Sync to Dropbox
Finished a new sync program called Synchronator to sync from Pythonista to Dropbox and visa versa. It uses the new Dropbox API (the old one is deprecated). It can be found in Github at https://github.com/markhamilton1/Synchronator. I have now been using this to sync between iPad-Dropbox-iPhone. Take a look at the project wiki at https://github.com/markhamilton1/Synchronator/wiki.
Any feedback would be appreciated. This should work in either Python 2 or 3.
I've just installed Pythonista, the dropbox and requests packages and Synchronator. When I run DropboxSetup.py I get the following:
/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version!
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/Dropbox/DropboxSetup.py", line 54, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/dropbox/init.py", line 3, in <module>
fronds in my UJ UK m .dropbox import version, Dropbox, DropboxTeam, create_session # noqa: F401
File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/dropbox/dropbox.py", line 17, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/EAEDE395-145A-4A8B-A282-E6D1409E3D51/Pythonista3/Documents/site-packages/requests/init.py", line 90, in <module>
from urllib3.exceptions import DependencyWarning
ImportError: cannot import name 'DependencyWarning'
- make sure you are using the latest stash.
- Install requests
pip install requests
- For me, I had to update chardet and idna. Update failed, but install then fixed it.
pip update chardet pip install chardet pip update idna pip install idna pip update dropbox pip install dropbox
- in console:
M=[m for m in sys.modules if 'requests' in m] for m in M: del sys.modules[m] import requests
@JonB can you explain the purpose of step 4? And with all the packages that have been installed, why am I only interested in requests? Thanks
you could just force quit pythonista. The issue is that requests is imported by stash, so to force the new version to import, you have to delete everything related from sys.modules.
@JonB why don't I have to do the same for the other packages that have been installed? Do you mean StaSh doesn't use the other packages?
@JonB I tried the first line at the console and got:
>>> M=[m for m in sys.modules if 'requests' in m] Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'sys' is not defined
Again, the only reason I did this was to check that the import was successful, without a full quit -- it took a few tries, to figure out that I needed to update chardet, then idna.
Since you know what you need to update already, just double tap the home button and swipe to kill pythonista. When you come back, import requests and if it works, you are good to go
@JonB I killed and restarted Pythonista and got:
>>> import requests /private/var/mobile/Containers/Shared/AppGroup/77E4F4DB-EDA3-49C3-8AAD-D4452754B812/Pythonista3/Documents/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/mobile/Containers/Shared/AppGroup/77E4F4DB-EDA3-49C3-8AAD-D4452754B812/Pythonista3/Documents/site-packages/requests/__init__.py", line 90, in <module> from urllib3.exceptions import DependencyWarning ImportError: cannot import name 'DependencyWarning'
Did some more digging and found that StaSh had installed urllib3 version 1.4 whereas the latest version is 1.22. Fortunately I am still at the beginning of my journey with Pythonista so I have deleted and reinstalled it. I will try again.
There is a problem with the way StaSh
piphandles installing minimum versions. I have raised an issue on GitHub (see Pip installed wrong version of urllib3). To get round the problem, check the latest version of the package you are trying to install using PyPI - the Python Package Index and install that version using:
pip install [-d <directory>] <package>==<version>
And if a package gets installed as a dependency for another, check its version and if it is wrong perform a
pip removeand install the correct version.
I am documenting exactly how I am getting this to work and, once it does, I will post it on this forum.
I have the same issue as you, but when I tried to install/update/ remove requests, I get the same issue:
StaSh v0.6.20 Tip: You can redirect output to Pythonista console, e.g. ls > &3 [~/Documents]$ pip install requests /private/var/mobile/Containers/Shared/AppGroup/8D798770-A6EB-4040-9568-3BCBFB1CF8E8/Documents/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.4) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning) stash: <type 'exceptions.ImportError'>: cannot import name DependencyWarning
Is there a way to fix the requests module without deleting Pythonista altogether?
@HerniaChair I'm not an expert and so I don't know if it will work, but you could try deleting the requests folder in site-packages and close down and restart Pythonista
Yes, remove requests from site packages, then follow the instructions on the other thread.
I’m having exactly this problem and cannot even uninstall the package with pip (I keep getting the same error).
Can someone point me to the “other thread” that is mentioned in this post? Nothing in this post seems to hint at how to get rid of the offending package. Can I do it manually?
Thanks for any help.
I have to say that Pythonista is an awesome program that has been a huge help to me in working on planes, etc.
Probably bad form to answer my own post, but I ended up deleting the package directories (/site/packages/urllib3 and /site/packages/requests). This let me run pip and “uninstall” the packages correctly.
Now I’m trying to get back to the original task to figure out what I need to download latest Dropbox API, resolve this dependency issue with urllib3, and get Synronator.py to run so I can backup the many python programs I’ve written in Pythonista.
If anyone has more details on these steps, I’d appreciate it.
This thread was very helpful to me with resolving the issue with the outdated version of the Requests module. Thanks.
Now that the Synchronator script is running, I am wondering: Is there an ignore list? I would prefer not be syncing site-packages.
Hmm I should also comment that I'm having to run synchronator repeatedly. I keep getting a LookupError('malformed_path', None). It appears to be related to the fact that the dropbox contains filenames starting with '.' (uploaded by DropboxSync) that Synchronator doesn't consider valid to sync (based on the valid_filename_for_upload function).
I think that my sync may be completely fubar'd due to the remnants left over from DropboxSync, but I'm afraid if I empty out the app folder and resync, it's probably going to try to empty and delete the site-packages folder.
EDIT: I ended up deleting the old app and creating a new one, and clearing out all the state files and token. Hopefully that'll resolve the issues with existing files from DropboxSync and previously-crashed Synchronator instances.
Alternate solution without using API's
I was also looking for something similar and thought it shouldn't be that difficult or time taking. That's when I came across "Shortcuts" app which I use for lot of other workflows.
I managed to get it done with 2 simple steps which is already available in iPad or iOs :
1. Create a shortcut app
2. From Pythonista on the right corner top click on share and select "Shortcuts" and your created shortcut.
( File is now received in your dropbox )
To create workflow in Shortcuts
a. Search for "Get Text from Input" and drag the same to your workflow.
b. Search for "Save File" and select "Service" as "Dropbox" (Note : You'll be asked to login to your dropbox once)
That's it. Worked for me like charm.
iPad version : 12.4
P.S. This is only for those lookng for just syncing the files to dropbox from Phythonista not caring about using dropbox apis.
@timmymathew If you want to send your file to Shortcuts app, there is a quicker way.
Actually, you tap on Tools, Share, Shortcuts, your shortcut.
With this way, you tap Tools, "Share to shortcut" (or the text you want, of course)
You have to do, once,
- your shortcut, named here, My_shortcut, containing only:
Save file.....as yours shortcut
- create the little script here-under and add it to Tools
That's all, folks
import clipboard import editor import webbrowser t = editor.get_text() clipboard.set(t) url = 'shortcuts://run-shortcut?name=My_shortcut&input=clipboard' webbrowser.open(url)
- your shortcut, named here, My_shortcut, containing only: