Answer the question
In order to leave comments, you need to log in
Python, rsync and subprocess.call - what's the problem?
Hello.
There is a python script, at some point rsync is called with parameters via subprocess.call. Simplified script. The function first generates an exclude_list string and returns it, rsync should accept it as a startup parameter.
print(exclude_list())
>> --exclude=var --exclude=opt --exclude=home
subprocess.call(['rsync', '-aAX', '/', '/mnt/', exclude_list()])
print(exclude_list())
>> --exclude=var
Answer the question
In order to leave comments, you need to log in
subprocess.call expects a list of arguments, one argument per list element.
If your exlude_list is a string, then it must be divided into parts and added to the list of arguments before passing it to subprocess.call, something like this:
subprocess.call(['rsync', '-aAX', '/', '/mnt/'] + exclude_list().split())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question