otsdaq_utilities  v2_05_02_indev
ProductsUpdate.py
1 #!/usr/bin/env python
2 
3 #THIS IS DEPRECATED (according to me, RAR -- sept 2017.. Parilla made this a while ago)
4 
5 import os
6 import subprocess
7 
8 otsdaqVersion = "s64-e15 prof";
9 
10 try:
11  os.path.isdir(os.environ['PRODUCTS']);
12 except KeyError:
13  print "PRODUCTS variable not set.";
14  print "Example:";
15  print "export PRODUCTS=`pwd`";
16  exit(1);
17 
18 ########################################################################
19 #get pull products
20 ########################################################################
21 cmd=os.environ['PRODUCTS'];
22 print cmd
23 os.chdir(cmd);
24 
25 if(os.path.isfile('pullProducts')):
26  os.remove('pullProducts');
27 
28 ######################################################################
29 cmd='curl -O http://scisoft.fnal.gov/scisoft/bundles/tools/pullProducts';
30 print cmd
31 os.system(cmd);
32 
33 ######################################################################
34 cmd='chmod +x pullProducts';
35 print cmd
36 os.system(cmd);
37 
38 ########################################################################
39 #pull the latest version of artdaq_demo from scisoft
40 ########################################################################
41 cmd = 'curl -s http://scisoft.fnal.gov/scisoft/bundles/otsdaq/ | grep id=\\"v | grep -oP \'(?<=id=\\")[^\\">]*\'';
42 print cmd;
43 process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
44 otsdaq_version,err = process.communicate();
45 if(err != '' and not err.find('Total')):
46  print "There was an error executing \"" + cmd + "\"";
47  print "Error:\n" + err;
48 
49 otsdaq_versions = otsdaq_version.rstrip().split();
50 
51 #print otsdaq_versions;
52 
53 ########################################################################
54 #detect operating system
55 ########################################################################
56 cmd = "uname -r";
57 print cmd
58 process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
59 operatingSystem,err = process.communicate();
60 if(err != ''):
61  print "There was an error executing \"" + cmd + "\"";
62  print "Error:\n" + err;
63 #print out
64 if "el6" in operatingSystem:
65  host_os = "slf6"
66  xerces_os = "slf6"
67 elif "el7" in operatingSystem:
68  host_os = "slf7"
69  xerces_os = "sl7"
70 
71 
72 cmd='cd $Products';
73 print cmd
74 os.system(cmd)
75 
76 for otsdaq_version in reversed(otsdaq_versions):
77  print "Fetching products for otsdaq_version: " + otsdaq_version;
78  print "This step might take longer than you wish so be patient..."
79  cmd = "./pullProducts . " + host_os + " otsdaq-" + otsdaq_version + " " + otsdaqVersion;
80  print cmd;
81  process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
82  operatingSystem,err = process.communicate();
83  if(err != ''):
84  print "There was an error executing \"" + cmd + "\"";
85  print "Error:\n" + err;
86  if( err.find('MANIFEST') == -1):
87  break;
88  print "Trying to fetch an older otsdaq_version..."
89  else:
90  break;
91 
92 ########################################################################
93 # Removing all tar files
94 ########################################################################
95 cmd="rm -f *.bz2 *.txt";
96 print cmd
97 os.system(cmd)
98 
99 
100 
101 
102 
103