[Tutor] Handling multiple file checkins in Clearcase from Python

shobhan schalla@vasoftware.com
Tue Jun 10 04:29:04 2003


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<font face="Helvetica, Arial, sans-serif" size="-1">Hi Everyone,<br>
<br>
Im encountering a strange problem here, i have a Clearcase machine and
i've made a python script which is fired by a clearcase trigger when a
'checkin' operation occurs on the Clearcase server. Here the python
script will get all the committed file info and dumps the info into the
DB.<br>
<br>
When i do a checkin in clearcase like (cleartool ci file1) it works
fine, but the problem occurs when i do a <br>
1) directory checkin (like cleartool ci directory_name)<br>
or<br>
2) checkin using dot(.) (like cleartool ci .)<br>
<br>
Here if there are 3 modified files and 2 new files, clearcase picks up
all the files (new and modified) but on the Python side it doesnt give
any file names, just gives dot(.).<br>
<br>
Now my question is when a user does a checkin like (cleartool ci .) how
do i pick the filenames, usernames from my python script..??<br>
<br>
The python script is as follows:<br>
<br>
<font color="#993300">#!/usr/bin/python<br>
<br>
import sys, os, os.path, local, re,time<br>
<br>
commit_msg = os.getenv('CLEARCASE_COMMENT')<br>
cc_user = os.getenv('CLEARCASE_USER')<br>
operation = os.getenv('CLEARCASE_OP_KIND')<br>
eltype = os.getenv('CLEARCASE_ELTYPE')<br>
</font></font><font face="Helvetica, Arial, sans-serif" size="-1"
 color="#993300">file_name = os.getenv('CLEARCASE_PN')</font><font
 color="#993300"><br>
<br>
</font><font face="Helvetica, Arial, sans-serif" size="-1"
 color="#993300">project_name = sys.argv[1:]<br>
<br>
#if eltype == 'directory':<br>
&nbsp;&nbsp;&nbsp; #sys.exit(0)<br>
<br>
if operation == 'checkin':<br>
&nbsp;&nbsp;&nbsp; files = []<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; ## Loop the file names <br>
&nbsp;&nbsp;&nbsp; for file in file_name:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if file:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; parts = string.split(file, ':')<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; files.append({'name':parts[0], 'version':parts[1],
'old_version':parts[2]})<br>
<br>
&nbsp;&nbsp;&nbsp; print file_name</font><font color="#993300"><br>
</font><font face="Helvetica, Arial, sans-serif" size="-1"><br>
Thanks in advance<br>
Schalla</font><br>
</body>
</html>