Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
6e5d093d
Commit
6e5d093d
authored
Sep 19, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configparser: minor refactoring.
parent
4e94a10e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
configparser.py
hdlmake/manifest_parser/configparser.py
+12
-17
No files found.
hdlmake/manifest_parser/configparser.py
View file @
6e5d093d
...
...
@@ -34,14 +34,12 @@ import contextlib
@
contextlib
.
contextmanager
def
stdout_io
(
stdout
=
None
):
def
capture_stdout
(
):
"""This is a function used to grab the stdout from
the executed Manifest.py files"""
old
=
sys
.
stdout
if
stdout
is
None
:
stdout
=
StringIO
()
sys
.
stdout
=
stdout
yield
stdout
sys
.
stdout
=
StringIO
()
yield
sys
.
stdout
sys
.
stdout
=
old
...
...
@@ -251,7 +249,7 @@ types:[<type 'int'>]
"""method that acts as an 'exec' wraper to run the Python code"""
options
=
{}
try
:
with
stdout_io
()
as
stdout_aux
:
with
capture_stdout
()
as
stdout_aux
:
root_path
=
os
.
getcwd
()
exec_path
=
os
.
path
.
dirname
(
self
.
config_file
)
os
.
chdir
(
exec_path
)
...
...
@@ -260,22 +258,19 @@ types:[<type 'int'>]
printed
=
stdout_aux
.
getvalue
()
if
len
(
printed
)
>
0
:
logging
.
info
(
"The manifest inside "
+
self
.
config_file
+
" tried to print something:"
)
"The manifest inside {} tried to print something:"
.
format
(
self
.
config_file
))
for
line
in
printed
.
split
(
'
\n
'
):
print
(
"> "
+
line
)
except
SyntaxError
as
error_syntax
:
raise
Exception
(
"Invalid syntax in the manifest file "
+
self
.
config_file
+
":
\n
"
+
str
(
error_syntax
)
+
content
)
raise
Exception
(
"Invalid syntax in the manifest file {}:
\n
{}{}"
.
format
(
self
.
config_file
,
str
(
error_syntax
),
content
))
except
SystemExit
as
error_exit
:
raise
Exception
(
"Exit requested by the manifest file "
+
self
.
config_file
+
":
\n
"
+
str
(
error_exit
)
+
content
)
raise
Exception
(
"Exit requested by the manifest file {}:
\n
{}{}"
.
format
(
self
.
config_file
,
str
(
error_exit
),
content
))
except
:
logging
.
error
(
"Encountered unexpected error while parsing
"
+
self
.
config_file
)
logging
.
error
(
"Encountered unexpected error while parsing
{}"
.
format
(
self
.
config_file
)
)
logging
.
error
(
content
)
print
(
str
(
sys
.
exc_info
()[
0
])
+
':'
+
str
(
sys
.
exc_info
()[
1
]))
raise
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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