Created
December 13, 2013 03:52
-
-
Save BlackFoks/7939538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Script for showing or setting the dropbox folder. | |
# | |
# Execute without options to show current dropbox folder (if non-default). | |
# Execute with --setfolder=/foo/bar to set new dropbox folder. | |
# | |
# Written by Wim Coenen ([email protected]). | |
import base64 | |
import optparse | |
import os | |
import os.path | |
import sqlite3 | |
# parse command line options | |
cmdparser = optparse.OptionParser() | |
cmdparser.add_option("-s","--setfolder", dest="folder", | |
help="set dropbox folder") | |
(options, args) = cmdparser.parse_args() | |
db_path = os.path.expanduser("~/.dropbox/config.db") | |
db = sqlite3.connect(db_path) | |
cursor = db.cursor() | |
# get dropbox_path | |
cursor.execute("select value from config where key='dropbox_path'") | |
dropbox_path = "<default>" | |
for entry in cursor: | |
dropbox_path_base64 = entry[0] | |
dropbox_path_raw = base64.decodestring(dropbox_path_base64) | |
dropbox_path = dropbox_path_raw[1:-5] | |
print "current dropbox path: %s" % dropbox_path | |
if not options.folder is None: | |
new_path_raw = "V" + os.path.abspath(options.folder) + "\np1\n." | |
new_path_base64 = base64.encodestring(new_path_raw) | |
cursor.execute("delete from config where key='dropbox_path'") | |
cursor.execute("insert into config (key,value) values (?,?)", \ | |
("dropbox_path", new_path_base64)) | |
db.commit() | |
print "new dropbox path: %s" % options.folder | |
db.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello your script is useful, but it is not working with current dropbox version do you know any update about how we can change dropbox folder from ~/Dropbox to /var/app for example?