-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log manager for Python based nodes #631
Merged
fabiencastan
merged 8 commits into
alicevision:develop
from
ChemicalXandco:python_logging
Jan 25, 2020
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3de9f7d
Merge pull request #4 from alicevision/develop
ChemicalXandco ad486e0
add LogManager class
ChemicalXandco 4dfd13c
intergrate python logging into publish node
ChemicalXandco 87da9bf
[nodes] Publish: update version to 1.2
ChemicalXandco 5ef33ef
rely on standard logging object
ChemicalXandco cd5beab
expose verbose level on Publish node
ChemicalXandco 17ecf78
use logger object directly
ChemicalXandco 749fc15
more reliable way to find progress bar position in log file
ChemicalXandco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
from __future__ import print_function | ||
|
||
__version__ = "1.1" | ||
__version__ = "1.2" | ||
|
||
from meshroom.core import desc | ||
import shutil | ||
import glob | ||
import os | ||
import logging | ||
|
||
|
||
class Publish(desc.Node): | ||
|
@@ -30,6 +31,15 @@ class Publish(desc.Node): | |
description="", | ||
value="", | ||
uid=[0], | ||
), | ||
desc.ChoiceParam( | ||
name='verboseLevel', | ||
label='Verbose Level', | ||
description='''verbosity level (critical, error, warning, info, debug).''', | ||
value='info', | ||
values=['critical', 'error', 'warning', 'info', 'debug'], | ||
exclusive=True, | ||
uid=[], | ||
), | ||
] | ||
|
||
|
@@ -41,23 +51,26 @@ def resolvedPaths(self, inputFiles, outDir): | |
return paths | ||
|
||
def processChunk(self, chunk): | ||
print("Publish") | ||
chunk.log.logger.setLevel(chunk.log.textToLevel(chunk.node.verboseLevel.value)) | ||
|
||
if not chunk.node.inputFiles: | ||
print("Nothing to publish") | ||
chunk.log.add('Nothing to publish', logging.WARNING) | ||
return | ||
if not chunk.node.output.value: | ||
return | ||
|
||
outFiles = self.resolvedPaths(chunk.node.inputFiles.value, chunk.node.output.value) | ||
|
||
if not outFiles: | ||
raise RuntimeError("Publish: input files listed, but nothing to publish. " | ||
"Listed input files: {}".format(chunk.node.inputFiles.value)) | ||
error = 'Publish: input files listed, but nothing to publish' | ||
chunk.log.add(error, logging.ERROR) | ||
chunk.log.add('Listed input files: {}'.format([i.value for i in chunk.node.inputFiles.value])) | ||
raise RuntimeError(error) | ||
|
||
if not os.path.exists(chunk.node.output.value): | ||
os.mkdir(chunk.node.output.value) | ||
|
||
for iFile, oFile in outFiles.items(): | ||
print('Publish file', iFile, 'into', oFile) | ||
chunk.log.add('Publish file {} into {}'.format(iFile, oFile)) | ||
shutil.copyfile(iFile, oFile) | ||
print('Publish end') | ||
chunk.log.add('Publish end') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have called the property
logger
instead oflogging
because it makes more sense imo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I agree.