Python and ClearCase setview

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 with exec(), 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 the setview.

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):

  • have a python script calling setview
  • but that 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.

Leave a Comment