Search code examples
pythonrclone

Rclone Python error when computing Hashes: ValueError


I am using Rclone_python (https://pypi.org/project/rclone-python/) to create some basic backup scripts for my server.

On one of my scripts, with rclone set up and properly configured on both client and server, there were issues with only the server running this. rclone configurations are both valid, and the same, using the same access keys and everything. rclone works on the server with the configuration, just isn't working in python.

The error I am receiving is:

Traceback (most recent call last):
  File "/root/rclone-backup-filechecker-python/main.py", line 145, in <module>
    main()
  File "/root/rclone-backup-filechecker-python/main.py", line 43, in main
    dict_of_remote = get_hashes_from_files_remote(remote_path)
  File "/root/rclone-backup-filechecker-python/main.py", line 53, in get_hashes_from_files_remote
    result = rclone.hash(HashTypes.md5, remote_path)
  File "/usr/local/lib/python3.10/dist-packages/rclone_python/rclone.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/rclone_python/rclone.py", line 507, in hash
    value, key = l.split()
ValueError: too many values to unpack (expected 2)

My code is on: https://gitlab.atfdev.co.uk/alicethefemme/rclone-backup-filechecker-python if it helps to identify an error.

Upon further inspection, the rlcone.py file from the package is having the error.

value, key = l.split() This was working prior to this, and upon tracking the variable that it wants to split, the errors aren't always consistent, with some files on my remote raising errors only occasionally. Any idea why this could be?


Solution

  • Figured out the issue with the package being used. It was doing a split, which didn't take into account some directories using spaces in their names. Adding a maxsplit=1 into the code ensures that it is just the hash and the filename returned from this code. Will make a PR on GitHub for it. Thanks for the help!!