Method to download gists to pythonista that currently works
JonB last edited by JonB
savefile does still work, using the Pythonista 3 share sheet. it takes a few secs for the interpreter to start,but the starts. you share from the main gist page.
robopu last edited by robopu
@JonB thx for followup.. i'm not sure i'm following the link you posted in the bottom of your reply. i would think i have no control over what the share sheet is sending to savefile.py.. so how do you know what is being set in the call back url from the share sheet in the first place? i'm curious because maybe that's part of the problem of why it's not working?
i thought that regardless of whether i ran from the share sheet in the form of an x-callback or simply copied the url in safari and run the script manually when i switch back to pythonista with url in the clipboard, that the only argument to this script is the url of the gist? but it looks like a bunch more things are being populated in the link you pasted.
also, perhaps i'm copying the wrong url?
this is the link i'm highligting and copying before running the script?
by default what directory will savefile put the downloaded gist?
fwiw, after spending a couple of days trying to get all this to work it would have been easier but not simple to just copy and paste the gist code in safari directly into a new pythonista file except for the fact that for some reason that "select all" is not allowed in safari gist text on my iphone7 which means i have to tediously drag to try and select everything past 1+ scrolls which often fails before i can actually copy!??
thx for the help!
JonB last edited by JonB
sorry, i just updated the link. it should spawn pythonista with a "run this script" box. run it, shich just copies savefile.py to documents. If you already copy/pasted it into a file, then you can skip that step.
To use, you go to the gist page, this script doesnt use the clioboard, it uses safari address bar.
go to a gist page, use the safari Share To button, then Run Pythonista Script.
From the pythonista app extension that lanches, click Edit, then the Plus Sign, and choose
savefile.py. The script looks at current safari address bar, and downloads the file on that page. If it is a gist or multipart gist, it downloads it to the Dicuments/gists/gistid folder, so as not to overwrite any existing files you have with that name.
robopu last edited by
@JonB .. ok just to confirm..
- i'm on the gist page..
- this time i do NOT try and copy the url i simply click Share button in safari
- then i click " Edit Scripts" which brings me to pythonista
- in pythonista i don't have a + option like you mention but i see my filesave.py file right in my local directory listing in the file browser (probably b/c that's where i last was in pythonista) so i simply select the file which loads it into the editor
- the script is just sitting there in the editor and does nothing on it's own so i click the "right arrow symbol" to run the program..
when i do that i get this error in the console:
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/50D9A78C-3AC4-470C-908E-FB2D1012D385/Pythonista3/Documents/gitsavefile.py", line 9, in <module> urlfilename=unquote(unquote(urlparse(appex.get_url()).path.split('/')[-1])) TypeError: a bytes-like object is required, not 'str'
so it looks like it's expecting bytes and not a string?
thanks for the clarification on how the script was supposed to work?
use the install link.
then, from app extension, if you are editing a script, click back a few times untill you get to the main appex page. should have edit in upper left, and some icons below. you wNt to add savefile to the bottom icons.
robopu last edited by robopu
@JonB sorry but unfortunately your install link for filesave is failing for some reason.. error is something about
AttributeError __enter__followed by
.exec_from_url.py <module> (Line 13)
not sure what's going on.
also from your last reply "click back a few times untill you get to the main appex page. should have edit in upper left, and some icons below. you wNt to add savefile to the bottom icons." doesn't really look the same to me as you describe. maybe because i'm on an iphone7 vs ipad?
i'm not sure what the main "appex" page means unless that was spellchecked for " index" :), once there, i see "Edit" button but it's in top right vs left.. The icons below are simply my normal pythonista file browser listing with icons for folders and files with their appropriate names. python actualy opens the file filesave.py into this location but because of the script failure nothing actually gets written so that when you open it to run it, it's empty..
In the normal app extension, you should be able to edit scripts, but there is also a consols, and a menu somewhat like the wrench menu,where you can run scripts without having to open/edit them. Savefile wants to run from there (though it should work in the editor, except that I fear you may have accidentally edited something)
Can you try copying it again? Then try it one the gists above. (Just to rule out problems with the specific gist). I'll make some updates to give more detailed error messages.
GoDzM4TT3O last edited by
robopu last edited by
@JonB .. your link to copy filesave never worked. i tried it a number of times. the code runs, the file is created but it's empty. perhaps the path is not correct or i need a github token or something?
that said, by manually pasting the filesave script, i was eventually able to get this to run and it works downloading the gist i specified above! i confess, it took me a number of iterations to try and assign the script to an "appex action" thing or whatever it's called so that it showed up from the share sheet extension automatically but somehow it eventually did.
your instructions were different from what i saw on my iphone.
the wrench only appears when editing a file. once you click the wrench, you have an Edit button that allows you to add a blank "icon" with a plus in it. from there you choose the file to assign to the icon which then shows up one you drill back to pythonista from the share sheet.
anyway : just so i'm clear. for the share sheet to work correctly, do these icons assigned to pythonista scripts need to exist (ie it's the glue that the share sheet looks for)? or put another way do pythonista scripts only recognize the appex data when called in this way? because before i could assign the icon to the filesave script, when i share sheeted from safari back to pythonista it dropped me in the editor. if i then navigated to savefile and ran it manually, it didn't appear to be able to access the appex data of the last page i was on in safari. my guess is the answer is yes.. savefile needs to be tied to the icon which is what you call the appex extension??
thanks for being patient and following this through. much appreciated. i got it working just want to make sure i'm understanding the right process for interfacing with appex data via share sheet
I'm not sure how the iPhone app extension looks, so not sure how it all works... Maybe you could post some screenshots somewhere.
I can't think of a reason why running the script in the editor gives a different behavior, though could be that the appex geturl returns something different. Some people have problems with the being dodgy.
By the way, you could add a print (appex.get_url()) to the start of the script to test whether that is working in edit mode...