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.
Dropbox file picker needs update
-
@enceladus, thanks. Please host it in a repo or at least make it a gist (share - gist in pythonista), and we will put an updated link in Pythonista-Tools.
-
I would request @bosco to create the gist. He/she has done the main changes. (I have done small edits for running in python3). Anyway if he/she has not created the gist I will create after two/three days mentioning this thread.
-
@enceladus Please go ahead and make a gist. I hope contribute more in the future when I have more time. Thanks!
-
Ok. here is the gist. Thanks @bosco .
https://gist.github.com/encela95dus/67fd65aec0c25336ac8e70153ebcf7eb
-
The gist fails as follows:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/dp.py", line 127, in load_folder
infos = list_folder(self.path)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/dp.py", line 42, in list_folder
result = r.json()
File "/var/containers/Bundle/Application/A30CF941-D366-4CE5-BCAA-C22CBEC6C501/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/requests/models.py", line 809, in json
return complexjson.loads(self.text, **kwargs)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/simplejson/init.py", line 516, in loads
return _default_decoder.decode(s)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/simplejson/scanner.py", line 127, in scan_once
return _scan_once(string, idx)
File "/private/var/mobile/Containers/Shared/AppGroup/B86CEE4E-E4A9-4BB4-9CA7-6E13BDA2C2A4/Pythonista3/Documents/site-packages/simplejson/scanner.py", line 118, in _scan_once
raise JSONDecodeError(errmsg, string, idx)
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0) -
I do not get this error. (I have tested with various file extensions .txt, .py, .zip, .jpg etc). I use beta version of pythonista. May be this is due to different versions of request or json module. May be others could throw some light on this.
Can you try with python2 with original omz version with @bosco changes?
-
I do not have this "simplejson" module. Rename this module and see if that works.
I think that this is the issue. See the following url/
https://github.com/requests/requests/issues/3052 -
Hmm..I renamed the SimpleJson folder which was in sitepackages but I get the same error regardless.Funny thing is that this worked before bu now even the version I created from thte earlier posts is failing the same way. It must be somethign other than that simplejson.
-
Try running the following code to see if simplejson module is imported. Did you restart the pythonista after renaming sinplejson module?
import simplejson
-
@ihf This script appears to work with python 2 or 3. Try changing #!python3 to #python2. It shouldn't be using simplejson, since json is a core python module. I see now that the your error may be a problem with your requests package. LIne 42 which reads result = r.json coverts the result to json. Line 41 contains json.dumps(data), which converts the arguemnts to a string.
@enceladus Thanks for creating the gist.
-
in requests.compat:
try: import simplejson as json except (ImportError, SyntaxError): # simplejson does not support Python 3.2, it throws a SyntaxError # because of u'...' Unicode literals. import json
If simplejson is present, requests will use it. delete simplejson and fo ce quit pythonista
-
I am at a loss. Something obviously changed in my setup but I have no clue as to what. I deleted simplejson, emptied trash and restarted Pythonista. Then I recreatied the script using the gist and adding my access key and I get a jsondecode error Expecting value: line 1 column 1 (char 0).
If I run under Python 2.7 I get "No JSON object could be decoded'import simplejson results in module not found so perhaps now I have a different problem.
-
I figured it out (sort of). I generated a new access key and now it works. Thank you all.
-
The new version is added to pythonista-tools. Thanks to all.
script name: Dropbox File Picker V2
Description: Script to import a file from Dropbox into Pythonista - Dropbox V2 APIhttps://github.com/Pythonista-Tools/Pythonista-Tools/blob/master/Utilities.md
-
This is great, thank you. While I am dreaming, it would be wonderful if someone in the future were able to make the picker, 2-way so that individual files could be uploaded to dropbox as well as downloaded as is the case now.
-
@ihf, I do not use Dropbox, but if you have the Dropbox client installed, is it not available when you Share... from Pythonista?
-
@mikael You are quite right....somehow I never noticed the Share from Pythonista only the Share to. Thanks for pointing that out.