$treeview $search $mathjax $extrastylesheet
otsdaq_utilities
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #!/usr/bin/env python 00002 #____________________________________________________________ 00003 # 00004 # addNewHardware.py --help 00005 # 00006 #____________________________________________________________ 00007 # 00008 00009 import argparse 00010 import os #for isdir abspath dirname 00011 00012 print 00013 print "***********************\n" 00014 print "Setting up and Installing...\n" + \ 00015 "Look for 'Success!' at end of print out.\n" 00016 print 00017 00018 00019 parser = argparse.ArgumentParser(description='Setup Firmware Component') 00020 00021 parser.add_argument('-d','--dest', 00022 help='Destination path for new Interface') 00023 parser.add_argument('-n','--name', 00024 help='Name of new Hardware') 00025 00026 args = parser.parse_args() 00027 00028 print 00029 print 'Arguments parsed...' 00030 print args 00031 print 00032 print 00033 00034 ######## 00035 # at this point call is legal according to argparse 00036 00037 scriptDir = os.path.dirname(os.path.abspath(__file__)) 00038 00039 00040 print 'Script directory is:' 00041 print scriptDir 00042 print 00043 00044 dest = scriptDir + "/../hdl" #default destination path 00045 if (args.dest): #if option used, then use args.dest 00046 dest = args.dest 00047 00048 print 'Destination directory is:' 00049 print dest 00050 print 00051 print 00052 00053 #validate destination directory 00054 if ((not os.path.isdir(dest + "/"))): 00055 print "Error!\n Check usage. " 00056 parser.print_help() 00057 print 00058 print "****************" 00059 exit("Error: Invalid destination path '" + (args.dest) + "')\n\n") 00060 00061 00062 print 'Copy files...' 00063 00064 srcFile = scriptDir + "/../../otsdaq/otsdaq/DAQHardware/FrontEndHardwareTemplate.cc" 00065 os.system("cp " + srcFile + " " + args.dest + "/" + args.name + ".cc"); 00066 os.system("sed -i s/FrontEndHardwareTemplate/" + args.name + "/g " + \ 00067 args.dest + "/" + args.name + ".cc"); 00068 00069 srcFile = scriptDir + "/../../otsdaq/otsdaq/DAQHardware/FrontEndHardwareTemplate.h" 00070 os.system("cp " + srcFile + " " + args.dest + "/" + args.name + ".h"); 00071 os.system("sed -i s/FrontEndHardwareTemplate/" + args.name + "/g " + \ 00072 args.dest + "/" + args.name + ".h"); 00073 00074 00075 00076 00077 print 00078 print "***********************\n" 00079 print 'Success!' 00080 print 00081 print 00082