Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gino Tosti
pygen
Commits
1d22239b
Commit
1d22239b
authored
Jun 28, 2021
by
Gino Tosti
Browse files
refactored genDevice
parent
26fe907a
Changes
1
Show whitespace changes
Inline
Side-by-side
test/genDevice.py
View file @
1d22239b
...
...
@@ -11,6 +11,46 @@ from GenDevice.genFromTemplates import genFromTemplates
from
GenDevice.createEmptyCDB
import
*
from
GenDevice.acsUtils
import
*
import
pandas
as
pd
import
glob
outdir
=
"/tmp/"
def
manageICDFiles
(
dev
,
outdir
,
smain
,
wb
):
query
=
"`Device Name` =="
+
"'"
+
dev
+
"'"
main
=
smain
.
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
=
outdir
+
dev
+
".xlsx"
with
pd
.
ExcelWriter
(
outfile
)
as
writer
:
main
.
to_excel
(
writer
,
sheet_name
=
'Main'
,
index
=
False
)
get
.
to_excel
(
writer
,
sheet_name
=
'GET'
,
index
=
False
)
sett
.
to_excel
(
writer
,
sheet_name
=
'SET'
,
index
=
False
)
cmd
.
to_excel
(
writer
,
sheet_name
=
'CMD'
,
index
=
False
)
mode
.
to_excel
(
writer
,
sheet_name
=
'MODE'
,
index
=
False
)
return
outfile
def
build
(
mygen
):
introot
=
os
.
environ
[
"INTROOT"
]
if
introot
==
""
:
print
(
"INTROOT variable is not set"
)
else
:
os
.
chdir
(
mygen
.
_dirs
[
'src'
])
print
(
"Make Build "
)
command
=
"make clean all"
print
(
command
)
if
execACSCommand
(
command
):
print
(
"ERROR executing: "
,
command
)
def
removetmpfiles
():
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__"
:
parser
=
OptionParser
()
...
...
@@ -45,56 +85,29 @@ if __name__ =="__main__":
devs
=
smain
[
'Device Name'
]
comp
=
smain
[
'Component Name'
]
assembly
=
smain
[
'Assembly'
]
outdir
=
"/media/sf_Desktop/Useful_SW/"
outfile
=
[]
if
len
(
assembly
)
>
1
:
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
)
query
=
"`Device Name` =="
+
"'"
+
dev
+
"'"
main
=
smain
.
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'
,
index
=
False
)
get
.
to_excel
(
writer
,
sheet_name
=
'GET'
,
index
=
False
)
sett
.
to_excel
(
writer
,
sheet_name
=
'SET'
,
index
=
False
)
cmd
.
to_excel
(
writer
,
sheet_name
=
'CMD'
,
index
=
False
)
mode
.
to_excel
(
writer
,
sheet_name
=
'MODE'
,
index
=
False
)
outf
=
manageICDFiles
(
dev
,
outdir
,
smain
,
wb
)
outfile
.
append
(
outf
)
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"
)
else
:
os
.
chdir
(
mygen
.
_dirs
[
'src'
])
print
(
"Make Build "
)
command
=
"make clean all"
print
(
command
)
if
execACSCommand
(
command
):
print
(
"ERROR executing: "
,
command
)
build
(
mygen
)
os
.
chdir
(
pwd
)
else
:
print
(
"the Assembly:"
+
assembly
[
0
]
+
" includes one device
\n
"
,
devs
)
mygen
=
genFromTemplates
(
options
.
bookfile
,
options
.
prefix
,
options
.
module
,
options
.
basedir
)
outf
=
manageICDFiles
(
devs
[
0
],
outdir
,
smain
,
wb
)
mygen
=
genFromTemplates
(
outf
,
options
.
prefix
,
options
.
module
,
options
.
basedir
)
mygen
.
generateFileInDir
()
if
options
.
install
:
introot
=
os
.
environ
[
"INTROOT"
]
if
introot
==
""
:
print
(
"INTROOT variable is not set"
)
else
:
os
.
chdir
(
mygen
.
_dirs
[
'src'
])
print
(
"Make Build "
)
command
=
"make clean all"
print
(
command
)
if
execACSCommand
(
command
):
print
(
"ERROR executing: "
,
command
)
build
(
mygen
)
os
.
chdir
(
pwd
)
removetmpfiles
()
print
(
"ALL Done"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment