def on_start(cmd: pcmd.Command, args: List[str]) -> None: """Callback for `start` - starts the channel""" global ch if ch.is_alive(): utils.printwrn('Already running ... ') return ch = Channel(ch.transf, ch.ist, ch.ost) try: ch.start() except IOError as e: utils.printerr(e)
def on_start(cmd: pcmd.Command, args: List[str], json: bool) -> None: """Callback for `start` - starts the channel""" global ch if ch.is_alive(): if not json: utils.printwrn('Already running ... ') else: print(JSON.dumps({ 'error': 'Already running ... ', })) return ch = Channel(ch.transf, ch.ist, ch.ost) server.ch = ch try: ch.start() if json: print(JSON.dumps({})) except IOError as e: if not json: utils.printerr(e) else: print(JSON.dumps({ 'error': str(e), }))