$treeview $search $mathjax $extrastylesheet
otsdaq_utilities
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #!/usr/bin/env python 00002 #____________________________________________________________ 00003 # 00004 # addNewFrontEndInterface.py --help 00005 # 00006 #____________________________________________________________ 00007 # 00008 00009 #//For example: 00010 #// ./addNewFrontEndInterface.py -n MyInterface 00011 #// -- copy FrontEndGenericInterface.cc MyInterface.cc 00012 #// -- replace sed /FrontEndGenericInterface/MyInterface/g 00013 00014 import argparse 00015 import os #for isdir abspath dirname 00016 00017 #//Steps: 00018 #// - copy source to destination 00019 #// - swap in new name 00020 #// - Add entry in destination CMakeLists.txt 00021 00022 00023 print 00024 print "***********************\n" 00025 print "Setting up and Installing...\n" + \ 00026 "Look for 'Success!' at end of print out.\n" 00027 print 00028 00029 00030 parser = argparse.ArgumentParser(description='Setup Firmware Component') 00031 00032 parser.add_argument('-s','--src', 00033 help='Source path for new Interface') 00034 parser.add_argument('-d','--dest', 00035 help='Destination path for new Interface') 00036 parser.add_argument('-n','--name', 00037 help='Name of new Interface') 00038 parser.add_argument('-hw','--hardwareName', 00039 help='Name of new Interface') 00040 parser.add_argument('-fw','--firmwareName', 00041 help='Name of new Interface') 00042 00043 args = parser.parse_args() 00044 00045 print 00046 print 'Arguments parsed...' 00047 print args 00048 print 00049 print 00050 00051 ######## 00052 # at this point call is legal according to argparse 00053 00054 scriptDir = os.path.dirname(os.path.abspath(__file__)) 00055 00056 00057 print 'Script directory is:' 00058 print scriptDir 00059 print 00060 00061 ################################## 00062 print 'Validating source path...' 00063 00064 source = scriptDir + "/../../otsdaq_demo/" #default destination path 00065 if (args.dest): #if option used, then use args.dest 00066 dest = args.dest 00067 00068 print 'Destination directory is:' 00069 print dest 00070 print 00071 print 00072 00073 #validate destination directory 00074 if ((not os.path.isdir(dest + "/"))): 00075 print "Error!\n Check usage. " 00076 parser.print_help() 00077 print 00078 print "****************" 00079 exit("Error: Invalid destination path '" + (args.dest) + "')\n\n") 00080 00081 ################################## 00082 dest = scriptDir + "/" #default destination path 00083 if (args.dest): #if option used, then use args.dest 00084 dest = args.dest 00085 00086 print 'Destination directory is:' 00087 print dest 00088 print 00089 print 00090 00091 #validate destination directory 00092 if ((not os.path.isdir(dest + "/"))): 00093 print "Error!\n Check usage. " 00094 parser.print_help() 00095 print 00096 print "****************" 00097 exit("Error: Invalid destination path '" + (args.dest) + "')\n\n") 00098 00099 00100 print 'Copy files...' 00101 00102 srcFile = scriptDir + "/../../otsdaq/otsdaq/DetectorWriter/FrontEndInterfaceTemplate.cc" 00103 os.system("cp " + srcFile + " " + args.dest + "/" + args.name + ".cc"); 00104 os.system("sed -i s/FrontEndInterfaceTemplate/" + args.name + "/g " + \ 00105 args.dest + "/" + args.name + ".cc"); 00106 os.system("sed -i s/FrontEndHardwareTemplate/" + args.hardwareName + "/g " + \ 00107 args.dest + "/" + args.name + ".cc"); 00108 os.system("sed -i s/FrontEndFirmwareTemplate/" + args.firmwareName + "/g " + \ 00109 args.dest + "/" + args.name + ".cc"); 00110 00111 srcFile = scriptDir + "/../../otsdaq/otsdaq/DetectorWriter/FrontEndInterfaceTemplate.h" 00112 os.system("cp " + srcFile + " " + args.dest + "/" + args.name + ".h"); 00113 os.system("sed -i s/FrontEndInterfaceTemplate/" + args.name + "/g " + \ 00114 args.dest + "/" + args.name + ".h"); 00115 os.system("sed -i s/FrontEndHardwareTemplate/" + args.hardwareName + "/g " + \ 00116 args.dest + "/" + args.name + ".h"); 00117 os.system("sed -i s/FrontEndFirmwareTemplate/" + args.firmwareName + "/g " + \ 00118 args.dest + "/" + args.name + ".h"); 00119 00120 00121 00122 00123 00124 print 00125 print "***********************\n" 00126 print 'Success!' 00127 print 00128 print 00129