def __init__(self): super(Account, self).__init__() self.api_helper = APIServer() self.tt_helper = TumServer() from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.tt_helper.setTest(True)
def __init__(self, wallet): super(Operation, self).__init__() self.src_address = wallet.address self.src_secret = wallet.secret self.is_sync = False self.client_resource_id = self.getNextUUID() self.api_helper = APIServer() from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.validateAddress(self.src_address)
class Operation(object): def __init__(self, wallet): super(Operation, self).__init__() self.src_address = wallet.address self.src_secret = wallet.secret self.is_sync = False self.client_resource_id = self.getNextUUID() self.api_helper = APIServer() from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.validateAddress(self.src_address) def getNextUUID(self): return FinGate.getNextUUID() def validateAddress(self, address): if not JingtumBaseDecoder.verify_checksum( JingtumBaseDecoder.decode_base(address, 25)): raise JingtumOperException("Invalid address: %s" % str(address)) def submit(self, callback=None): #print self.oper() from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) if callback is None: return self.api_helper.post(*self.oper(), callback=callback) else: self.api_helper.postasyn(*self.oper(), callback=callback) return None # def addSrcSecret(self, src_secret): # self.src_secret = src_secret def setValidate(self, is_sync): self.is_sync = is_sync def setClientId(self, client_resource_id): self.client_resource_id = client_resource_id
def go(self): utils.fix_output_encoding() self.apiServer = None #Configure logging # root level logger = logging.getLogger() logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') log_file = os.path.join(AppFolders.logs(), "ComicStreamer.log") if not os.path.exists(os.path.dirname(log_file)): os.makedirs(os.path.dirname(log_file)) fh = logging.handlers.RotatingFileHandler(log_file, maxBytes=1048576, backupCount=4, encoding="UTF8") fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) # By default only do info level to console sh = logging.StreamHandler(sys.stdout) sh.setLevel(logging.INFO) sh.setFormatter(formatter) logger.addHandler(sh) config = ComicStreamerConfig() opts = Options() opts.parseCmdLineArgs() # set file logging according to config file #fh.setLevel(config['general']['loglevel']) # turn up the log level, if requested if opts.debug: sh.setLevel(logging.DEBUG) elif opts.quiet: sh.setLevel(logging.CRITICAL) config.applyOptions(opts) self.apiServer = APIServer(config, opts) self.apiServer.logFileHandler = fh self.apiServer.logConsoleHandler = sh signal.signal(signal.SIGINT, self.signal_handler) bonjour = BonjourThread(self.apiServer.port) bonjour.start() if getattr(sys, 'frozen', None): # A frozen app will run a GUI self.apiServer.runInThread() logging.info("starting GUI loop") if platform.system() == "Darwin": from gui_mac import MacGui MacGui(self.apiServer).run() elif platform.system() == "Windows": from gui_win import WinGui WinGui(self.apiServer).run() self.apiServer.shutdown() else: #from gui_qt import QtBasedGui #self.apiServer.runInThread() #QtBasedGui(self.apiServer).run() #self.apiServer.shutdown() self.apiServer.run() logging.info("gui shoudld be done now")
def go(self): utils.fix_output_encoding() self.apiServer = None opts = Options() opts.parseCmdLineArgs() #Configure logging # root level logger = logging.getLogger() logger.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s') log_file = os.path.join(AppFolders.logs(), "ComicStreamer.log") if not os.path.exists(os.path.dirname(log_file)): os.makedirs(os.path.dirname(log_file)) fh = logging.handlers.RotatingFileHandler(log_file, maxBytes=1048576, backupCount=4, encoding="UTF8") fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) # By default only do info level to console sh = logging.StreamHandler(sys.stdout) sh.setLevel(logging.INFO) sh.setFormatter(formatter) logger.addHandler(sh) # set file logging according to config file #fh.setLevel(config['general']['loglevel']) # turn up the log level, if requested if opts.debug: sh.setLevel(logging.DEBUG) elif opts.quiet: sh.setLevel(logging.CRITICAL) config = ComicStreamerConfig() config.applyOptions(opts) self.apiServer = APIServer(config, opts) self.apiServer.logFileHandler = fh self.apiServer.logConsoleHandler = sh signal.signal(signal.SIGINT, self.signal_handler) if getattr(sys, 'frozen', None): # A frozen app will run a GUI self.apiServer.runInThread() logging.debug("UI: Started") if platform.system() == "Darwin": from gui_mac import MacGui MacGui(self.apiServer).run() elif platform.system() == "Windows": from gui_win import WinGui WinGui(self.apiServer).run() self.apiServer.shutdown() else: #from gui_qt import QtBasedGui #self.apiServer.runInThread() #QtBasedGui(self.apiServer).run() #self.apiServer.shutdown() self.apiServer.run() logging.info("UI: Stopped")
class Account(Server): def __init__(self): super(Account, self).__init__() self.api_helper = APIServer() self.tt_helper = TumServer() from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.tt_helper.setTest(True) def get(self, url, para, callback=None, cb_para=None): from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.tt_helper.setTest(True) if callback is None: return self.api_helper.get(url, para) else: self.api_helper.getasyn(url, para, callback=callback, cb_para=cb_para) return None def tt_send(self, *para): from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.tt_helper.setTest(True) return self.tt_helper.send(*para) def submit(self, url, para, callback=None): from server import g_test_evn if g_test_evn: self.api_helper.setTest(True) self.tt_helper.setTest(True) if callback is None: return self.api_helper.post(url, para, callback=callback) else: self.api_helper.postasyn(url, para, callback=callback) return None