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
-
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''
-
@omz Beat me to it 😄
-
@omz It worked! Thanks for helping out on this noob issue. :)
Now I am reading the source code of
iter_content
and it callsself.raw.stream(....)
. But if I try this withurllib3
directly, it still won't work ... anyway, it is not important as onlyrequests
is designed for humans ... -
@Webmaster4o Aside: When you're dealing with binary data (zip files, images...), you should use
r.content
instead ofr.text
-
-
Why not just switch to requests for all of this? It works in both Python 2 and 3 and is far easier and more reliable to use than the alternatives. At the last Pycon, the consensus was to move requests into the Standard Library but the maintainer declined because he wants to keep the innovations and bug fixes coming at a faster pace than the Standard Library process would allow.
If you moved to requests, what functionality would still be missing?
-
@dgelessus Thanks for the information. Didn't know that.
BTW, to test the Python 3 port, run following one-liner to get the
py3
branch.import requests as r; exec(r.get('http://j.mp/gsp35').text)
-
@ccc I have now switched to requests following omz's example code. It's indeed much friendly than urllib.
-
@JonB Dulwich supports at least to Python 3.4 But Gittle has no Python 3 support. Any idea how the
git
tools could be ported to Pythonista 3?The python-future project has an experimental feature to automatically translate Python 2 modules to Python 3 upon loading. But I am not sure how reliable it is.
The main framework of StaSh is working now. I am in the process to make sure all the commands still work. I have ran
git
through some 2to3 tools so itself is now mostly Python 3 compatible. But the dependencies could be the tricky part. -
This post is deleted! -
I guess I can start removing gittle dependancies (right after I finish the gh command, which is almost ready)
Much of gittle is superceeded by dulwich porcelain, or workarounds in my own code. I have been itching to rewrite git from scratch for a while anyway. my newfound discovery of
docopts
will make much of the CLI interface easier, the trickier bit is whether it makes more sense to update dulwich, or git. -
Guys, time for a new thread for StaSh Pythonista 3.x?
-
-
@ywangd I've just installed Stash. How do I cd to the Home directory? I'm not familiar with the iPad file system.
"Please run launch_stash.py under the Home directory to start StaSh."
-
The best way to run stash, is to click the wrench icon, then edit, then the plus sign. then find the launch_stash file.
Then, you will have a shortcut in the wrench menu that you can run anytime.
-
@cappy The
launch_stash.py
file is found in the directory when you start Pythonista, i.e.Documents
.From Pythonista's file browser (swipe to right to reveal it if not already visible), select
launch_stash.py
. This opens the file in the editor, then click the Run button (the right-facing triangle on the top right) to start StaSh.Once you know where the launch file is, you can create an editor action to access it quickly as @JonB suggested.
-
I just typed 'git' into stash and got this, looks similar to something posted in here earlier...I'm so confused.
'''
StaSh v0.4.0
[~/Documents]$ git
Opening: https://github.com/transistor1/dulwich/archive/master.zip
Save as: /private/var/mobile/Containers/Data/Application/B381FF20-8B02-43E0-870D-BCC9678441DA/tmp/dulwich.zip
8192
16384
24576
32768
40960
49152
57344
65536
73728
81920
90112
98304
106496
114688
122880
131072
139264
147456
155648
163840
172032
180224
188416
196608
204800
212992
221184
229376
237568
245760
253952
262144
270336
278528
286720
294912
303104
311296
319488
327680
335872
344064
352256
355169
stash: ImportError('No module named dulwich',): (No module named dulwich)
[~/Documents]$'''
-
@Tizzy your stash is v0.4.0 but the current version is v0.6.0.
-
@Tizzy It is recommended to install the latest version of StaSh (0.6.3). Version 0.5 and up is not compatible with 0.4 and lower. So please delete your current 0.4 installation and run the following oneliner to get the latest release:
import requests as r; exec r.get('http://bit.ly/get-stash').text
Once installed, restart Pythonista and run
launch_stash.py
underDocuments
to start.