Sync files with Dropbox
I'm new to Pythonista (and not exactly savvy with Python). Is there a way to sync everything with Dropbox, as there is in Editorial?
So far I've tried using DropboxSync script, and even created a new app in Dropbox, but nothing has worked so far -- there's always some issue with Dropbox or Python/Pythonista. It's frustrating (for me at least). I just want to get started with my scripts instead of wasting 2 hours on this.
Any help or URLs to some working script is greatly appreciated.
@bennr01 Thanks for the clarification and the links. It is unfortunate that syncing between your own devices can't be built in because of this.
If you just want to grab a script from your Dropbox, here's a simple 8-liner that does it using the share sheet. Put this in your pythonista share sheet extensions, then from the Dropbox app, run the script, and the script will land in your pythonista file system with no fuss or muss.
In order to work with the new Dropbox API V2 I have written a new synchronization app. The instructions for installation and configuration are documented on my blog page Pytopia. I have been using the new app on my iPad and iPhone for about a week and it seems to be working pretty well. I would love to have other eyes on it.
Set up the app in dropbox as per your instructions. When I run the Sycronator script I get an error: 'FileMetaData object has no attribute 'content_hash'. I am using the app store version of Pythonista 2.11. Is the script designed to run in Pythonista 3? What directory does the script belong in, it's own, or the Pythonista root directory? I assume the DropboxSetup script goes in the site-packages folder where it can be imported by other scripts that need Dropbox access.
@markhamilton1 Please consider converting the gists into a GitHub repo so that we can submit pull requests (suggestions for improvement).
Step one would be to add the line:
from __future__ import print_function
At the top of your script files before all other imports and then fix up the print statements. This will help to get your scripts working with both Python 2 and Python 3.
@omz Please consider adding "Publish to Repo" functionality to Pythonista.
def valid_filename_for_upload(filename): return not any((filename == STATE_FILE, # Synchronator state file filename.startswith('.'), # hidden file filename.startswith('@'), # temporary file filename.endswith('~'), # temporary file filename.endswith('.pyc'), # generated Python file filename.endswith('.pyo'))) # generated Python file
Be sure you have the latest version of the dropbox package installed. It is 7.2.1.
I tried changing the test to use any but it gave me an error. I will keep looking into it though.
Thanks for the feedback!
Sorry @markhamilton1 my mistake. Any() takes an iterator so you need to bundle all the arguments into a tuple. I have fixed the code above. If you copy and paste that, it should work now.
Thanks! That is an awesome pattern! I have updated the code. I will create a git repo today sometime.
There is now a git repo for the code for all of you that would like to add to it.
It can be found at
This is open source, no license, no waranty, use at your own risk, blah blah blah. Welcome to a world run by lawyers.