diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 43aecf8526..816d78f92d 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -132,9 +132,6 @@ class LogManager: def __init__(self, chunk): self.chunk = chunk - self.chunk.statusChanged.connect(self.clear) - self.progressBar = False - self.cleared = False self.logger = logging.getLogger(chunk.node.getName()) class Formatter(logging.Formatter): @@ -151,27 +148,22 @@ def configureLogger(self): handler.setFormatter(formatter) self.logger.addHandler(handler) - def clear(self): - if self.chunk.statusName == 'RUNNING' and not self.cleared: - open(self.chunk.logFile, 'w').close() - self.configureLogger() - self.cleared = True - # When the node gets ran again the log needs to be cleared - elif self.chunk.statusName in ['ERROR', 'SUCCESS']: - for handler in self.logger.handlers[:]: - # Stops the file being locked - handler.close() - self.cleared = False - self.progressBar = False - - def waitUntilCleared(self): - while not self.cleared: - time.sleep(0.01) + def start(self, level): + # Clear log file + open(self.chunk.logFile, 'w').close() + + self.configureLogger() + self.logger.setLevel(self.textToLevel(level)) + self.progressBar = False + + def end(self): + for handler in self.logger.handlers[:]: + # Stops the file being locked + handler.close() def makeProgressBar(self, end, message=''): assert end > 0 assert not self.progressBar - self.waitUntilCleared() self.progressEnd = end self.currentProgressTics = 0 @@ -194,7 +186,6 @@ def makeProgressBar(self, end, message=''): def updateProgressBar(self, value): assert self.progressBar assert value <= self.progressEnd - self.waitUntilCleared() tics = round((value/self.progressEnd)*51) diff --git a/meshroom/nodes/aliceVision/Publish.py b/meshroom/nodes/aliceVision/Publish.py index ebe2b9b832..447bd65d53 100644 --- a/meshroom/nodes/aliceVision/Publish.py +++ b/meshroom/nodes/aliceVision/Publish.py @@ -50,27 +50,29 @@ def resolvedPaths(self, inputFiles, outDir): return paths def processChunk(self, chunk): - chunk.logManager.waitUntilCleared() - chunk.logger.setLevel(chunk.logManager.textToLevel(chunk.node.verboseLevel.value)) - - if not chunk.node.inputFiles: - chunk.logger.warning('Nothing to publish') - return - if not chunk.node.output.value: - return + try: + chunk.logManager.start(chunk.node.verboseLevel.value) + + if not chunk.node.inputFiles: + chunk.logger.warning('Nothing to publish') + return + if not chunk.node.output.value: + return - outFiles = self.resolvedPaths(chunk.node.inputFiles.value, chunk.node.output.value) + outFiles = self.resolvedPaths(chunk.node.inputFiles.value, chunk.node.output.value) - if not outFiles: - error = 'Publish: input files listed, but nothing to publish' - chunk.logger.error(error) - chunk.logger.info('Listed input files: {}'.format([i.value for i in chunk.node.inputFiles.value])) - raise RuntimeError(error) + if not outFiles: + error = 'Publish: input files listed, but nothing to publish' + chunk.logger.error(error) + chunk.logger.info('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) + if not os.path.exists(chunk.node.output.value): + os.mkdir(chunk.node.output.value) - for iFile, oFile in outFiles.items(): - chunk.logger.info('Publish file {} into {}'.format(iFile, oFile)) - shutil.copyfile(iFile, oFile) - chunk.logger.info('Publish end') + for iFile, oFile in outFiles.items(): + chunk.logger.info('Publish file {} into {}'.format(iFile, oFile)) + shutil.copyfile(iFile, oFile) + chunk.logger.info('Publish end') + finally: + chunk.logManager.end() diff --git a/meshroom/nodes/aliceVision/SketchfabUpload.py b/meshroom/nodes/aliceVision/SketchfabUpload.py index 2a552b879c..27bea2fb28 100644 --- a/meshroom/nodes/aliceVision/SketchfabUpload.py +++ b/meshroom/nodes/aliceVision/SketchfabUpload.py @@ -216,31 +216,31 @@ def stopped(self): return self._stopped def processChunk(self, chunk): - self._stopped = False - chunk.logManager.waitUntilCleared() - chunk.logger.setLevel(chunk.logManager.textToLevel(chunk.node.verboseLevel.value)) + try: + self._stopped = False + chunk.logManager.start(chunk.node.verboseLevel.value) + uploadFile = '' - if not chunk.node.inputFiles: - chunk.logger.warning('Nothing to upload') - return - if chunk.node.apiToken.value == '': - chunk.logger.error('Need API token.') - raise RuntimeError() - if len(chunk.node.title.value) > 48: - chunk.logger.error('Title cannot be longer than 48 characters.') - raise RuntimeError() - if len(chunk.node.description.value) > 1024: - chunk.logger.error('Description cannot be longer than 1024 characters.') - raise RuntimeError() - tags = [ i.value.replace(' ', '-') for i in chunk.node.tags.value.values() ] - if all(len(i) > 48 for i in tags) and len(tags) > 0: - chunk.logger.error('Tags cannot be longer than 48 characters.') - raise RuntimeError() - if len(tags) > 42: - chunk.logger.error('Maximum of 42 separate tags.') - raise RuntimeError() + if not chunk.node.inputFiles: + chunk.logger.warning('Nothing to upload') + return + if chunk.node.apiToken.value == '': + chunk.logger.error('Need API token.') + raise RuntimeError() + if len(chunk.node.title.value) > 48: + chunk.logger.error('Title cannot be longer than 48 characters.') + raise RuntimeError() + if len(chunk.node.description.value) > 1024: + chunk.logger.error('Description cannot be longer than 1024 characters.') + raise RuntimeError() + tags = [ i.value.replace(' ', '-') for i in chunk.node.tags.value.values() ] + if all(len(i) > 48 for i in tags) and len(tags) > 0: + chunk.logger.error('Tags cannot be longer than 48 characters.') + raise RuntimeError() + if len(tags) > 42: + chunk.logger.error('Maximum of 42 separate tags.') + raise RuntimeError() - try: data = { 'name': chunk.node.title.value, 'description': chunk.node.description.value, @@ -276,5 +276,7 @@ def processChunk(self, chunk): os.remove(uploadFile) chunk.logger.debug('Deleted {}'.format(uploadFile)) + chunk.logManager.end() + def stopProcess(self, chunk): self._stopped = True diff --git a/setup.py b/setup.py index 4bbe3df2fb..c14ed6b26b 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,9 @@ def __init__(self, script, initScript=None, base=None, targetName=None, icons=No build_exe_options = { # include dynamically loaded plugins "packages": ["meshroom.nodes", "meshroom.submitters"], + "includes": [ + "idna.idnadata", # Dependency needed by SketchfabUpload node, but not detected by cx_Freeze + ], "include_files": ["CHANGES.md", "COPYING.md", "LICENSE-MPL2.md", "README.md"] }