def showOutput(self): while type(self.channel) is type(None) and self.flowRunning: time.sleep(1) try: while self.flowRunning: for block in self.myCore.getBlocksByType('txt'): block = Block(block) if block.getMetadata('ch') != self.channel: #print('not chan', block.getMetadata('ch')) continue if block.getHash() in self.alreadyOutputed: #print('already') continue if not self.flowRunning: break logger.info('\n------------------------', prompt=False) content = block.getContent() # Escape new lines, remove trailing whitespace, and escape ansi sequences content = self.myCore._utils.escapeAnsi( content.replace('\n', '\\n').replace('\r', '\\r').strip()) logger.info(block.getDate().strftime("%m/%d %H:%M") + ' - ' + logger.colors.reset + content, prompt=False) self.alreadyOutputed.append(block.getHash()) time.sleep(5) except KeyboardInterrupt: self.flowRunning = False
def installBlock(block): try: block = Block(block, core = pluginapi.get_core()) blockContent = json.loads(block.getContent()) name = sanitize(blockContent['name']) author = blockContent['author'] date = blockContent['date'] version = None if 'version' in blockContent['info']: version = blockContent['info']['version'] install = False logger.info(('Will install %s' + (' v' + version if not version is None else '') + ' (%s), by %s') % (name, date, author)) # TODO: Convert to single line if statement if os.path.exists(pluginapi.plugins.get_folder(name)): install = logger.confirm(message = 'Continue with installation (will overwrite existing plugin) %s?') else: install = logger.confirm(message = 'Continue with installation %s?') if install: blockToPlugin(block.getHash()) addPlugin(name) else: logger.info('Installation cancelled.') return False return True except Exception as e: logger.error('Failed to install plugin.', error = e, timestamp = False) return False