seafile icon indicating copy to clipboard operation
seafile copied to clipboard

seaf-cli: allow more flexible input

Open nick-youngblut opened this issue 3 years ago • 1 comments

I'm using the the seafile CLI, and the input requirements are very particular, which can be challenging for new users. For instance, the following didn't work:

seaf-cli download -l 8887ae4e0-50b7-4832-b98e-4ec8aus0ab1a -s https://keeper.mpdl.mpg.de/ -d test_dl -u my.username

The error:

Traceback (most recent call last):
  File "/usr/bin/seaf-cli", line 845, in <module>
    main()
  File "/usr/bin/seaf-cli", line 841, in main
    args.func(args)
  File "/usr/bin/seaf-cli", line 421, in seaf_download
    token = get_token(url, username, password, conf_dir)
  File "/usr/bin/seaf-cli", line 235, in get_token
    token_json = urlopen("%s/api2/auth-token/" % url, data=data)
  File "/usr/bin/seaf-cli", line 208, in urlopen
    resp = urllib2.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

...but the following did:

seaf-cli download -l 8887ae4e0-50b7-4832-b98e-4ec8aus0ab1a -s https://keeper.mpdl.mpg.de -d test_dl -u [email protected]

I couldn't include a / add the end of the url: https://keeper.mpdl.mpg.de, although users will often do this, and even though I should be able to use my user name (my.username in this example), I had to use my full email address.

It would be helpful to add an urllib2.HTTPError exception handling so that any trailing / characters are removed from the url and the request is re-sent, and if the username is not correct, the cli could include an error message stating to try the email address instead of the username.

Also, it appears that one cannot easily get the seaf-cli version via simply seaf-cli --version or seaf-cli version

nick-youngblut avatar Feb 19 '22 14:02 nick-youngblut

Returning not found error when using URL ended with / should be a server configuration issue. It's unnecessary for the client to handle such case.

About using username for login, can you use username to login from the web interface? If so, the cli client should also be able to login with username. This is handled by the server, not the client.

killing avatar Feb 20 '22 10:02 killing