Trouble using ccdb dump command in python

13 views
Skip to first unread message

Albert Fabrizi

unread,
Mar 23, 2023, 12:45:43 PM3/23/23
to GlueX Software Help
Hello,
I am trying to use the command ccdb dump in a python script to edit an sqlite file but inside the script the command "ccdb dump" is not recognized. The issue is that when I use ccdb dump on the command line it works fine and I am not sure where the disconnect is. 

I have attached pictures of my trial and error and the script I used to try to debug it, as well as the python version I am using. 


Screenshot 2023-03-23 at 12.40.30 PM.png
Screenshot 2023-03-23 at 12.40.58 PM.png
Screenshot 2023-03-23 at 12.41.09 PM.png
Screenshot 2023-03-23 at 12.43.33 PM.png

Beni Zihlmann

unread,
Mar 23, 2023, 12:55:39 PM3/23/23
to gluex-s...@googlegroups.com
Hi Albert,
first from your pictures it is not clear what you mean "does not work">
second, what do you actually want to do? Do you want the content of the
table directly into the script??

cmd = "ccdb dump CTOF/tdc_timing_offsets"
system(cmd)

will do that too, no need to use subprocess.

and if you want it into a file you could do: (-nc to not print #  comments)
cmd = "ccdb dump -nc CTOF/tdc_timing_offsets > outfiles.log"
--
You received this message because you are subscribed to the Google Groups "GlueX Software Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gluex-softwar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gluex-software/0fc8394e-2d4f-4e0c-ac8c-3f5c470bbd7cn%40googlegroups.com.

roma...@gmail.com

unread,
Mar 23, 2023, 12:58:28 PM3/23/23
to GlueX Software Help
Hi All, 

Looks like I messed google group replies. There is also an ability to use CCDB commands directly in python

Example: 
https://github.com/JeffersonLab/ccdb/blob/master/python/tests/integ_test_cli_manager.py#L101


More info on python APIs: 

Albert Fabrizi

unread,
Mar 23, 2023, 1:36:41 PM3/23/23
to GlueX Software Help
Sorry I should have been more specific, I am trying to dump the contents of the constant tdc_timing_offets too a .dat file which is then read and edited by the python script, the script then "uploads" the values in the .dat file to my personal sqlite file. Therefore changing the constants (in my case the tdc_timing_offsets constants) to the new values(the small snippet of python code I posted is just the line providing this error so i made this just to test it). The error comes in where the script will not dump the constants into the .dat file to begin with to be edited, since in the python script the command "ccdb dump" is not recognized, however when i just type the command "ccdb dump CTOF/tdc_timing_offsets" directly into the terminal I get the proper response. I was looking for any issues with the process I was attempting to do this with, and I will definitely try your suggestions.

On Thursday, March 23, 2023 at 12:55:39 PM UTC-4 Beni Zihlmann wrote:

Albert Fabrizi

unread,
Mar 23, 2023, 1:37:20 PM3/23/23
to GlueX Software Help
Thank you I will look at this to see if I can find the error.

zihlmann

unread,
Mar 23, 2023, 2:39:05 PM3/23/23
to gluex-s...@googlegroups.com
the problem is that the subprocess will create a new shell may be different than the shell
you are normally using meaning there are NO environment variables set.
you can test that by executing the command "env >toflie.log"
to see what environment variables are set. And it is probably non, in particular ccdb is not defined.
make sure you use the correct shell.

Beni
 

roma...@gmail.com

unread,
Mar 23, 2023, 2:47:08 PM3/23/23
to GlueX Software Help
I would suggest you to just use CCDB python api. You can then just load  tdc_timing_offets into a list table, change everything, and upload it back. 

Here is an example of how one does this

https://github.com/JeffersonLab/ccdb/blob/master/python/examples/example_llapi_change_value.py

Dmitry
Reply all
Reply to author
Forward
0 new messages