oracc / nammu

Oracc GUI
GNU General Public License v3.0
12 stars 10 forks source link

Unable to open Nammu #299

Closed dreilaendereck closed 6 years ago

dreilaendereck commented 7 years ago

image

Thank you for your help.

raquelalegre commented 7 years ago

Thanks for the report @dreilaendereck and sorry Nammu is not working for you at the moment.

There seems to be a problem with the code trying to access the contents of the jar file. I have tested this some time ago in Windows 7, but not Windows 10. It might be the path to the jar automatically built in the code is wrong.

This is the part of the code the problem is coming from in nammu/utils/__init__.py:

def copy_yaml_to_home(jar_file_path, source_rel_path, target_path):
    '''
    Opens Nammu's jar as a zip file, looks for the yaml config file and copies
    it to ~/.nammu.
    '''
    try:
        zf = zipfile.ZipFile(jar_file_path, 'r')
    except zipfile.BadZipfile:
        shutil.copyfileobj(file(source_rel_path, "wb"),
                           file(target_path, "wb"))
    else:
        lst = zf.infolist()
        for zi in lst:
            fn = zi.filename
            if fn.lower() == source_rel_path:
                source_file = zf.open(fn)
                target_file = file(target_path, "wb")
                with source_file, target_file:
                    shutil.copyfileobj(source_file, target_file)
    finally:
        zf.close()

My guess is there might have been an exception when trying to do zf = zipfile.ZipFile(jar_file_path, 'r') and the finally part which is always executed (with or without the exception happening) is trying to close zf even though it doesn't exist.

We'll test it in Windows 10 next week to see if the problem is related to that, and add some logging functionality to this part of the code, to be able to see the contents of the jar_file_path variable.

ageorgou commented 7 years ago

I cannot replicate this on Windows 7, but will also test it on Windows 10. I think we can avoid the problem by rewriting those lines, but we need to check that the path to the zip file is correct anyway.

ageorgou commented 7 years ago

Managed to reproduce this under these conditions:

In this case, the path_to_jar in get_yaml_config will be "D:/my" instead of the full folder name, and the jar will not be accessible. I am a bit surprised that this doesn't cause an error when the exception is caught (line 318-319) - it seems that the "plan B" file copying fails silently.

(The directory name will still cause a problem even if there is a previous version, but with a different error)

Edit: Spaces and other special characters in the path will also cause problems, because the URL created by the Resource Manager will encode them (e.g. "this path" will become "this%20path"), which means that trying to read from that file will change. We can use urllib.unquote to decode them.

Plan for fixing (if this is indeed the problem):

ageorgou commented 7 years ago

Hi @dreilaendereck,

We may have an idea of why the problem occurs but would appreciate some more information to confirm. Could you please give us the full path to the folder where the Nammu jar file is located?

Thanks in advance!

dreilaendereck commented 7 years ago

Hello,

Thank you for trying to fix this problem for me. The complete path is C:\Users\Brandon Post\Desktop\Lindsey Grad School\UofT\BATCUL. I have the same issue, however, when I leave Nammu in the download folder.

Thanks!


From: ageorgou notifications@github.com Sent: 02 November 2017 15:55:58 To: oracc/nammu Cc: Lindsey Post; Mention Subject: Re: [oracc/nammu] Unable to open Nammu (#299)

Hi @dreilaendereckhttps://github.com/dreilaendereck,

We may have an idea of why the problem occurs but would appreciate some more information to confirm. Could you please give us the full path to the folder where the Nammu jar file is located?

Thanks in advance!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/oracc/nammu/issues/299#issuecomment-341539364, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Afn0g5I_IlTOyAR6ss14HWKBqphTS1lnks5syh5OgaJpZM4QJPxJ.

ageorgou commented 6 years ago

Hi @dreilaendereck,

Thanks for the information. I'm fairly confident that the error is because of the spaces in the path. Sorry about that! It's not very complicated to change, and I'm working on a fix.

raquelalegre commented 6 years ago

@ageorgou since fixing the problem and be able to compile the jar is going to take a while, can you prepare a jar for @dreilaendereck with the fixed version, just so he can test it? Then we'll work on the maven problem on a separate issue.

Update: See #302 .

ageorgou commented 6 years ago

Hi @dreilaendereck,

Sorry for the delay. We have created a temporary release that fixes your issue while we work on an official update. You can download it from this link. Please let us know how you get on!

dreilaendereck commented 6 years ago

Hi @ageorgou,

It worked! Thanks so much for your work on this issue!