FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ews-coordinator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab has been upgraded. See what's new in the
Changelog
.
Show more breadcrumbs
Gilligan Lab for Epidemiology and Modelling
Wheat rusts
ews-coordinator
Commits
84b68f99
Commit
84b68f99
authored
10 months ago
by
L. Bower
Browse files
Options
Downloads
Patches
Plain Diff
removing unused function
parent
74db142d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
coordinator/Processor.py
+42
-42
42 additions, 42 deletions
coordinator/Processor.py
with
42 additions
and
42 deletions
coordinator/Processor.py
+
42
−
42
View file @
84b68f99
...
...
@@ -216,48 +216,48 @@ class Processor:
}
def
move_default_logfile_handler
(
self
,
dstPathName
,
srcPathName
=
None
,
FileHandlerName
=
'
handler_file
'
,
):
'''
For on-the-fly move of logging from default file to another. Copies the
contents of the source log file to destination, switches file handler in
logger, then removes source log file.
'''
if
srcPathName
is
None
:
srcPathName
=
self
.
log_path_default
self
.
logger
.
info
(
f
"
Moving logfile location from:
\n
{
srcPathName
}
\n
to:
\n
{
dstPathName
}
"
)
# copy old log file to new filename
srcPath
=
Path
(
srcPathName
)
dstPath
=
Path
(
dstPathName
)
assert
srcPath
.
exists
()
assert
dstPath
.
parent
.
is_dir
()
oldFileHandler
=
[
h
for
h
in
self
.
logger
.
handlers
if
h
.
name
==
FileHandlerName
][
0
]
oldFormatter
=
oldFileHandler
.
formatter
# define new file handler
newfilehandler
=
logging
.
FileHandler
(
dstPath
,
mode
=
oldFileHandler
.
mode
)
newfilehandler
.
setLevel
(
oldFileHandler
.
level
)
newfilehandler
.
setFormatter
(
oldFormatter
)
shutil
.
copyfile
(
srcPath
,
dstPath
)
# add handler for destination file
self
.
logger
.
info
(
'
Adding new logging file handler to destination path
'
)
self
.
logger
.
addHandler
(
newfilehandler
)
# remove handler for source file
self
.
logger
.
info
(
'
Stopping write to old file handler
'
)
self
.
logger
.
removeHandler
(
oldFileHandler
)
oldFileHandler
.
close
()
self
.
logger
.
info
(
'
Successfully stopped write to old file handler
'
)
# delete old log file
self
.
logger
.
info
(
'
Deleting old log file, since all content available in new log file stream
'
)
os
.
rename
(
srcPathName
,
srcPathName
+
'
removed
'
)
return
#
def move_default_logfile_handler(self, dstPathName, srcPathName = None, FileHandlerName = 'handler_file', ):
#
'''For on-the-fly move of logging from default file to another. Copies the
#
contents of the source log file to destination, switches file handler in
#
logger, then removes source log file.'''
#
#
if srcPathName is None:
#
srcPathName = self.log_path_default
#
#
self.logger.info(f"Moving logfile location from:\n{srcPathName}\nto:\n{dstPathName}")
#
#
# copy old log file to new filename
#
srcPath = Path(srcPathName)
#
dstPath = Path(dstPathName)
#
assert srcPath.exists()
#
assert dstPath.parent.is_dir()
#
#
oldFileHandler = [h for h in self.logger.handlers if h.name == FileHandlerName][0]
#
oldFormatter = oldFileHandler.formatter
#
#
# define new file handler
#
newfilehandler = logging.FileHandler(dstPath, mode = oldFileHandler.mode)
#
newfilehandler.setLevel(oldFileHandler.level)
#
newfilehandler.setFormatter(oldFormatter)
#
#
shutil.copyfile(srcPath, dstPath)
#
#
# add handler for destination file
#
self.logger.info('Adding new logging file handler to destination path')
#
#
self.logger.addHandler(newfilehandler)
#
#
# remove handler for source file
#
self.logger.info('Stopping write to old file handler')
#
self.logger.removeHandler(oldFileHandler)
#
oldFileHandler.close()
#
self.logger.info('Successfully stopped write to old file handler')
#
#
# delete old log file
#
self.logger.info('Deleting old log file, since all content available in new log file stream')
#
os.rename(srcPathName, srcPathName + 'removed')
#
#
return
def
parse_and_check_args
(
self
)
->
dict
:
...
...
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