I would like to set to a clearcase view from a python script, and then execute commands within that view. I have tried using various methods outlined here:
subprocess
but I have not had any success. Does anyone know how to accomplish this?
I would like to set to a clearcase view from a python script, and then execute commands within that view. I have tried using various methods outlined here:
subprocess
but I have not had any success. Does anyone know how to accomplish this?
I wouldn\'t recommend setting a view, because setview
itself spawn a new process.
I really prefer working with /view/viewTag/aVob/...
after starting the view (cleartool startview viewTag
)
The \"spawn process\" issue makes the all thing too complex in my opinion, and explains why you have technotes like:
Any commands that appear after the execution of
cleartool setview cmview
are not processed because a shell is spawned off withexec()
, which replaces the current program with a new program.This means current process\'s text and code segments, which in this case is the script that contains all the commands, is replaced by the program getting executed, which is the shell invoked by running
cleartool setview cmview
.
Hence, none of the commands are processed beyond the point of invocation of thesetview
.
The
-exec
variable will start a subshell process and invoke the specified command in the dynamic view specified. Control is then returned to the parent shell once the command has finished.
The-exec
will not set the view in the parent shell process.
The-exec
spawned subshell will inherit the Environment variables of the parent shell process; however, the Environment variables created in the child shell will not pass back into the parent shell.
So if you really want to use setview
, you could (not tested directly myself):
setview
setview
call would be with an -exec
parameter being another python script (doing what you want to do when that /vobs
is configured with the content of said set view.Old thread, but i just had to work on this issue , so maybe of help .
In your python script
process = subprocess.Popen(\'usr/atria/bin/cleartool setview viewName\')
(out, err) = process.communicate(\'python script2Name\')
the .communicate can be passed new commands, as if you were passing it to a new shell (terminal).