Using --volname to mount with space in name not possible via Python subprocess

What is the problem you are having with rclone?

I'm trying to write a small python script that assits us in mounting our Buckets as Drives on a couple of windows machines. The script I wrote works like I want it to, but I cannot use any space in the naming of the mount (I'm using --volname). Unfortunately it is not possible to use a different name, since these drives have been named like this a while ago and we have many projects that link to these specific drives.

The command below is what is generated with the python script and then executed via subprocess.

Once I execute this command, I get this error:

Command mount needs 2 arguments maximum: you provided 3 non flag arguments: ["REMOTE:BUCKET_NAME" "DRIVE_LETTER:" "Cloud"]

The code looks like this:

main_command = [
    "REMOTE",
    ":",
    "BUCKET_NAME",
    " ",
    "DRIVE_LETTER",
    ":",
]

ADDITIONAL_ARGS = [
    "-vv",
    "--vfs-cache-mode",
    "full",
    "--vfs-cache-max-age",
    "744h",  # Cache Lifetime
    "--vfs-read-chunk-size",
    "512M",
    "--vfs-fast-fingerprint",
    "--transfers",
    "10",
    "--network-mode",
    "--use-server-modtime",
    "--fast-list",
    "--dir-cache-time",
    "5s",
    "--volname",
    "L-Library Cloud",
    "--file-perms=0777",
    "--dir-perms=0777",
    "--use-json-log",
    "--stats",
    "1s",
    "--retries",
    "10",
]

Command = "rclone mount " + "".join(main_command) + " " + " ".join(ADDITIONAL_ARGS)
print(Command)

try:

    p = subprocess.Popen(
        args=Command,
        startupinfo=None,
        stdout=sys.stdout,
        stderr=sys.stdout,
        stdin=sys.stdin,
        bufsize=1,
        universal_newlines=True,
    )

except:
    print(Back.RED)
    print("Something went wrong!")
    print(Style.RESET_ALL)

The code works fine and without any issues if I change the --volname to something without space, for example:

"--volname",
"L-LibraryCloud",

It seems like rclone assumes that the word "Cloud" in Library Cloud is it's own command.

How can I fix this? As I said, I cannot rename this drive.

Thank you very much in advance.

Run the command 'rclone version' and share the full output of the command.

rclone v1.62.2

  • os/version: Microsoft Windows 10 Pro 22H2 (64 bit)
  • os/kernel: 10.0.19045.4046 Build 19045.4046.4046 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

Amazon S3 compliant Cloud Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount REMOTE:BUCKET_NAME L: --vfs-cache-mode full --vfs-cache-max-age 744h --vfs-read-chunk-size 512M --vfs-fast-fingerprint --transfers 10 --network-mode --use-server-modtime --fast-list --dir-cache-time 5s --volname L-Library Cloud --file-perms=0777 --dir-perms=0777 --use-json-log --stats 1s --retries 10

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

config is irrelevant here

A log from the command that you were trying to run with the -vv flag

log is not relevant here

You have to pass quotes here:

--volname "L-Library Cloud"

In Python If you want to use double quotes you can just use single quotes as delimiter:

r'"test test"'
1 Like

And BTW this has nothing really to do with rclone:) You should seek help on Python forums.

1 Like

Haha yes, you're right.
After fighting with this for hours of COURSE I fixed it myself 5mins after posting here.

Thank you nontheless, it works perfectly now!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.