Access to shared ..\Documents
First post here, been using Pythonista for about 6 months. The best App I have ever downloaded.
I'm writing some code that uses logged time series data in another App.
Current to get access to that file I use iTunes file sharing, e-mail it to myself and transfer it to Pythonista using Scratchpad.
All this is great! However it would be good if I could just copy the file from its Shared folder.
Does anyone know if this is possible?
(File name is always the same but I do not know the long App identifier so cannot access //Shared//AppGroup//??//Documents)
Any thoughts greatly appreciated.
If the source app has a Share Menu, you can create an appex script that copies the file to pythonista.
i know several people have published their "save file to pythonista" app extension scripts.... here is mine:
#coding: utf-8 import urllib,urlparse import appex,console,time url=appex.get_url() p=urlparse.urlparse(url) f=urllib.unquote(urllib.unquote(urlparse.urlparse(appex.get_url()).path.split('/')[-1])) urllib.urlretrieve(url,f) import console console.hud_alert(f) appex.finish()
It turns out this works for urls (safari for example), but in other apps that expose files to the share menu, since it returns a file:// url to some app specific folder. for instance, if i click on a mail,attachment, and run pythonista script, get_url returns something like
I suspect in python3 you'd replace urlretrieve with just an urlopen, read() and write(), I admit I am lazy and enjoy the convienece or urlretrieve. Also, this probably would be a little more robust if it checked for an existing file before clobbering it, and perhaps auto incrementing and appending an integer until the file does not exist.
Many thanks for idea JonB
The App is called EngineLink. It's main function is just to display raw data. It has no Share Menu so I can't access that way.
You could still email it to yourself, but then click on the attachment and run the save attachment script above. It at least saves you a few clicks
alijnclarke last edited by
In objective c it is possible to get the path to an app's shared folder by querying a private Api with the apps bundle identifier.
Not sure if it's possible to access these within pythonista but I'll give it a go and post back
The shared folder is only for apps that share an appgroup (i.e by same developer, such as the two pythonista beta versions). Due to obvious security concerns, apple sandboxes apps such that without jailbreak, you cannot access another app's sandbox.
@JonB .Am using the appex module to get the file into Pythonista which is very useful and not too much hassle.
I thought it might be possible to get at the file direct given that it is being made available via iTunes.
Not a major blocking point though. Thanks again