Loading test/genDevice.py +35 −34 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from GenDevice.acsUtils import * import pandas as pd import glob outdir="/tmp/" OUTDIR="/tmp/" gendir=os.environ["PYGEN"] if gendir=="": Loading @@ -22,38 +22,35 @@ if gendir=="": if not checkACS(): print ("ACS Enviroment is not set") exit() def generateComponent(config,install=False): def generateComponent(config): pwd=os.getcwd() wb=excelIcd(config['icdfile']) smain= wb.book.parse("Main") devs= smain['Device Name'] #comp=smain['Component Name'] assembly=smain['Assembly'] #outfile=[] devs= wb.MainSheet['Device Name'] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print ("The Assembly:"+wb.MainSheet['Assembly'][0]+" includes more than one device\n",devs) genMulti(wb,config) else: print ("The Assembly:"+wb.MainSheet['Assembly'][0]+" includes one device\n",devs) genSingle(wb,config) os.chdir(pwd) def genMulti(wb,config): for dev in wb.MainSheet['Device Name']: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) #outfile.append(outf) print("Working on files:",dev) outf=manageICDFiles(dev,OUTDIR,wb) print("Working on files:",outf) wb1=excelIcd(outf) mygen=genFromTemplates(wb1,outf,config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) config['icdfile']=outf genSingle(wb1,config) removetmpfiles() else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) #outf=manageICDFiles(devs[0],outdir,wb) def genSingle(wb,config): mygen=genFromTemplates(wb,config['icdfile'],config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() checkCDB(mygen) if install : if config['install'] : build(mygen) checkCDB(mygen) os.chdir(pwd) def manageICDFiles(dev,outdir,wb): query="`Device Name` =="+ "'"+dev+"'" Loading Loading @@ -103,17 +100,15 @@ def checkCDB(mygen): def removetmpfiles(): filelist = glob.glob(outdir+'*.xlsx') filelist = glob.glob(OUTDIR+'*.xlsx') for fil in filelist: try: os.remove(fil) except OSError as e: print ("Error: %s - %s." % (e.filename, e.strerror)) if __name__ =="__main__": def getInput(): 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 @@ -125,13 +120,19 @@ if __name__ =="__main__": 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) #print("running genDevice with the following options:\n", options) config={} config['icdfile']=options.bookfile config['prefix']=options.prefix config['module']=options.module config['basedir']=options.basedir generateComponent(config,install=options.install) config['install']=options.install return config if __name__ =="__main__": pwd=os.getcwd() config=getInput() generateComponent(config) print ("ALL Done") os.chdir(pwd) Loading Loading
test/genDevice.py +35 −34 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from GenDevice.acsUtils import * import pandas as pd import glob outdir="/tmp/" OUTDIR="/tmp/" gendir=os.environ["PYGEN"] if gendir=="": Loading @@ -22,38 +22,35 @@ if gendir=="": if not checkACS(): print ("ACS Enviroment is not set") exit() def generateComponent(config,install=False): def generateComponent(config): pwd=os.getcwd() wb=excelIcd(config['icdfile']) smain= wb.book.parse("Main") devs= smain['Device Name'] #comp=smain['Component Name'] assembly=smain['Assembly'] #outfile=[] devs= wb.MainSheet['Device Name'] if len(devs)>1 : print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs) for dev in devs: print ("The Assembly:"+wb.MainSheet['Assembly'][0]+" includes more than one device\n",devs) genMulti(wb,config) else: print ("The Assembly:"+wb.MainSheet['Assembly'][0]+" includes one device\n",devs) genSingle(wb,config) os.chdir(pwd) def genMulti(wb,config): for dev in wb.MainSheet['Device Name']: print("working On device:", dev) outf=manageICDFiles(dev,outdir,wb) #outfile.append(outf) print("Working on files:",dev) outf=manageICDFiles(dev,OUTDIR,wb) print("Working on files:",outf) wb1=excelIcd(outf) mygen=genFromTemplates(wb1,outf,config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() if install : build(mygen) config['icdfile']=outf genSingle(wb1,config) removetmpfiles() else: print ("the Assembly:"+assembly[0]+" includes one device\n",devs) #outf=manageICDFiles(devs[0],outdir,wb) def genSingle(wb,config): mygen=genFromTemplates(wb,config['icdfile'],config['prefix'],config['module'],config['basedir']) mygen.generateFileInDir() checkCDB(mygen) if install : if config['install'] : build(mygen) checkCDB(mygen) os.chdir(pwd) def manageICDFiles(dev,outdir,wb): query="`Device Name` =="+ "'"+dev+"'" Loading Loading @@ -103,17 +100,15 @@ def checkCDB(mygen): def removetmpfiles(): filelist = glob.glob(outdir+'*.xlsx') filelist = glob.glob(OUTDIR+'*.xlsx') for fil in filelist: try: os.remove(fil) except OSError as e: print ("Error: %s - %s." % (e.filename, e.strerror)) if __name__ =="__main__": def getInput(): 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 @@ -125,13 +120,19 @@ if __name__ =="__main__": 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) #print("running genDevice with the following options:\n", options) config={} config['icdfile']=options.bookfile config['prefix']=options.prefix config['module']=options.module config['basedir']=options.basedir generateComponent(config,install=options.install) config['install']=options.install return config if __name__ =="__main__": pwd=os.getcwd() config=getInput() generateComponent(config) print ("ALL Done") os.chdir(pwd) Loading