otsdaq_utilities
v2_05_02_indev
Return to top level
Main Page
Related Pages
Namespaces
Classes
Files
File List
AddNewHardware.py
1
#!/usr/bin/env python
2
#____________________________________________________________
3
#
4
# addNewHardware.py --help
5
#
6
#____________________________________________________________
7
#
8
9
import
argparse
10
import
os
#for isdir abspath dirname
11
12
print
13
print
"***********************\n"
14
print
"Setting up and Installing...\n"
+ \
15
"Look for 'Success!' at end of print out.\n"
16
print
17
18
19
parser =
argparse.ArgumentParser
(description=
'Setup Firmware Component'
)
20
21
parser.add_argument(
'-d'
,
'--dest'
,
22
help=
'Destination path for new Interface'
)
23
parser.add_argument(
'-n'
,
'--name'
,
24
help=
'Name of new Hardware'
)
25
26
args = parser.parse_args()
27
28
print
29
print
'Arguments parsed...'
30
print
args
31
print
32
print
33
34
########
35
# at this point call is legal according to argparse
36
37
scriptDir = os.path.dirname(os.path.abspath(__file__))
38
39
40
print
'Script directory is:'
41
print
scriptDir
42
print
43
44
dest = scriptDir +
"/../hdl"
#default destination path
45
if
(args.dest):
#if option used, then use args.dest
46
dest = args.dest
47
48
print
'Destination directory is:'
49
print
dest
50
print
51
print
52
53
#validate destination directory
54
if
((
not
os.path.isdir(dest +
"/"
))):
55
print
"Error!\n Check usage. "
56
parser.print_help()
57
print
58
print
"****************"
59
exit(
"Error: Invalid destination path '"
+ (args.dest) +
"')\n\n"
)
60
61
62
print
'Copy files...'
63
64
srcFile = scriptDir +
"/../../otsdaq/otsdaq/DAQHardware/FrontEndHardwareTemplate.cc"
65
os.system(
"cp "
+ srcFile +
" "
+ args.dest +
"/"
+ args.name +
".cc"
);
66
os.system(
"sed -i s/FrontEndHardwareTemplate/"
+ args.name +
"/g "
+ \
67
args.dest +
"/"
+ args.name +
".cc"
);
68
69
srcFile = scriptDir +
"/../../otsdaq/otsdaq/DAQHardware/FrontEndHardwareTemplate.h"
70
os.system(
"cp "
+ srcFile +
" "
+ args.dest +
"/"
+ args.name +
".h"
);
71
os.system(
"sed -i s/FrontEndHardwareTemplate/"
+ args.name +
"/g "
+ \
72
args.dest +
"/"
+ args.name +
".h"
);
73
74
75
76
77
print
78
print
"***********************\n"
79
print
'Success!'
80
print
81
print
82
argparse.ArgumentParser
Definition:
argparse.py:1538
otsdaq_utilities
tools
AddNewHardware.py
Generated on Wed Apr 29 2020 18:45:12 for otsdaq_utilities by
1.8.5