Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
synnefo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
synnefo
Commits
44d64bb1
Commit
44d64bb1
authored
11 years ago
by
Ilias Tsitsimpis
Browse files
Options
Downloads
Patches
Plain Diff
Burnin: Small code refactoring
parent
eb523a67
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snf-tools/synnefo_tools/burnin/logger.py
+16
-15
16 additions, 15 deletions
snf-tools/synnefo_tools/burnin/logger.py
with
16 additions
and
15 deletions
snf-tools/synnefo_tools/burnin/logger.py
+
16
−
15
View file @
44d64bb1
...
@@ -245,18 +245,6 @@ class Log(object):
...
@@ -245,18 +245,6 @@ class Log(object):
assert
output_dir
assert
output_dir
# Create file for logging
output_dir
=
os
.
path
.
expanduser
(
output_dir
)
if
not
os
.
path
.
exists
(
output_dir
):
self
.
debug
(
None
,
"
Creating directory %s
"
,
output_dir
)
try
:
os
.
makedirs
(
output_dir
)
except
OSError
as
err
:
msg
=
(
"
Failed to create folder
\"
%s
\"
with error: %s
\n
"
%
(
output_dir
,
err
))
sys
.
stderr
.
write
(
msg
)
sys
.
exit
(
"
Failed to create log folder
"
)
if
curr_time
is
None
:
if
curr_time
is
None
:
curr_time
=
datetime
.
datetime
.
now
()
curr_time
=
datetime
.
datetime
.
now
()
timestamp
=
datetime
.
datetime
.
strftime
(
timestamp
=
datetime
.
datetime
.
strftime
(
...
@@ -267,16 +255,29 @@ class Log(object):
...
@@ -267,16 +255,29 @@ class Log(object):
self
.
_write_to_stdout
(
None
,
"
Starting burnin with id %s
\n
"
%
timestamp
)
self
.
_write_to_stdout
(
None
,
"
Starting burnin with id %s
\n
"
%
timestamp
)
# Create the logging file
# Create the logging file
self
.
_create_logging_file
(
timestamp
)
self
.
_create_logging_file
(
timestamp
,
output_dir
)
def
_create_logging_file
(
self
,
timestamp
):
def
_create_logging_file
(
self
,
timestamp
,
output_dir
):
"""
Create the logging file
"""
"""
Create the logging file
"""
if
self
.
log_level
>
1
:
if
self
.
log_level
>
1
:
return
return
# Create file for logging
output_dir
=
os
.
path
.
expanduser
(
output_dir
)
if
not
os
.
path
.
exists
(
output_dir
):
self
.
debug
(
None
,
"
Creating directory %s
"
,
output_dir
)
try
:
os
.
makedirs
(
output_dir
)
except
OSError
as
err
:
msg
=
(
"
Failed to create folder
\"
%s
\"
with error: %s
\n
"
%
(
output_dir
,
err
))
sys
.
stderr
.
write
(
msg
)
sys
.
exit
(
"
Failed to create log folder
"
)
self
.
debug
(
None
,
"
Using
\"
%s
\"
file for logging
"
,
self
.
file_location
)
self
.
debug
(
None
,
"
Using
\"
%s
\"
file for logging
"
,
self
.
file_location
)
with
open
(
self
.
file_location
,
'
w
'
)
as
out_file
:
with
open
(
self
.
file_location
,
'
w
'
)
as
out_file
:
out_file
.
write
(
SECTION_SEPARATOR
+
"
\n
"
)
out_file
.
write
(
SECTION_SEPARATOR
+
"
\n
"
)
out_file
.
write
(
"
%s%s
(
%s
)
:
\n\n\n\n
"
%
out_file
.
write
(
"
%s%s
with id
%s:
\n\n\n\n
"
%
(
SECTION_PREFIX
,
SECTION_RUNNED
,
timestamp
))
(
SECTION_PREFIX
,
SECTION_RUNNED
,
timestamp
))
out_file
.
write
(
SECTION_SEPARATOR
+
"
\n
"
)
out_file
.
write
(
SECTION_SEPARATOR
+
"
\n
"
)
out_file
.
write
(
"
%s%s:
\n\n
"
%
(
SECTION_PREFIX
,
SECTION_RESULTS
))
out_file
.
write
(
"
%s%s:
\n\n
"
%
(
SECTION_PREFIX
,
SECTION_RESULTS
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment