Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
#!/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
Ejemplo n.º 3
0
#!/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()
Ejemplo n.º 4
0
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())

Ejemplo n.º 5
0
#!/usr/bin/env python
from btsync import BTSync
import sys

secret = sys.argv[1]
b = BTSync()

print b.register_secret(secret)
Ejemplo n.º 6
0
 def __init__(self, host='localhost', 
              port='14888', user='******', 
              pswd='password', prefix='/BTSync'):
     self.prefix=prefix
     BTSync.__init__(self,host,port,user,pswd)
Ejemplo n.º 7
0
#!/usr/bin/env python
import sys
from btsync import BTSync

secret = sys.argv[1]
b = BTSync()

print b.get_encryption(secret)
Ejemplo n.º 8
0
#!/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()
Ejemplo n.º 9
0
#!/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())
Ejemplo n.º 10
0
#!/usr/bin/env python
from btsync import BTSync

b = BTSync()

for folder in b.get_folders():
  print folder['secret']
Ejemplo n.º 11
0
#!/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)
Ejemplo n.º 12
0
#!/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)
Ejemplo n.º 13
0
#!/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())