Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env python
from Cheetah.Template import Template
from datetime import date
#from getSheets import myIcd
from GenDevice.excelIcd import excelIcd
import sys,os
from optparse import OptionParser
import subprocess
from GenDevice.genFromTemplates import genFromTemplates
from GenDevice.createEmptyCDB import *
from GenDevice.acsUtils import *
if __name__ =="__main__":
parser = OptionParser()
today = date.today()
parser.add_option("-f", "--file", dest="bookfile",
help="ICD Exel File ", metavar="FILE")
parser.add_option("-d", "--dir", dest="basedir", default="./tmp",
help="Root dir where to install the new device ", metavar="DIR")
parser.add_option("-p", "--prefix", dest="prefix", default="astri",
help="pkg prefix es. astri ", metavar="PREFIX")
parser.add_option("-m", "--module", dest="module", default="tcs",
help="module name es.tcs ", metavar="MODULE")
parser.add_option("-i", "--install", action="store_true",
help="execute the Makefile in src dir ", metavar="INSTALL")
(options, args) = parser.parse_args()
print("running genDevice with the following options:\n", options)
#exit()
gendir=os.environ["PYGEN"]
if gendir=="":
print ("Please set the env variable PYGEN = the Geneartor root directory")
exit()
if not checkACS():
print ("ACS Enviroment is not set")
exit()
pwd=os.getcwd()
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
excel_file =options.book_file
wb=excelIcd(excel_file)
devs=wb.MainSheet['Device Name']
comp=wb.MainSheet['Component Name']
assembly=wb.MainSheet['Assembly']
outdir="/media/sf_Desktop/Useful_SW/"
outfile=[]
if len(assembly)>1 :
print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs)
for dev in devs:
query="`Device Name` =="+ "'"+dev+"'"
print("working On:", query)
main=(wb.book.parse("Main")).query(query)
get=(wb.book.parse("GET")).query(query)
sett=(wb.book.parse("SET")).query(query)
cmd=(wb.book.parse("CMD")).query(query)
mode=(wb.book.parse("MODE")).query(query)
outfile.append(outdir+dev+".xlsx")
with pd.ExcelWriter(outfile[-1]) as writer:
main.to_excel(writer,sheet_name='Main')
get.to_excel(writer,sheet_name='GET')
sett.to_excel(writer,sheet_name='SET')
cmd.to_excel(writer,sheet_name='CMD')
mode.to_excel(writer,sheet_name='MODE')
print("Working on files:",dev)
mygen=genFromTemplates(outfile[-1],options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
if options.install :
introot = os.environ["INTROOT"]
if introot=="":
print("INTROOT variable is not set")
exit()
os.chdir(mygen._dirs['src'])
print ("Make Build ")
command="make clean all"
print (command)
if execACSCommand(command):
print ("ERROR executing: ",command,)
os.chdir(pwd)
else:
mygen=genFromTemplates(options.book_file,options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
if options.install :
introot = os.environ["INTROOT"]
if introot=="":
print("INTROOT variable is not set")
exit()
os.chdir(mygen._dirs['src'])
print ("Make Build ")
command="make clean all"
print (command)
if execACSCommand(command):
print ("ERROR executing: ",command,)
os.chdir(pwd)
"""else:
command ="make install"
if execACSCommand(command):
print ("ERROR executing: ",command)
os.chdir(pwd)
exit()
os.chdir(pwd)
command="cdbChecker"
if execACSCommand(command):
print ("ERROR executing: ",command)
exit()"""
print ("ALL Done")