MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
274 stars 70 forks source link

Server does not start when language set to Chinese #72

Closed qigesmn closed 2 years ago

qigesmn commented 2 years ago

Thanks for sharing this practical package. On line 133 of 'server.py', the code: match = regex(r'(?i)^Comsol.+?server.+?(\d+)$', line.strip()) it may cause loop while setting Chinese as the as the programming language in comsol.

john-hen commented 2 years ago

Hi, thanks for reporting this. You probably mean line 113. I will need your help with this. Apparently the console output of comsolmphserver is language-dependent (which complicates things). That regular expression filters out the port number, and there's no other way to query it, so we will have to make the regex more flexible.

What's the output you get when you start comsolmphserver on the command line? For example, with Comsol 5.6 installed on Windows and language set to English:

C:\temp> "C:\Program Files\COMSOL\COMSOL56\Multiphysics\bin\win64\comsolmphserver"
COMSOL Multiphysics server 5.6 (Build: 401) started listening on port 2036
Use the console command 'close' to exit the program
close

If you're on Linux or macOS, the command would be comsol mphserver.

qigesmn commented 2 years ago

Hi, thanks for replying. I do mean line 113, oops :-) The environment is Ubuntu 18.04 with Chinese and Comsol 5.6 MultiPhysics with Chinese. The console output of comsolmphserver do have Chinese characters, I will report the details later. I have run it successfully under original English settings.Obviously, the regular expression does filter some particular cases, I will test an alternative regular expression and report it later.

qigesmn commented 2 years ago

The output when starting comsolmphserver is: COMSOL Multiphysics server 5.6 (开发版本: 341) 开始在端口 2037 上监听 Obvious the sentence does not end with a port number. I think the regular expression r'(?i)^Comsol.+?server.+?(\d+)$' should be refined to deal with more situations, or directly declare that the environment should be limited to the original language settings. At last, thanks again for sharing this wonderful package!

john-hen commented 2 years ago

thanks again for sharing this wonderful package!

Always happy to hear. 😄 Thanks.

should be refined to deal with more situations, or directly declare that the environment should be limited to the original language settings.

We definitely want to support all languages. It's just a little difficult to test, as I would have to go through the installer many times, and in languages I cannot even read.

I've now added tests for Chinese, the default English, as well as German (previously reported in issue #24). In case the latest iteration of that regular expression doesn't work for some other language, people can open another issue and we'll fix that and add that language to the tests.

I did see, just now, that there's also a way of having the server write the port out to a file. That would probably be the cleanest solution, but takes a little more work. I might implement that some other time.

john-hen commented 2 years ago

Fixed in MPh 1.1.5, released today.