bensteUEM / ChurchToolsAPI

Collection of Python files to use the API for ChurchTools
6 stars 4 forks source link

Umlauts in file_upload() #81

Closed jannesjust closed 7 months ago

jannesjust commented 1 year ago

If there are umlauts in the file name, I get the answer 200 back, but the file is not uploaded.

bensteUEM commented 1 year ago

@fschrempf do I remember correctly that this was your part of the code? Do you have time to look into this bug report?

fschrempf commented 1 year ago

@fschrempf do I remember correctly that this was your part of the code? Do you have time to look into this bug report?

No, I never used or touched file_upload() so far.

bensteUEM commented 1 year ago

@jannesjust - i could not reproduce your described behavior.

Not only do we already have songs like "Macht hoch die Tür" on our system, i did also add a test case which specifically checks a test file with Umlaut.

Are you sure you're using the song_arrangement_id and not the song_id to upload you attachment? I've updated a docstring to strongly point out this difference ... https://github.com/bensteUEM/ChurchToolsAPI/commit/53c0de025219be4f019f789b0ab2880ac0420d53#diff-026cdb0bee0effb8f5d2b4e8d06983b2fbab48b868670644ea2d0e12ce8c153cR28

If this wasn't the cause i'd need more information.

jannesjust commented 1 year ago

Thanks for your quick testing and reply.

That's my code:

def initial_file_upload(api, category):

    cwd = os.getcwd()
    os.chdir(cwd +"/Lieder/3.Chor")

    songs = api.get_songs()

    for song in songs:
        if song['category']['id'] == category:

            name = f'{song["name"]}.pdf'
            arrangement = song['arrangements'][0]['id']

            if api.file_upload(name, 'song_arrangement', arrangement, overwrite = True) == True:
                logging.info(name + " hochgeladen")
            else:
                logging.info(name + " fehlgeschlagen")
            time.sleep(1)
bensteUEM commented 1 year ago

I'd rather suspect the use of you . might be a problem. I'll have to look into the code again though...

If that's not the issue

bensteUEM commented 1 year ago

One more idea ... my test runs with overwrite = False as default. Can you try to upload without overwrite and let me know if the issue persists?

jannesjust commented 1 year ago

When I upload the file via the webbroser in ChurchTools by hand, it works and the Umlaut is showing correctly

jannesjust commented 7 months ago

After some testing on other machines and updating everything, I found the issue. Previously I used Python version 3.7.4 which did not work. After updating to 3.12.0 it finally works. Thanks for your support.

bensteUEM commented 7 months ago

Thanks for the update. Would you mind trying again with Python 3.8 as specified in the requirements?

[tool.poetry.dependencies]
python = "^3.8"

If it does work with 3.8 i'd keep everything as is, but if you require 3.9, 3.10 or newer I'd have to update the requirements :) It looks like my venv is currently using 3.11 ...

jannesjust commented 7 months ago

Yes, it also works with 3.8