Using python to check out a file (cleartool)
If you don't need to enter a comment, a simple -nc would be enough:
os.system('cleartool co -nc ' + pathname)
See cleartool checkout
man page.
If the comment is known, you can add it directly (-c xxx
)
In both cases, the checkout becomes non-interactive, more suite to batch process.
Getting present working view in Clearcase
cleartool pwv
will only give you the name of the view.
To get the path:
cleartool pwv -root
G:\
means probably a snapshot view, since all dynamic views are usually mounted (MVFS) on the drive M:\
by default (but they could be subst'ed to a drive letter as well).
For snapshot views, a drive letter different from C:\
means the actual path of the snapshot view has been subst
(Windows command) to a drive letter in order to shorten its path.
See "To use the subst
command to access snapshot views (Windows)"
Assigning a snapshot view root directory to a drive letter with the subst command provides slightly better performance than making the snapshot view a shared directory
So if you are on G:\norbt5_ed_hil_dev
and want the full path after a cleartool pwv
, you can:
cleartool pwv -root
If that returns you only G:\
, then you need to call the commands subst
to see the full path where G:\
has been assigned.
subst
Or, in python (as in the example):
os.system('subst')
And parse the result.
Note: As explained in "Python and ClearCase setview
", pwv
wouldn't work in a dynamic view started with setview
on Unix (setview
doesn't exist on Windows), because it creates a sub-process.
If you are on Unix working with dynamic view, don't use setview
(as illustrated here).
Always use cleartool startview <view_tag>
, and then the full path of the dynamic view:
/view/AViewName/vobs/aVob/...
A cleartool pwv -root
would then return /view/AViewName
.
On Windows, if cleartool pwv
is used in a dynamic view, then the name of the view returned by cleartool pwv -short
is enough:
The path of the root folder of a dynamic view on Windows is always:
m:\view_tag
even if the view has been subst
to a different drive letter.
You don't need the -root
.
Python ClearCase Download Vobs Popen Password BASH Program Sketchy
Try and not use setview
.
You do not need it and you can use the full path of the view instead.
cleartool startview yourDynamicView
cd /view/yourDynamicView/vobs/yourVob
I have mentioned before the danger of using setview ("Python and ClearCase setview").
It creates a subprocess within your subprocess, which is not needed here.
Setting a view on clearcase from a script exits the script why and also need a solution?
Simply don't use cleartool setview
.
As I describe in "How to exit from clearcase view and not from script?":
any commands that appear after the execution of cleartool setview XYZ are not processed because a shell is spawned with
exec()
, which replaces the current program with a new program.
See more at "Python and ClearCase setview".
Instead, use the full path of the view /view/<view name>/vobs/yourVob
, in order to launch your script.
(But first, make sure you start the dynamic view: cleartool startview <view name>
)
If you still want to use setview
, try at least:
cleartool setview -exec "yourScript" -view <view name>
Otherwise, -view
would be interpreted as an option to -exec
command, which makes no sense.
Script exits after view is set (clearcase)
As I mentioned before in "Python and ClearCase setview", using setview
in a script is generally not a good idea.
It will create a subshell, which will cause any running script to exit once that subshell exits.
If you can, use the full dynamic view path (/view/myView/vobs/myVob/...
): you are then sure in that path to run as many scripts/commands as you want.
As long as the dynamic view is started and the vob mounted, you don't need setview
.
If you do need setview
:
cleartool setview -exec script viewname
: make sure you type yourself the '-
' in-exec
, and don't copy-paste it. That is because of the hyphen-minus bug I illustrate in ClearCase question.- try do set the view, then run your script (two steps, as I recommend here)
working in /vobs/some/path versus /view/view-tag-name/vobs/some/path
what's the difference between working in
/vobs/some/path
in asetview
shell versus working in/view/view-tag-name/vobs/some/path
in a plain shell?
Do not use cleartool setview
: As I explained before, the cleartool setview
command opens a subshell in which commands are supposed to be run, which can be problematic.
Working in /view/view-tag-name/vobs/some/path
means you remain in your main shell, with all its properties.
what is the proper term to use when referring to the
/view/view-tag-name
directory?
That references the full path view root folder (inside which you are mounting vobs and accessing versions based on the view config spec and its selection rules)
In /vobs/some/path
, you can still see the view you are in with cleartool pwv ("path working view").
why when I do
ct lsview -l -properties -ful view-tag-name
I don't see any reference to the/view/view-tag-name
directory?
You are seeing the property of the view, which will then be mounted in /view/view-tag-name
(on Unix) or M:\view-tag-name
on Windows.
Those properties make no assumption on the runtime usage of that view, they only display static metadata (like the view storage or the view type)
Findmerge graphical using paramiko
It depends how you did setup your X-forwarding: see this thread for example:
- Launch Exceed
- Launch Putty
- In the putty configuration window, select Connection, then SSH, and then X11 from the left side menus.
- On the right side, select the checkbox for
Enable X11 forwarding
and set the X display location to "localhost:0
" . - In the putty configuration window, select
Session
from the left side.
Enter thehostname
of a system to connect to Select the SSH protocol
Save settings by selecting theSave
button on the right. - Invoke session by double-clicking on hostname
- from the server, run "
export DISPLAY=windows ip:0
" - You should be able to run any X-based tool or application
e.g.clearprojexp &
The OP Srikar Veeramallu mentions in the comments:
I am in a dynamic view set using
cleartool setview
That explains why it "waits forever". A setview
will create a sub-shell, which might not benefit from the same X11 forwarding as the main shell.
See "Python and ClearCase setview
" for more details.
The workaround is to use the full path of the view.
Cannot 'cleartool setview' in a shell process opened with Perl IPC::open2
As I mention in the answer you saw "Python and ClearCase setview", using setview
in a script is generally not a good idea.
The only solution I know is two make 2 scripts:
- one which ensure that setview is done, and
/vobs/xxx
refers to the right vob in the right view - one which will use
/vobs
.
Trying to do all in one step will mostly fail due to the sub-shell launched by setview.
Related Topics
Removing Duplicate Characters from a String
Python, Typeerror: Unhashable Type: 'List'
Check If a String Matches an Ip Address Pattern in Python
How to Plot Implicit Equations Using Matplotlib
Type Hints: Solve Circular Dependency
Why Isn't Pycharm's Autocomplete Working for Libraries I Install
How to Allow or Deny Notification Geo-Location Microphone Camera Pop Up
How to Make a Multi-Color Line in Matplotlib
How to Save a Python Interactive Session
What Is the Use of Join() in Python Threading
How to Drop a List of Rows from Pandas Dataframe
Difference Between Exit() and Sys.Exit() in Python
Efficient Way to Apply Multiple Filters to Pandas Dataframe or Series
Creating a New Corpus with Nltk
Python List Subtraction Operation
How to Run a Python Program in the Command Prompt in Windows 7
How to Mock an Open Used in a with Statement (Using the Mock Framework in Python)