• SpotlightKid

    Thanks for the heads up!

    There was an error in the regex to parse the bottle version. Should be fixed now. Your approach unfortunately wouldn't work with version strings like '0.13-dev'. Anyway, I think on Python 2 the version of bottle included with Pythonista should be fine, so I adapted the code to reflect this too.

    posted in Pythonista read more
  • SpotlightKid

    Hi all,

    I needed a way to make my iPad display images scaled to fullscreen without taking my hands off the keyboard/mouse of my main computer. Thus ImageFrame.py was born:


    Just run this script in Pythonista and it will start up with a fullscreen display of the 'test:Lenna' image included in Pythonista. Then use the provided script send-image.py on your main computer to upload an image and have it displayed instead (requires the requests library). The image is added to the Photo Library on your iOS device in an album called "Image Frame" (which will be created if it does not exist yet). I add this script as a handler for images to the right-click context menu of my file browser. You can also point your browser to http://<ip of your ios device>:8080/ and upload an image via an HTML form. Use a 2-finger wipe down to end the script.

    I use this for displaying reference images while drawing or cheat sheets for keyboard shortcuts or programming languages while coding. But it also makes it possible to use your iPad as an over-priced digital image frame ;)

    Bugs / Areas for possible future improvements:

    • Runs on Pythonista 2 or 3, although on Pythonista 3 there are some problems with uploading images through the browser. The send-image.py script simply sends the image via HTTP PUT and this works without problems on both Pythonista 2 and 3.
    • No authentication whatsoever
    • You need to pass the IP address of your iOS device to the upload script or edit it to set the default.
    • The network status, clock and battery status are always displayed at the top of the screen.
    • Some sort of automatic slideshow display would be nice.

    Share & Enjoy, Chris

    posted in Pythonista read more
  • SpotlightKid

    That's what I would think too. Apparently Apple doesn't. If you can't live with this, don't use Apple products. Life's a bitch.

    posted in Pythonista read more
  • SpotlightKid

    The easiest way for me is usually the Dropbox File Picker.

    Your need to do some initial setup as explained in the comments at the start of the file, but then it's easy and convenient.

    posted in Pythonista read more
  • SpotlightKid

    How about putting the month in the filename:

    filename = "data-%s-%02i.csv" % (stock.replace('^', ''), startdate.month)

    posted in Pythonista read more
  • SpotlightKid

    Small suggestion:

    from datetime import datetime, date
    month = int(datetime.strftime(date.today(), "%m")) - 1
    year = int(datetime.strftime(date.today(), "%Y"))

    This can be just written as:

    from datetime import date
    month = date.today().month - 1
    year = date.today().year

    No need to format the month/year number into a string and then into an integer again.

    posted in Pythonista read more
  • SpotlightKid

    BTW, if you want to play with the URL parameters (params a-f can be used to set a date range), you can construct the URL params from a dictionary like so (note that the month number has to be minus one):

    STOCK_URL = 'http://ichart.finance.yahoo.com/table.csv'
    PARAMS = {
        'a': 9,
        'b': 1,
        'c': 2014,
        'd': 9,
        'e': 31,
        'f': 2014,
        'g': 'd',
        'ignore': '.csv'
    def pulldata(stock, filename):
        params = PARAMS.copy()
        params['s'] = stock
        url = "%s?%s" % (STOCK_URL, urllib.urlencode(params))
        return urllib.urlretrieve(url, filename)

    Here's the documentation of the API:


    posted in Pythonista read more
  • SpotlightKid

    The File2Txt.py file could be written much shorter using shutil.copy() and os.path.splitext().

    In Python is pays to know your standard library well.

    posted in Pythonista read more
  • SpotlightKid

    RUT doesn't seem to be a valid stock identifier. Try '^GDAXI' for the German DAX.

    posted in Pythonista read more
  • SpotlightKid

    Just pass the path of the output file as a second argument to urlretrieve(). The filename is also the first item of the tuple returned by this function.

    import urllib
    STOCK_URL = 'http://ichart.finance.yahoo.com/table.csv?s=%s&a=07&b=25&c=2014&d=07&e=29&f=2014&g=d&ignore=.csv'
    def pulldata(stock, filename):
        return urllib.urlretrieve(STOCK_URL % urllib.quote(stock), filename)
    filename, headers = pulldata("RUT", "RUT-data.csv")

    If you want to save the file in your documents folder, build the filename like this (there are several ways to do this, but this one will work on desktop Python as well):

    import os
    from os.path import exists, dirname, join
    # create output directory if it doesn't exist yet
    documents = join(os.getenv('HOME'), 'Documents')
    if not exists(documents):
    filename = join(documents, 'RUT-data.csv')

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!