Advertisement
Guest User

dropbox_set_lansync.py for Python 2.x

a guest
Jan 18th, 2011
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement