labrad / scalabrad

scala interface for labrad
MIT License
8 stars 6 forks source link

LabRAD manager fails to start when pointed to the old registry (and a funny workaround) #97

Open xiaoyuejin opened 7 years ago

xiaoyuejin commented 7 years ago

I am a user of the old Delphi LabRAD manager for years. Now I am trying to upgrade to the new scalabrad manager, but backward compatibility is of my highest priority. For newer users who never touched the Delphi version, these issues might not be interesting…

Since I have multiple problems, I will split them to different issues.

Test platform: Windows 7 x64, Java 8 up to date, Python 2.7, pylabrad up to date, without footprint of previous versions of LabRAD.

I need LabRAD to start its manager and point the registry to the directory where I store the old registry files. In the help, I read:

--registry uri URI giving the registry storage location. Use labrad://[pw>@]<host[:][?tls=] to connect to a running manager, or file://[?format=] to load data from a local file...

So I tried this, and got an error: C:\scalabrad-0.8.3\bin>labrad --registry file://c:/labrad/registry?format=delphi

Exception in thread "main" java.lang.IllegalArgumentException: URI has an authority component at java.io.File.(Unknown Source) at org.labrad.manager.Manager$.main(Manager.scala:185) at org.labrad.manager.Manager.main(Manager.scala)

I got stuck here for several hours. I was trying different options, like path with quotation marks, ?format after a space, delphi with quotation marks, etc. (It would be great if the --help can contain an example sometimes.) Nothing worked. Until I accidentally entered a command with a typo in it:

C:\scalabrad-0.8.3\bin>labrad --registry file://;c:/labrad/registry?format=delphi

To my greatest surprise, the manager started working for the first time and went to read my old registry files!! I can't believe my eyes:

C:\scalabrad-0.8.3\bin>labrad --registry file://;c:/labrad/registry?format=delphi 23:55:23.658 [main] INFO org.labrad.manager.Manager$ - registry location: c:\labrad\registry, format=delphi ......

And then I went on to test why the typo will help start the manager. It turned out that there must be a "placeholder" character before the real path, no matter what that placeholder is, as long as it doesn't trigger other syntax errors. I can replace ";" (the typo) with other characters and start the manager all the same. So far I have tested and found these commands that work equally well:

C:\scalabrad-0.8.3\bin>labrad --registry file:///c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://;c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://:c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://.c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://,c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://+c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://-c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://*c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://(c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://)c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://=c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://_c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://$c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://!c:/labrad/registry?format=delphi C:\scalabrad-0.8.3\bin>labrad --registry file://~c:/labrad/registry?format=delphi

And this list is very likely not complete. I know, I know... But the poor guy should be allowed to have some fun after he was stuck here for many hours and was trying desperately everything until a typo saved the world, right? :)

maffoo commented 7 years ago

Interesting that so many variants work. The usual way to embed a windows file path with drive letter into a url is to add a leading slash, which means you have a triple slash after the file: scheme part of the URL:

file:///c:/labrad/registry?format=delphi

That's what we have always done so I never noticed that the java url parser would accept a path with other leading characters.

thetorque commented 6 years ago

I have a stupid question. How do I set the password for LabRad manager? The old Delphi manager you can set it in the init file.

xiaoyuejin commented 6 years ago

You may add them manually in Environment Variables.

I don't know of any automatic method that can be used to configure the new pylabrad (it is not a manager problem). But here is a list of things you can/must do:

https://github.com/labrad/pylabrad/blob/b9067425ce1bddf9efa08638e89b0395e52fc52b/CONFIG.md

Alternatively, you can also use the init file to set up the new system. Just need to modify/ignore a few lines.