NebulousLabs / python-skynet

Library for integrating Skynet with Python applications
MIT License
19 stars 11 forks source link

siasky.net compatibility #10

Closed DaWe35 closed 4 years ago

DaWe35 commented 4 years ago

The SDK works with the most of portals, except siasky.net:

opts = type('obj', (object,), {
    'portal_url': 'https://siasky.net',
    'portal_upload_path': 'skynet/skyfile',
    'portal_file_fieldname': 'file',
    'portal_directory_file_fieldname': 'files[]',
    'custom_filename': ''
})
skylink = Skynet.upload_file(saveTo, opts)

Traceback (most recent call last):
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Wamp.NET\sites\archive\Skylive\uploader.py", line 46, in share
    skylink = Skynet.upload_file(saveTo, opts)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\siaskynet\skynet.py", line 37, in upload_file
    return Skynet.uri_skynet_prefix() + Skynet.upload_file_request(path, opts).json()["skylink"]
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
DaWe35 commented 4 years ago

It was a shout outage, now it's working again.

marcinja commented 4 years ago

Thanks for reporting. This was caused by an outage like you said, but I'll leave the issue open. The SDK should probably return an error or indicate there was no result in this case

The issue is at this line I believe: https://github.com/NebulousLabs/python-skynet/blob/f58ff474fee7d377fcf87f4be8bd68f485606f47/siaskynet/skynet.py#L37