We're working on a brand new Dropbox Wiki with better features and ease of access! Find out more.

PyDropboxValues

From Dropbox Wiki

Jump to: navigation, search

Improved Python script to get dropbox config values

Works for both dropbox 0.7.x, 0.8.x and 1.0.x and on all platforms (Windows / Mac / Linux)

Contents

Download

Download here: http://dl.dropbox.com/u/340607/pyDropboxValues.py

For Python < 2.6 Users: http://pastebin.com/eKymSQ1w

Usage

Place pyDropboxValues.py somewhere on your $PATH, make it executable, and then run it in a terminal / DOS window.

pyDropboxValues.py

It will print a big list of all the config keys, and their values.

Extra Features :-D

  • Get the value for just one config key, e.g. 
pyDropboxValues.py dropbox_path

    or 

pyDropboxValues.py email
  • Print out all available config keys (the little u at the front of each just means they're Unicode strings - you can simply ignore it)
pyDropboxValues.py _printkeys

  • Print the location of the user's Dropbox folder (not always stored in the config database)  
pyDropboxValues _dropbox
 pyDropboxValues.py _linkurl
  • Backup your config database (so you can restore it, if you accidentally break it)
pyDropboxValues.py _backup
  • Display the 'raw' undecoded values
pyDropboxValues.py _raw
  • Display the 'special' options accepted by this command
pyDropboxValues.py --help
  • If you want, you can do
from pyDropboxValues import *

in your own Python script, and then you have access to the functions GetConfigDbDirectory, GetConfigDbFilename, GetDbConnection, GetDbVersion, GetDbKeys, ReadDbValue, WriteDbValue, DeleteDbValue, & GetDropboxLocation (hopefully the usage is fairly straightforward, see Switch_Proxy_Settings for an example) - I'm not sure of the re-use licence of my code because it borrows so much from the two scripts mentioned below, and neither of those specify a licence.

SyntaxError: invalid syntax
If you are using Python 2.5 or earlier maybe you will get this error.

  File "./pyDropboxValues.py", line 213
    except Exception as detail:
                      ^
SyntaxError: invalid syntax

For fix this you must upgrade your python version to 2.6 or greater (or see the link near the top of this page).

History

As a developer and tinkerer I really liked the functionality provided by Python_Script_To_Display_Config but unfortunately it doesn't work once you've upgraded your dropbox client to the 0.8.x builds... I'd also seen some people say that it sometimes didn't work properly on Linux.

...so I fixed both these problems by taking the best bits of Python_Script_To_Display_Config and the best bits of pyDropboxPath to create this script!

Like pyDropboxPath, it seamlessly works on all operating systems and with all dropbox versions; and like Python_Script_To_Display_Config it simply prints out all the configuration values stored in the dropbox config database.