• Sigafoos

    Definitely. You can use requests to make API calls.

    posted in Editorial read more
  • Sigafoos

    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)
    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 read more
  • Sigafoos

    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 read more
  • Sigafoos

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

    with io.BytesIO() as bIO:
        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 read more
  • Sigafoos

    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 read more
  • Sigafoos

    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'
    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 read more
  • Sigafoos

    Wonderful! Thank you.

    posted in Editorial read more

Internal error.

Oops! Looks like something went wrong!