1

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 + '\n')
    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.

user3808269
  • 1,321
  • 3
  • 21
  • 40
  • I see the name of the `folder` variable in the `dest` location but none of the actual data I want underneath this folder. This was working yesterday though with copying all the important stuff underneath the `folder`. – user3808269 Jan 07 '15 at 17:59
  • Yes. When I run it from BASH I am in a ClearCase view and run `sudo cp -r /my_data /etc/foo` and it copies everything recursively to the target location. So this Python works on your system? I wonder if I messed up my environment variables earlier trying to tweak CRON. – user3808269 Jan 07 '15 at 18:05
  • Interesting. Thank-you for the feedback. – user3808269 Jan 07 '15 at 18:08
  • I created some folders in `$HOME` and tried to copy them somewhere else using the above commands in an interactive Python shell but I received this Traceback error: `IOError: [Errno 32] Broken pipe` :/ – user3808269 Jan 07 '15 at 18:22
  • I think I may try the `shutil` module and see if I get better results. Please see my updates above. The problem maybe interacting with ClearCase. I think this because I created some folders on my desktop and made a script to copy them to a system folder and it worked so I do not think this is the problem anymore. – user3808269 Jan 07 '15 at 18:57

1 Answers1

0

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Should I hard-code the dynamic view? I do not know the full path of the view. – user3808269 Jan 07 '15 at 19:00
  • @user3870315 no hard coding needed. As long as you know the name of your dynamic view, you can build the full path of that view. setview is not needed. – VonC Jan 07 '15 at 19:03
  • Thank-you for the help. I think I found the full path to the view. I am going to experiment with this by writing some code and see if this works. Thank-you again. :D – user3808269 Jan 07 '15 at 19:06
  • I noticed that all the views appear to be under the `/view` directory. With this in mind why would I need to use the `startview` command? – user3808269 Jan 07 '15 at 19:31
  • @user3870315 you would not need to use setview indeed. – VonC Jan 07 '15 at 19:32