omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Sigafoos

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    Sigafoos

    @Sigafoos

    0
    Reputation
    714
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Sigafoos Unfollow Follow

    Latest posts made by Sigafoos

    • RE: Use python workflow to submit request to REST API?

      Definitely. You can use requests to make API calls.

      posted in Editorial
      Sigafoos
      Sigafoos
    • Uploading from camera library via xmlrpclib

      I couldn't find anything else in the forums, but I'm trying to upload an image to a Wordpress site via xmlrpclib. I was able to do it with an image hosted online using this code:

      def new_image(url, post_id = None):
      	import urllib2
      	from re import findall
      	
      	raw = urllib2.urlopen(url)
      	image = raw.read()
      	
      	content = {}
      	content['bits'] = xmlrpclib.Binary(image)
      
      	content['name'] = findall('[^\/]+?$',url)[0]
      	content['type'] = 'image/jpeg'
      	if post_id is not None:
      		content['post_id'] = post_id
      	
      	img = server.wp.uploadFile(1,username,password,content)
      	return img
      

      (server, username and password are defined earlier)

      I'm trying to do the same thing with an image chosen from my camera roll (I go through my company's Instagram feed and upload it for a weekly blog post, but sometimes I have a 4:3 version I want to use instead). To get content['bits'] I'm using:

      import photos
      	
      image = photos.pick_image(False, True, False)
      image[0].verify()
      
      content = {}
      content['bits'] = xmlrpclib.Binary(image[0].tostring())
      

      This... works, in that an object is returned, but the image doesn't actually upload. See this example.

      File and I/O stuff are what I hate most about coding, and I don't really understand all the components, so maybe (hopefully) there's something easy I'm missing.

      posted in Pythonista
      Sigafoos
      Sigafoos
    • RE: Uploading from camera library via xmlrpclib

      Wonderful, thank you!

      Using JPEG still didn't work, so I went the raw_data route, and it works perfectly. For posterity:

      content = {}
      image = photos.pick_image(False, True, True ,True )
      content['bits'] = xmlrpclib.Binary(image[0])
      
      posted in Pythonista
      Sigafoos
      Sigafoos
    • RE: Uploading from camera library via xmlrpclib

      Thank you! But now I'm having trouble with .save():

      with io.BytesIO() as bIO:
      	image[0].save(bIO,'JPG')
      	content['bits'] = bIO.getvalue()
      

      The second line gives KeyError: 'JPG'. So I thought it might be interpreting that as an option and not format I added {'quality': 80} and got TypeError: save() takes at most 3 arguments (4 given)

      So... It thinks there's an extra argument? To make sure image[0] was correct I did .show() and it worked...

      posted in Pythonista
      Sigafoos
      Sigafoos
    • RE: 1.1 Bugs?

      Sorry if this has been covered elsewhere (it didn't seem to be):

      The Extract Range action can handle negative values, but (at least on the iPhone version) the keyboard that pops up is the numeric one, so I can't input a negative number.

      I actually just realized that what I really want is Remove Whitespace (I was trying to do 1:-1), but it still seems like a bug.

      posted in Editorial
      Sigafoos
      Sigafoos
    • "Find" not working?

      I can't seem to get the "Find" block to work. This is what I'm trying to do:

      Find 'zzz'
      Set Variable 'firstpos'
      If firstpos != 0:0
          Show Alert 'Hey you forgot stuff'
          Stop
      Convert Markdown
      Open URL (Wordpress app url to post)
      

      The problem is that the Find always returns 0:0 (or an empty string if I do it that way). I've tried case sensitive, insensitive and regex. I tried just finding 'z' (without quotes, obviously). Nothing will make Find return a positive result.

      posted in Editorial
      Sigafoos
      Sigafoos
    • RE: "Find" not working?

      Wonderful! Thank you.

      posted in Editorial
      Sigafoos
      Sigafoos