How to check if a file is checked out (Clearcase / Python)

1.4k views Asked by At

I guess the title sufficiently sums up my question. I have working code to automatically check out a file:

 p = Popen(['cleartool', 'co', pathname], stdin = PIPE)
 p.communicate('comment for checkout')

I'm wondering how to check if the file is already checked out before executing this. Thanks in advance everyone!

1

There are 1 answers

1
VonC On BEST ANSWER

You can parse the output of a cleartool ls -short pathname

If checked out, its version will end with /CHECKEDOUT.

Or you can go ahead, try to check out and test the exit status of the command. But there could be other causes for failure (other than "already checked out")