daily pastebin goal
10%
SHARE
TWEET

dropbox_set_lansync.py for Python 2.x

a guest Jan 18th, 2011 710 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # Python script to enable or disable dropbox LAN-sync
  3. # This file written by Andrew Scheller, 2010-11-09
  4. # Adpated by Fr3d for Python 2.x Users, 2011-01-18
  5.  
  6. import sys
  7. import os
  8. from pyDropboxValues import *
  9.  
  10. dbfile, dbfnver = GetConfigDbFilename()
  11. connection = GetDbConnection(dbfile)
  12. dbver = GetDbVersion(dbfnver, connection)
  13.  
  14. if dbver == 0:
  15.         key = 'p2p_enabled'
  16. elif dbver == 1:
  17.         key = 'p2p_enabled'
  18. else:
  19.         raise Exception('Unhandled DB schema version %d' % dbver)
  20.  
  21. try:
  22.         try:
  23.                 if len(sys.argv) == 2 and sys.argv[1] in ('on', 'off'):
  24.                         enable_lansync = (sys.argv[1] == 'on')
  25.                         if dbver == 0:
  26.                                 value = enable_lansync
  27.                         elif dbver == 1:
  28.                                 if enable_lansync:
  29.                                         value = 1
  30.                                 else:
  31.                                         value = 0
  32.                         else:
  33.                                 raise Exception('Unhandled DB schema version %d' % dbver)
  34.                         WriteDbValue(connection, dbver, key, value)
  35.                 else:
  36.                         print "Usage: %s <on|off>" % os.path.basename(sys.argv[0])
  37.         except Exception , detail:
  38.                 print "An error occured: %s" % detail
  39. finally:
  40.         connection.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top