Loading GenDevice/genFromTemplates.py +2 −2 Original line number Diff line number Diff line Loading @@ -40,10 +40,10 @@ archive=["0","15"] class genFromTemplates: def __init__(self, bookfile,prefix="astri",module="tcs", basedir="./tmp"): def __init__(self, wbook,bookfile,prefix="astri",module="tcs", basedir="./tmp"): self.bookfile =bookfile self.basedir=basedir wbook=excelIcd(bookfile) #wbook=excelIcd(bookfile) self.wb=wbook self.gendir=os.environ["PYGEN"] if self.gendir=="": Loading test/genDevice.py +50 −44 Original line number Diff line number Diff line Loading @@ -15,6 +15,43 @@ import glob outdir="/tmp/" 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() def generateComponent(config,install=False): pwd=os.getcwd() wb=excelIcd(config['icdfile']) smain= wb.book.parse("Main") devs= smain['Device Name'] comp=smain['Component Name'] assembly=smain['Assembly'] outfile=[] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) outfile.append(outf) print("Working on files:",dev) wb1=excelIcd(ouf) mygen=genFromTemplates(wb1,outf,config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) removetmpfiles() else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) #outf=manageICDFiles(devs[0],outdir,wb) mygen=genFromTemplates(wb,config['icdfile'],config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) os.chdir(pwd) def manageICDFiles(dev,outdir,wb): query="`Device Name` =="+ "'"+dev+"'" main=(wb.book.parse("Main")).query(query) Loading @@ -36,12 +73,14 @@ def build(mygen): if introot=="": print("INTROOT variable is not set") else: pwd=os.getcwd() os.chdir(mygen._dirs['src']) print ("Make Build ") command="make clean all" print (command) command="make clean all install" print ("Executing:",command,'\n',"...Please wait it will take some minutes") if execACSCommand(command): print ("ERROR executing: ",command) os.chdir(pwd) def removetmpfiles(): Loading @@ -55,6 +94,7 @@ def removetmpfiles(): if __name__ =="__main__": parser = OptionParser() today = date.today() pwd=os.getcwd() parser.add_option("-f", "--file", dest="bookfile", help="ICD Exel File ", metavar="FILE") parser.add_option("-d", "--dir", dest="basedir", default="./tmp", Loading @@ -63,51 +103,17 @@ if __name__ =="__main__": 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", parser.add_option("-i", "--install", dest="install", default=False, 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() excel_file =options.bookfile wb=excelIcd(excel_file) #tmp=wb.book.parse("Main") #smain=pd.DataFrame(data=tmp.loc[1:,tmp.columns].values,columns=tmp.loc[0,tmp.columns]) #print (smain) smain= wb.book.parse("Main") devs= smain['Device Name'] comp=smain['Component Name'] assembly=smain['Assembly'] outfile=[] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) outfile.append(outf) print("Working on files:",dev) mygen=genFromTemplates(outfile[-1],options.prefix,options.module,options.basedir) mygen.generateFileInDir() if options.install : build(mygen) os.chdir(pwd) else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) outf=manageICDFiles(devs[0],outdir,wb) mygen=genFromTemplates(outf,options.prefix,options.module,options.basedir) mygen.generateFileInDir() if options.install : build(mygen) os.chdir(pwd) removetmpfiles() config={} config['icdfile']=options.bookfile config['prefix']=options.prefix config['module']=options.module config['basedir']=options.basedir generateComponent(config,install=options.install) print ("ALL Done") os.chdir(pwd) Loading
GenDevice/genFromTemplates.py +2 −2 Original line number Diff line number Diff line Loading @@ -40,10 +40,10 @@ archive=["0","15"] class genFromTemplates: def __init__(self, bookfile,prefix="astri",module="tcs", basedir="./tmp"): def __init__(self, wbook,bookfile,prefix="astri",module="tcs", basedir="./tmp"): self.bookfile =bookfile self.basedir=basedir wbook=excelIcd(bookfile) #wbook=excelIcd(bookfile) self.wb=wbook self.gendir=os.environ["PYGEN"] if self.gendir=="": Loading
test/genDevice.py +50 −44 Original line number Diff line number Diff line Loading @@ -15,6 +15,43 @@ import glob outdir="/tmp/" 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() def generateComponent(config,install=False): pwd=os.getcwd() wb=excelIcd(config['icdfile']) smain= wb.book.parse("Main") devs= smain['Device Name'] comp=smain['Component Name'] assembly=smain['Assembly'] outfile=[] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) outfile.append(outf) print("Working on files:",dev) wb1=excelIcd(ouf) mygen=genFromTemplates(wb1,outf,config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) removetmpfiles() else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) #outf=manageICDFiles(devs[0],outdir,wb) mygen=genFromTemplates(wb,config['icdfile'],config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) os.chdir(pwd) def manageICDFiles(dev,outdir,wb): query="`Device Name` =="+ "'"+dev+"'" main=(wb.book.parse("Main")).query(query) Loading @@ -36,12 +73,14 @@ def build(mygen): if introot=="": print("INTROOT variable is not set") else: pwd=os.getcwd() os.chdir(mygen._dirs['src']) print ("Make Build ") command="make clean all" print (command) command="make clean all install" print ("Executing:",command,'\n',"...Please wait it will take some minutes") if execACSCommand(command): print ("ERROR executing: ",command) os.chdir(pwd) def removetmpfiles(): Loading @@ -55,6 +94,7 @@ def removetmpfiles(): if __name__ =="__main__": parser = OptionParser() today = date.today() pwd=os.getcwd() parser.add_option("-f", "--file", dest="bookfile", help="ICD Exel File ", metavar="FILE") parser.add_option("-d", "--dir", dest="basedir", default="./tmp", Loading @@ -63,51 +103,17 @@ if __name__ =="__main__": 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", parser.add_option("-i", "--install", dest="install", default=False, 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() excel_file =options.bookfile wb=excelIcd(excel_file) #tmp=wb.book.parse("Main") #smain=pd.DataFrame(data=tmp.loc[1:,tmp.columns].values,columns=tmp.loc[0,tmp.columns]) #print (smain) smain= wb.book.parse("Main") devs= smain['Device Name'] comp=smain['Component Name'] assembly=smain['Assembly'] outfile=[] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) outfile.append(outf) print("Working on files:",dev) mygen=genFromTemplates(outfile[-1],options.prefix,options.module,options.basedir) mygen.generateFileInDir() if options.install : build(mygen) os.chdir(pwd) else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) outf=manageICDFiles(devs[0],outdir,wb) mygen=genFromTemplates(outf,options.prefix,options.module,options.basedir) mygen.generateFileInDir() if options.install : build(mygen) os.chdir(pwd) removetmpfiles() config={} config['icdfile']=options.bookfile config['prefix']=options.prefix config['module']=options.module config['basedir']=options.basedir generateComponent(config,install=options.install) print ("ALL Done") os.chdir(pwd)