blakev / python-syncthing

Python bindings to the Syncthing REST interface.
MIT License
75 stars 24 forks source link

Scan Folder #6

Closed senden9 closed 7 years ago

senden9 commented 8 years ago

Hi, first thanks for this library. But scan a folder throw a exeption. The folder i want scan exist:

In [58]: sync.stats.folder()
Out[58]: 
{'UniShare': {'lastFile': {'at': '2016-02-17T14:28:06.901964811+01:00', …

Here is the exeption:

In [59]: sync.db.set.scan(folder="UniShare")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-59-1b1d8f30fc87> in <module>()
----> 1 sync.db.set.scan(folder="UniShare")

/tmp/venv/lib/python3.5/site-packages/syncthing/__init__.py in __call__(self, data_obj, **params)
     74 
     75         return C.iface.do_req(self.command.verb, self.command.endpoint, \
---> 76                                 data_obj, **params)
     77 
     78     def __str__(self):

/tmp/venv/lib/python3.5/site-packages/syncthing/__init__.py in do_req(self, verb, endpoint, data, **params)
    203     def do_req(self, verb, endpoint, data=None, **params):
    204         url = uparse.urljoin(self.host, endpoint)
--> 205         return self.__req(verb, url, data, params)
    206 
    207     def __req(self, verb, url, data=None, params=None):

/tmp/venv/lib/python3.5/site-packages/syncthing/__init__.py in __req(self, verb, url, data, params)
    254             else:
    255                 c = resp.content
--> 256                 if c.startswith('{') and c.endswith('}'):
    257                     return json.loads(c)
    258                 return c

TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Whatever, the folder get scanned.