I need to pass options to rsync. I do that with
EXCLUDE = [".svn",".dropbox"]
OPTS = "-rltgoi --delay-updates --delete --exclude={:} --chmod=a-w".format(EXCLUDE)
this code prints
-rltgoi --delay-updates --delete --exclude=['.svn', '.dropbox'] --chmod=a-w
[]
can't be processed by the shell
I need to pass
-rltgoi --delay-updates --delete --exclude=.svn,.dropbox --chmod=a-w
You need to join EXCLUDE
into a comma-separated string:
EXCLUDE = ','.join(EXCLUDE)
You are instead interpolating the list representation, which is not what you want here (note that a list representation includes quoted string values as well).
在将排除项添加到命令之前,应将其加入字符串中。
OPTS = "-rltgoi --delay-updates --delete --exclude={0} --chmod=a-w".format(",".join(EXCLUDE))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.