havardgulldahl / jottalib

A library to access files stored at jottacloud.com.
GNU General Public License v3.0
83 stars 19 forks source link

requests has tightened up their api, tripping jotta-scanner when uploading #122

Closed eiaro closed 8 years ago

eiaro commented 8 years ago
jotta@kallax:~$ jotta-scanner -l info /data/temporary /Ronny
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): www.jottacloud.com
INFO:root:args: topdir u'/data/temporary', jottapath u'/Ronny'
Entering dir: /data/temporary
Ouch. Something's wrong with "/data/temporary/_40x20.gcode":1 - 00:00:00
ERROR:jottalib.scanner:SAFERUN: Got exception when processing ('/data/temporary/_40x20.gcode', u'/Ronny/temporary/_40x20.gcode', <jottalib.JFS.JFS object at 0x7fc077682790>)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/jottalib/scanner.py", line 62, in saferun
    return apply(cmd, args)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/jottacloud.py", line 197, in new
    _new = JFS.up(jottapath, lf)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 1148, in up
    return self.post(url, None, files=files, params=params, extra_headers=headers, upload_callback=upload_callback)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 1077, in post
    r = self.session.post(url, data=m, params=params, headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 461, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 394, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 295, in prepare
    self.prepare_headers(headers)
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 409, in prepare_headers
    check_header_validity(header)
  File "/usr/local/lib/python2.7/dist-packages/requests/utils.py", line 800, in check_header_validity
    "not %s" % (value, type(value)))
InvalidHeader: Header value 152919 must be of type str or bytes, not <type 'int'>
uploading 1 new files: [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 1/1 - 00:00:00
Network upload speed 0B/sec
Entering dir: /data/temporary/test
Finished syncing 0 files, with 1 errors (read ./jottacloudclient.log for details)

jottacloudclient.txt

root@kallax:/data/temporary# python -m pip list
argh (0.26.2)
args (0.1.0)
certifi (2016.8.8)
cffi (1.7.0)
chardet (2.3.0)
clint (0.5.1)
defusedxml (0.4.1)
dnspython (1.12.0)
docutils (0.12)
humanize (0.5.1)
jottalib (0.5.0)
lxml (3.6.4)
pathtools (0.1.2)
Pillow (2.6.1)
pip (8.1.2)
pycparser (2.14)
pycrypto (2.6.1)
Pygments (2.0.1)
python-apt (0.9.3.12)
python-dateutil (2.5.3)
python-debian (0.1.27)
python-debianbts (1.11)
reportbug (6.6.3)
requests (2.11.1)
requests-toolbelt (0.7.0)
roman (2.0.0)
setuptools (25.4.0)
six (1.10.0)
SOAPpy (0.12.22)
watchdog (0.8.3)
wstools (0.4.3)
xattr (0.8.0)

Jeg har dessverre ikke tid til å sette meg inn i hva som er galt. Håper jeg har gitt nok info til at noen klarer finne ut hva som er galt. :)

havardgulldahl commented 8 years ago

Hey, @eiaro, thanks for the report ! I'll look into it right away

havardgulldahl commented 8 years ago

Got it. requests changed underneath our feet: https://github.com/kennethreitz/requests/issues/3477

I'll update our code and cut a new 0.5.1 release asap

havardgulldahl commented 8 years ago

@eiaro and @everyone, as a workaround, try to downgrade/pin requests to the 2.10 branch.

havardgulldahl commented 8 years ago

... like

pip install requests==2.10.0
ilyvion commented 8 years ago

Not that I've looked into this very thoroughly, but it seems to me like changing line 1147 in JFS.py from

'JSize': contentlen,

to

'JSize': str(contentlen),

should fix this issue.

havardgulldahl commented 8 years ago

@alexschrod yes, you're quite right. thanks!