Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
675 views
in Technique[技术] by (71.8m points)

subprocess - Python ClearCase Download Vobs Popen Password BASH Program Sketchy

I coded this program yesterday and it was actually working except for when run by CRON. Today, I ran the same script and it does not work. The script will run without any Tracebacks Errors, and it will copy the top folder (vob) from the ClearCase view, but none of the actual important data in the folders and files below the target folder.

Here is my Python script.

def obtainCode(view="My_VIEW", folder="/my_folder"):
    """Download code from ClearCase's File System and put it on the hard-drive"""

    dest = '/etc/foo'
    password = 'passwords'

    v1 = subprocess.Popen(['cleartool', 'setview', view], shell=True, stdout=subprocess.PIPE)
    print "v1 = ", v1
    print "view maybe set :/"

    c1 = subprocess.Popen(['sudo', '-p', '', '-S', 'cp', '-r', folder, dest], stdin=subprocess.PIPE)
    c1.stdin.write(password + '
')
    c1.stdin.close()
    c1.wait()

    #### Close View and Stop Processes ####
    v2 = subprocess.Popen(['cleartool', 'endview', view], shell=True, stdin=v1.stdout, stdout=subprocess.PIPE)


    v2.kill()
    v1.kill()

Does anyone know: 1) what is going wrong 2) why it would work yesterday but not today 3) a better way to do this?

Thank-you for your time and attention.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...