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.
StaSh for Pythonista 2 and 3
-
the ios8crash branch seems to solve the specific problems i was having. modify getstash.py to list the ios8crash instead of master, then restart pythonista.
-
@ihf said:
@ywangd Please let me know if/when there is a version (other than v0.4.x) that I might try. Once one uses Stash with Pythonista it is hard to go back :-)
@JonB and I worked out two solutions for an iOS8 related crash issue.
You can get them with following one-liner installers.
- ios8crash
import urllib2; exec urllib2.urlopen('http://bit.ly/get-stash').read() in {'_br': 'ios8crash'}
- iso8crash2
import urllib2; exec urllib2.urlopen('http://bit.ly/get-stash').read() in {'_br': 'ios8crash2'}
Please let me know how they work for you. Thanks!
-
@ywangd I only tried the first solution and it worked!. Thank you very much!
-
@ywangd Will I be able to use selfupdate in the future or will I then lose the ios8 fix?
-
@ihf If nothing has changed you should be able to do something like
SELFUPDATE_BRANCH=ios8fix selfupdate
(this is a single command in one line) to update from a branch that isn'tmaster
. -
@dgelessus I just noticed that the leading environmental variable NO longer works for the new
selfupdate.py
. It used to work withselfupdate.sh
. I'll need to fix it later.As an alternative, you can still update to a specific branch by just typing
selfupdate.py BRANCH
@ihf Great the first fix worked for you. Could you please also give the 2nd fix a try? I currently prefer the 2nd fix as it is much simpler. The fix will stay in the main branch once it is finalised. This means you can simply
selfupdate
to get any future updates. -
@ywangd Unfortunately, ios8crash2 does not fix the problem (it crashes as before). Ios8crash works fine.
-
@ihf The fix is now merged into the
master
branch along with some other improvements. You can get the update by runningselfupdate
. Thanks! -
@ywangd On the latest version of StaSh, I get an error message that makes it unusable:
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/9BC2C58D-632D-4A13-9539-7CC3C7AA159A/Documents/launch_stash.py", line 36, in <module> reload(stash) File "/private/var/mobile/Containers/Shared/AppGroup/9BC2C58D-632D-4A13-9539-7CC3C7AA159A/Documents/site-packages/stash/stash.py", line 34, in <module> from system.shcommon import IN_PYTHONISTA, ON_IPAD ImportError: cannot import name IN_PYTHONISTA
-
@ywangd Never mind, I stopped getting the error without changing anything
-
@disorientedp said:
@ywangd Never mind, I stopped getting the error without changing anything
It is likely that the old stash related modules were still cached after updating. Restart Pythonista will clear the cache and fix the problem (as indicated by the last message printed by
selfupdate
). -
@ywangd, I sent you a pull request for an improved version of
edit
. Please let me know if you don't receive or if I've erred otherwise in the process; I'm an amateur on GitHub ;-( -
-
So the porting came along quicker than I expected. The py3 branch can at least start in Pythonista 3.
However many commands still not working, esepcially
wget
which then affectspip
andgit
. The issue is that I could not figure out how to download a zip file from GitHub usingurllib3
. I tried following code, but theread
method always returns an empty string !!??import urllib3 http = urllib3.PoolManager() r = http.request('GET', 'https://github.com/ywangd/stash/archive/master.zip') # So far so good, but then nothing can be read from the response object print(r.read()) # this gives an empty string print(r.read(999)) # empty string as well ...
I tried
requests
as well withrequests.get(ZIP_FILE_URL).raw.read()
. It returns empty string as well. I guess this is not a surprise asrequests
is a wrapper ofurllib3
.Any help is appreciated.
-
-
@Webmaster4o Thanks for the help. Unfortunately it didn't solve the issue. Still getting empty strings.
The problem that I am experiencing is with
urllib3
not2
. It actually worked fine withurllib2
. Sinceurllib2
is removed from Python 3,urllib3
seems to be the logical alternative. Theurllib
family just seem to have so many incompatibilities between versions. -
@ywangd What was your code using
requests
? That's usually easier to handle ;) -
@Webmaster4o I used the requests module as follows and try to read a chunk of data at a time.
import requests r2 = requests.get('https://github.com/ywangd/stash/archive/master.zip') print(repr(r2.raw.read())) print(repr(r2.raw.read(999)))
The read calls return empty strings as well. I noticed the
raw
property is in fact aurllib3
response object. So above code should behave the same as usingurllib3
. I do get content if I callr2.text
. But this downloads the entire file at once which is not what I am after. -
I usually use
requests
like this to download a file without having to load it in memory completely. Works in Python 2 and 3.import requests url = 'https://github.com/ywangd/stash/archive/master.zip' r = requests.get(url, stream=True) with open('dest.zip', 'wb') as f: for chunk in r.iter_content(1024): f.write(chunk)
-
I'm not sure what
raw
does, but it's empty on my macbook as well. Trytext
. Here's a comparison:>>> import requests >>> r=requests.get('https://github.com/ywangd/stash/archive/master.zip') >>> r.text[:100] 'PK\x03\x04\n\x00\x00\x00\x00\x00ۀNH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\x00\t\x00stash-master/UT\x05\x00\x01�\x16�VPK\x03\x04\n\x00\x00\x00\x08\x00ۀNHf��?�\x01\x00\x00\x1e\x03\x00\x00\x17\x00\t\x00stash-master/.gitign' >>> r.raw.read()[:100] b''