Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-ASCII usernames character will cause the module's plot to not work #1196

Open
shun2wang opened this issue Apr 27, 2022 · 13 comments
Open

Comments

@shun2wang
Copy link
Contributor

shun2wang commented Apr 27, 2022

  • OS: windows 10 21H2
  • locale: Chinese
  • version: 2.3.6

Hi @jonathon-love

I got a lot of help request after we released 2.3.6 (but not when testing the individual patch),This issue is related to the inference of #1009 In the non-ASCII username path, jamovi cannot correctly parse the path, so the drawing in the module will not work properly, and the process of saving the analysis file .omv will prompt 'Save failed , path not found'.

Maybe with the update of R4.2 (is available now), we will be able to completely get rid of these annoying encoding characters on Windows, but now it is really a problem.

In the following example, the user name is three characters of Chinese characters '杨**' instead of the five garbled characters in the picture
image

thank you
shun

@jonathon-love
Copy link
Member

thanks sw

this one i am quite puzzled by ... the code involved is entirely python, and i've never had a path encoding problem in python before ... 🤔

@jonathon-love
Copy link
Member

could you see if it's possible to save a file without any images in it? ... if it isn't, i'd be interested to see the error message there too.

with thanks

@shun2wang
Copy link
Contributor Author

shun2wang commented Apr 28, 2022

could you see if it's possible to save a file without any images in it? ... if it isn't, i'd be interested to see the error message there too.

no, they cannot sav any .omv files, it says:'system can not find the file specified'.
I provided them with a temporary solution, which is to add an account with English letters locally and use jamovi under this account, and this problem disappears.

I have a basic understanding of python and a Chinese system environment. Maybe you can direct me to some reproducible experiments in python on windows and let me see what I can help.

thank you jonathon

@jonathon-love
Copy link
Member

that would be awesome.

let me walk you through my reasoning on this, as you may pick up on something that i've missed.

the errors in the screenshot above are when requesting the images on line 108 here:

            resource_path = instance.get_path_to_resource(resource_id)
            with open(resource_path, 'rb') as file:
                self.set_header('Cache-Control', 'private, no-cache, must-revalidate, max-age=0')
                content = file.read()
                self.write(content)

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/server.py#L107-L111

so resource_path is bad, we're thinking something has gone wrong when the paths have been created. so working backwards, we want to look at instance.get_path_to_resource(resource_id) which is:

def get_path_to_resource(self, resourceId):
    return posixpath.join(self._instance_path, resourceId)

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/instance.py#L254-L255

this combines the instance path:

C:\Users\${ username }\AppData\Local\Temp\${a_generated_temp_name}\${session_id}\${instance_id}

with the resource path

${analysis_id_and_name}/resources/${ imageName }

(and we see that in the screenshot above). so the problem with the username seems to be coming from the instance_path.

working backwards, the instance path is set when the Instance object is constructed:

class Instance:

    def __init__(self, session, instance_path, instance_id, settings):

        self._session = session
        self._instance_path = instance_path

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/instance.py#L69-L74

which is constructed from the session path:

        instance_path = os.path.join(self._session_path, instance_id)
        settings = await self.get_settings()
        instance = Instance(self, instance_path, instance_id, settings)

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/session.py#L156-L158

which is constructed from the data path:

class Session(dict):

    def __init__(self, data_path, id):
        self._path = data_path
        self._id = id
        self._session_path = os.path.join(data_path, id)

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/session.py#L52-L57

which here is called the spool path:

self._session = Session(self._spool_path, self._session_id)

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/server.py#L620

which is populated using the python TemporaryFile:

        self._spool_path = conf.get('spool_path')
        if self._spool_path is None:
            self._spool = TemporaryDirectory()
            self._spool_path = self._spool.

https://github.com/jamovi/jamovi/blob/current-dev/server/jamovi/server/server.py#L507-L510

so this is really weird, because this is all sensible python code, and there aren't many pitfalls in python code.

one riddle here is that jamovi relies on creating and attaching to a shared memory segment for the data set, and this lives in the instance path, so it's weird that things based on the instance path work for some things, but not others.

one thing to be wary of, is that the corrupt user name in the terminal ... it may be correct, and may be being corrupted when the terminal displays it (and the error may be somewhere else). i've fallen for that in the past.

with thanks

@jonathon-love
Copy link
Member

but simply running the python code:

from tempfile import TemporaryDirectory

dir = TemporaryDirectory()
print(dir.name)

on a windows machine with a problematic username, should tell us a fair bit.

@shun2wang
Copy link
Contributor Author

Sorry for the late, I'm on vacation, but I now have time to look at this with you now.

one thing to be wary of, is that the corrupt user name in the terminal ... it may be correct, and may be being corrupted when the terminal displays it (and the error may be somewhere else). i've fallen for that in the past.

yes i have tried the TemporaryDirectory, python may be correct.

I suggest that I set up an environment like this, and then you remotely control the computer (perhaps using anydesk, and run some tests on it yourself.If you agree, I will give you a code to connect to this computer later by email

@jonathon-love
Copy link
Member

that would be great ... i've used teamviewer in the past ... but i expect anydesk will work too. ... you have access to a computer which has this problem?

@shun2wang
Copy link
Contributor Author

I'ii set a same environment to repreduce it for you on my computer.

@jonathon-love
Copy link
Member

perfect. thanks. ... i gather it's only certain user names which are a problem.

@shun2wang
Copy link
Contributor Author

i have send a code to you. waiting for you.

@sivanMargalit
Copy link

I have the same issue with non ascii character path.
Did you find a solution to this problem ?

@jonathon-love
Copy link
Member

jonathon-love commented Oct 27, 2022

it's a bug in electron

electron/electron#33997

@jonathon-love
Copy link
Member

although you won't have a problem if you use the cloud version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants