You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my script I use argparse to accept a '--file' parameter where I can specify a single or multiple files to upload to pcloud:
clp.add_argument('-f', '--file', type=argparse.FileType('r'), nargs='+',
help='List of local FILEs to upload')
clargs = clp.parse_args()
by running it like so:
./pcloud-upload.py -f ./README.md ./LICENSE
and when this happens, my script passes clargs.file (a python list) to uploadfile in pycloud but throws following exception(s):
Traceback (most recent call last):
File "/home/alarm/dev/pcloud-upload/./pcloud-upload.py", line 227, in <module>
fileinfo = pc.uploadfile(files=[pc_uploadlist], path='/') # folderid=folderid) # path=upload_dir)
File "/home/alarm/.local/lib/python3.10/site-packages/pcloud/validate.py", line 19, in wrapper
return func(*args, **kwargs)
File "/home/alarm/.local/lib/python3.10/site-packages/pcloud/api.py", line 265, in uploadfile
files = [
File "/home/alarm/.local/lib/python3.10/site-packages/pcloud/api.py", line 266, in <listcomp>
("file", (os.path.split(f)[1], open(f, "rb"))) for f in upload_files
File "/usr/lib/python3.10/posixpath.py", line 103, in split
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not list
I thought it might have been the argparse.FileType('r') was the problem with an improper cast to a list, which is what I believe pycloud will accept for more than one file. But when I removed argparse.FileType('r') from the argparse part of the script, I got the same exception(s). To remove the issue with perhaps argparse being the problem, I hardcoded a list to be sent to pc.uploadfile like so:
In my script, before I used argparse, I was just passing my --file command line option using a variable and pcloud would upload it properly. So I feel that the api's uploadfile function is not accepting a list and processing that list properly.
Testing some more - I only pass a single file to argparse like so ./pcloud-upload.py -f ./README.md and changing my script line above from:
In my script I use argparse to accept a '--file' parameter where I can specify a single or multiple files to upload to pcloud:
by running it like so:
and when this happens, my script passes clargs.file (a python list) to
uploadfile
in pycloud but throws following exception(s):I thought it might have been the
argparse.FileType('r')
was the problem with an improper cast to a list, which is what I believe pycloud will accept for more than one file. But when I removedargparse.FileType('r')
from the argparse part of the script, I got the same exception(s). To remove the issue with perhaps argparse being the problem, I hardcoded a list to be sent topc.uploadfile
like so:and I get the exact same set of exceptions as above.
In your
uploadfile
function https://github.com/tomgross/pycloud/blob/master/src/pcloud/api.py#L251 you go through your kwargsfiles
and pop off each item in the list but I'm not sure if this is working properly for accepting a list foruploadfile
.In my script, before I used argparse, I was just passing my --file command line option using a variable and pcloud would upload it properly. So I feel that the api's
uploadfile
function is not accepting a list and processing that list properly.Testing some more - I only pass a single file to argparse like so
./pcloud-upload.py -f ./README.md
and changing my script line above from:to
works properly and uploaded the single file. But I cannot pass two files to my script.
The text was updated successfully, but these errors were encountered: