Houston4444 / RaySession

Session manager for linux musical programs
GNU General Public License v2.0
156 stars 18 forks source link

ray_control setproperties #49

Open newlaurent62 opened 4 years ago

newlaurent62 commented 4 years ago

Hello,

following your advice, i'm starting to look into ray_control usage:

I have an argument which i set using the xml file using this syntax (note that there is " AND ' : " and ' ): arguments=""/home/laurent/Ray Sessions/Streaming audio from Jamulus/config-obs-session" 'obs --profile "mp3-Streaming audio from Jamulus" --scene "mp3-Streaming audio from Jamulus" --startrecording'"

Once the XML entities have been replaced: "/home/laurent/Ray Sessions/Streaming audio from Jamulus/config-obs-session" 'obs --profile "mp3-Streaming audio from Jamulus" --scene "mp3-Streaming audio from Jamulus" --startrecording'

I tried to set the "arguments" properties using

ray_control client obs-session setproperties arguments:""/home/laurent/Ray Sessions/Streaming audio from Jamulus/config-obs-session" 'obs --profile "mp3-Streaming audio from Jamulus" --scene "mp3-Streaming audio from Jamulus" --startrecording'"

but the command ray_control client obs-session getproperties does not return the desired value. ' and " are not translated to characters. Is there a way i can do this ?

Houston4444 commented 4 years ago

have you tried entering arguments like you would on the command line? That is the way it is supposed to work

newlaurent62 commented 4 years ago

Yes what i needed to know is how to escape the quote character. The solution is to use \" in place of ". ray_control client obs-session setproperties arguments:" \"/home/laurent/Ray Sessions/Streaming audio from Jamulus/config-obs-session\" 'obs --profile \"mp3-Streaming audio from Jamulus\" --scene \"mp3-Streaming audio from Jamulus\" --startrecording' "

And that works fine.

Houston4444 commented 4 years ago

Yes, but I see you make a big error here. You are using as argument a file in the session path. This will make the nightmare if you duplicates or saves as template this session and then, moves or removes the original session. And it will never works if you copy the session to another computer. Please don't do that ! (I really have to write a documentation to avoid theses kind of wrong usage).

2 possible cases: 1 ) The config file for obs-session doesn't needs to be saved when user saves obs-session (I don't know obs-session, so I do not have the answer), in this case please move the config file to an absolute path fixed (for example, your wizard source code or installed lib).

2 ) The config file for obs-session needs to be saved when user saves obs-session (this is the case for allmost softwares), then you need to use ray-proxy. ray-proxy is done for this. A program run via ray-proxy will have the client directory as PWD, then you can use relative path to your config-file placed in this directory.

inconveniences of ray-proxy in this case are light, client won't keep alive at session switch, and it consumes a very little more memory.

newlaurent62 commented 4 years ago

Yes i know that did not the job as expected. It was an example from my first version.

Some of the apps i’m using do not provide command line args to set the conf file to use. I found that changing XDG_CONFIG_HOME let me use à set of configuration files for each application instances. Which is fine but this variable is not a file. So i thought that the proxy client would not work in my case.

I implemented a wrapper that replace the raysession path in the wrapper args: For example

alt-conf-home —xdg_config_home xxx-RAYSESSION_PATH-xxx/etc/clientID — ‘my command + 
Args’

For now, That works for my use case but i think i will need proxy client because i will need signal handling to save state of my applications.

This solution has one advantage though not yet tested , the raysession document should be portable (at least if software version are compatible).

Houston4444 commented 4 years ago

this variable is not a file. So i thought that the proxy client would not work in my case.

This is not a problem, proxy doesn't check if file exists or not.

I must confess that I haven't completely understood what you want to do, its mechanisms and how it will be presented to the user. I would be happy to have a source code link even if it's not ready yet.

newlaurent62 commented 4 years ago

I will prepare a simple use case scenario and push it here in a zip file.

Do you use an ubuntu based Linux ?

Houston4444 commented 4 years ago

nice !

Do you use an ubuntu based Linux ?

Yes, but I plan to switch to Librazik3 as soon as possible (it's debian based, so it should not be a problem).

newlaurent62 commented 4 years ago

Here is an archive of my young project.

The idea is to create a Ray Session wizard builder. It lets you create a wizard from a simple XML file. Once that you have walk through the wizard steps, it creates a JSON data file. This file is used by Cheetah templates to create a Ray Session ... (Cheetah is a python template engine).

This way, you can create templates for your use cases and create a ray session on the fly.

https://drive.google.com/file/d/1jcCpD265l1u_VVOt8KC7LV5fGIbOnxNa/view?usp=sharing

Houston4444 commented 4 years ago

Thanks a lot, I think I understand the project now ! I achieve to make and have the GUI, but after click on last "finish", I've got this error:

--/tmp/tmphkrp80/etc/default/datamodel.json --/home/houston/.local/share/raysession-templates/mywizard --/tmp/tmphkrp80 --~/"Ray Sessions"/My jack capture session

-- Creating directory structure 
-- Copying templates files 
Traceback (most recent call last):
  File "build/mywizard.py", line 613, in validatePage
    if RaySessionTemplate().fillInTemplate(datamodelfile, templatedir, tmpdir, outdir) == 0:          
  File "/home/houston/.local/share/raysession-templates/mywizard/tmpl_mywizard.py", line 41, in fillInTemplate
    shutil.copytree(templatedir, outdir + os.sep + 'templates', dirs_exist_ok=True)
TypeError: copytree() got an unexpected keyword argument 'dirs_exist_ok'
newlaurent62 commented 4 years ago

The parameter dirs_exist_ok of shutil method copy_tree is new in python 3.8.

If you have python 3.8 or newer then may be your default env is python2. Try to force the use of python3 by changing the following file

in src/templates/mywizard/tmpl_mywizard.py

replace #!/usr/bin/env python

by

#!/usr/bin/python3 or whatever path to your python3 executable

newlaurent62 commented 4 years ago

alternatively, you can try to comment the following line in in src/templates/mywizard/tmpl_mywizard.py:

=> Line 36: #os.makedirs(outdir + os.sep + 'templates' ,exist_ok=True)

and remove: dirs_exist_ok on line 41

=> Line 41: shutil.copytree(templatedir, outdir + os.sep + 'templates')

Houston4444 commented 4 years ago

Last solution works, thanks ! So, this is interesting and gives solutions that RaySession can't give itself, sure. I didn't achieve to start the 3 Jamulus programs (raysession clients), I don't know really why.

The first think I have to say is : Use Proxies ! But you already know.

I don't have icons (my Jamulus install is built from source code), I think it is not a good idea to use absolute path for icons (icons can be present in ~/.local/share/icons, /usr/local/share/icons, /usr/share/icons, depending of where is installed the program providing the icon).

Client Labels are too long. RaySession is designed to be a window as little as possible. I'll give you the possibility to set a description by client.

I don't understand why 'templates' dir is in the session folder finally, could you explain that ?

Seen in the shell script: be careful with ray_control stop !!! ray_control stop stops all running daemons, ray_control quit is probably more indicated in this case (error executing the script). Probably it should be executed only if no daemon was started at script start (you can check this with ray_control get_port).

Maybe you could decide to start raysession's GUI if not already started. You can check this with ray_control has_gui. To start the gui, there is no smarter solution than start it with raysession &>/dev/null &. You could also have check boxes as "load the session" and "save as session template for RaySession", and easily make the good behavior with ray_control.

Best Regards !

newlaurent62 commented 4 years ago

Thanks for your comments and help ! ... I think i need to check the code with a fresh OS install (live USB).

Things are still being implemented.

Initially i put the template in the Raysession document because it contains bin directory with Jamulus program but there was a problem running Jamulus in the Raysession document (because of spaces in the path ~/Ray Sessions/My jack Capture/bin ). I did not solve this problem so i finally put the template files in ~/.local/share/raysession-templates/$(WIZARDNAME). I will remove the template directory from the ray session document.

I plan to create an application that give a menu with all wizard installed.

As i said, the project is at the very start and i need more time to think about it and find how implement the things.

i've late discovered python. But the good thing is there is a lot of information about it on the net.

Houston4444 commented 4 years ago

Obviously, when your project becomes reliable, I can add launcher(s) for your wizards directly in the GUI (enable if your wizards are installed).