Skip to content

Instantly share code, notes, and snippets.

@davesteele
Created July 20, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davesteele/03e6e30bf9e3ecae5c73dd9d7b560ed3 to your computer and use it in GitHub Desktop.
Save davesteele/03e6e30bf9e3ecae5c73dd9d7b560ed3 to your computer and use it in GitHub Desktop.
Synchronize Dropbox todo.txt on a Raspberry Pi
#!/home/pi/virtualenvs/todo/bin/python
import dropbox
access_token = ""
dbx = dropbox.Dropbox(access_token)
dbx.files_download_to_file("/home/pi/Dropbox/todo/todo.txt", "/todo/todo.txt")
#!/home/pi/virtualenvs/todo/bin/python
# https://github.com/dropbox/dropbox-sdk-python
import dropbox
# https://github.com/davesteele/todo.txt-gtd
from tdtgtd.tdtbackup import backup_path
# can get access token directly from Dropbox app
access_token = ""
dbx = dropbox.Dropbox(access_token)
(md, res) = dbx.files_download("/todo/todo.txt")
path = backup_path("/todo/backup")
dbx.files_upload(res.content, path, mode=dropbox.files.WriteMode("overwrite", None))
with open("/home/pi/Dropbox/todo/todo.txt", "rb") as fp:
data = fp.read()
dbx.files_upload(data, "/todo/todo.txt", mode=dropbox.files.WriteMode("overwrite", None))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment