'file upload from container using webdav results into empty file upload

I'm attempting to wrap my brain around this because the identical code generates two different sets of outcomes, implying that there must be a fundamental difference between the settings in which the code is performed.

This is the code I use:

from webdav3.client import Client

if __name__ == "__main__":
    client = Client(
        {
            "webdav_hostname": "http://some_address"
            + "project"
            + "/",
            "webdav_login": "somelogin",
            "webdav_password": "somepass",
        }
    )

    ci = "someci"
    version = "someversion"

    directory = f'release-{ci.replace("/", "-")}-{version}'

    client.webdav.disable_check = (
        True  # Need to be disabled as the check can not be performed on the root
    )
    f = "a.rst"
    with open(f, "r") as fh:
        contents = fh.read()
        print(contents)
    evaluated = contents.replace("@PIPELINE_URL@", "DUMMY PIPELINE URL")
    with open(f, "w") as fh:
        fh.write(evaluated)
        print(contents)
    client.upload(local_path=f, remote_path=f)

The file a.rst contains some text like:

Please follow instruction link below
#####################################
`Click here for instructions <https://some_website>`_

When I execute this code from macOS, a file with the same contents of a.rst appears on my website.

When I execute this script from within a container with a base image of Python 3.9 and the webdav dependencies, it creates a file on my website, but the content is always empty. I'm not sure why, but it could have something to do with the fact that I'm running it from within a Docker container that on top of it can't handle the special characters in the file (plain text seems to work though)?

Anyone have any ideas as to why this is happening and how to fix it?

EDIT: It seems that the character ":" is creating the problem..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source