def handle(self): # self.request is the TCP socket connected to the client char = self.request.recv(1024) if len(char) == 1: len_secret = ord( char ) self.request.send('a') secret = '' while len(secret) < len_secret: chunk = self.request.recv( len_secret - len(secret) ) secret = secret + chunk b = BTSync() r = b.register_secret( secret ) self.request.sendall( str(r) ) self.request.shutdown(2) self.request.close()
#!/usr/bin/env python from btsync import BTSync from config import host,port,user,pswd b=BTSync(host,port,user,pswd) secrets=b.get_registerd_secrets() for secret in secrets: print secret
#!/usr/bin/env python from btsync import BTSync b = BTSync() print 'listen : {0}:{1}'.format(b.host, b.port) print b.get_os() print b.get_version() print b.get_speed()
from btsync import BTSync from config import host, port, user, pswd import sys secrets=sys.argv[1] b=BTSync(host, port, user, pswd) for secretWithN in open(secrets): print b.remove_folder(secretWithN.strip())
#!/usr/bin/env python from btsync import BTSync import sys secret = sys.argv[1] b = BTSync() print b.register_secret(secret)
def __init__(self, host='localhost', port='14888', user='******', pswd='password', prefix='/BTSync'): self.prefix=prefix BTSync.__init__(self,host,port,user,pswd)
#!/usr/bin/env python import sys from btsync import BTSync secret = sys.argv[1] b = BTSync() print b.get_encryption(secret)
#!/usr/bin/env python from btsync import BTSync b = BTSync() print 'listen : {0}:{1}'.format(b.host,b.port) print b.get_os() print b.get_version() print b.get_speed()
#!/usr/bin/env python from btsync import BTSync import sys secrets_file = sys.argv[1] b = BTSync() for secretWithN in open(secrets_file,'r'): print b.register_secret(secretWithN.strip())
#!/usr/bin/env python from btsync import BTSync b = BTSync() for folder in b.get_folders(): print folder['secret']
#!/usr/bin/env python import sys import os import time from btsync import BTSync DB_PREFIX = '/Users/ywr/BTSync/db/ywr/' RESCAN_INTERVAL = 5 if not os.path.exists(DB_PREFIX): sys.exit("Not Found: " + DB_PREFIX) b = BTSync() while True: print 'sleep for', RESCAN_INTERVAL, 'seconds...' time.sleep(RESCAN_INTERVAL) secrets = os.listdir(DB_PREFIX) if secrets == []: print 'secrets is empty, continue' continue for secret in secrets: if b.validate_secret(secret): print 'valid secret:', secret print 'try to register', secret msg = b.register_secret(secret) print msg if msg['error'] in {0, 200}: try: os.rmdir(DB_PREFIX + secret)
#!/usr/bin/env python import sys import os import time from btsync import BTSync DB_PREFIX='/Users/ywr/BTSync/db/ywr/' RESCAN_INTERVAL=5 if not os.path.exists(DB_PREFIX): sys.exit("Not Found: " + DB_PREFIX) b = BTSync() while True: print 'sleep for', RESCAN_INTERVAL, 'seconds...' time.sleep(RESCAN_INTERVAL) secrets = os.listdir(DB_PREFIX) if secrets == []: print 'secrets is empty, continue' continue for secret in secrets: if b.validate_secret(secret): print 'valid secret:', secret print 'try to register', secret msg = b.register_secret(secret) print msg if msg['error'] in {0,200}: try: os.rmdir(DB_PREFIX+secret)
#!/usr/bin/env python from btsync import BTSync import sys secrets_file = sys.argv[1] b = BTSync() for secretWithN in open(secrets_file, 'r'): print b.register_secret(secretWithN.strip())