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.
I'd also like to add that built-in Dropbox sync feature would be really appreciated by a lot of people.
There's a huge gap between people comfortable with every python script and API and those who just want to write some applet to cater to everyday automation need. I am the latter and I just can't find myself spending extra energy and attention on infrastructure.
So @omz if you're reading this, please consider adding this feature to Pythonista (I've been using Sync features in Editorial and it works like a charm).
@tengl Welcome to the forums! Unfortunally, a built-in dropbox-sync would not be allowed by apple, because apps are not allowed to download executable code. What Error do you get? What Interpreter (2 or 3) are you using? Also, here are some dropbox-scripts (which should work, but i have not tested them):
Also, StaSh may help you. It has some commands for transfering files, for eample a http- and ftp-server, the
mc-command also has some dropbox features, but it is not a autosync).
I'm not sure that a built in Dropbox sync feature would not be allowed by Apple. If Editorial already syncs scripts it seems ok. Apple is trying to prevent people from building app stores in apps as well as trying to protect people from running potentially bad programs.
I understand why the "Open in.." feature was not allowed by Apple considering their policies, but that is a different thing.
Syncing your own Python programs between your devices with Dropbox might not be a problem.
@Oscar Unfortunaly, it is still "downloading code" See the Guidelines (#2.7 and #2.8). @omz said something about this here and in other dropbox-sync requests. I have not used editorial in a while, but it seems like it lost the ability to sync code to/from dropbox (see here).
@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.