def get_wallet_info(wallet): """ Add some info to a wallet object """ info = cache.get('walletinfo%d' % wallet.id) if info == None: try: conn = connection.get_connection(wallet) info = conn.getinfo() except socket.error, v: # pragma: no cover if v[0] == errno.ECONNREFUSED: info = False flash(u"%s: Connection refused" % wallet.label, 'error') elif v[0] == errno.ECONNRESET: info = False flash(u"%s: Connection reset" % wallet.label, 'error') elif v[0] == errno.EHOSTUNREACH: info = False flash(u"%s: Host unreachable" % wallet.label, 'error') elif v[0] == -2: # WTF info = False flash(u"%s: Unknown error" % wallet.label, 'error') #elif type(v) == socket.cachetime: # info = False # flash(u"%s: cachetime" % wallet.label, 'error') else: print v[0] print dir(v) print type(v) flash(u"Unhandled exception!", 'error') except ValueError: # pragma: no cover info = False flash(u"%s: Auth error (?)" % wallet.label, 'error')
def setUpModule(): init_db() ctx = app.test_request_context() ctx.push() wallet1 = Wallet( 'box1', 'admin1', '123', 'localhost', 19001, False, True, ) wallet2 = Wallet( 'box2', 'admin2', '123', 'localhost', 19011, False, True, ) session.add(wallet1) session.add(wallet2) session.commit() # DONTFIXME encryption should be done through the webapp # Actually, no, this can't be done as it makes the daemon stop.. # Unless we let this code restart it... conn = get_connection(wallet2) info = conn.getinfo() if not hasattr(info, 'unlocked_until'): conn.encryptwallet(pp) else: # Unlock and refill the keypool conn.walletpassphrase(pp, 1) conn.keypoolrefill()
def setUpClass(cls): cls.client = app.test_client() cls.wallet = Wallet.query.filter(Wallet.label=='box1').first() cls.conn = get_connection(cls.wallet) cls.account = 'testaccount-%s' % datetime.datetime.now().isoformat() cls.info = cls.conn.getinfo()
def dispatch_request(self, id): super(WalletConnectedBase, self).dispatch_request(id) self.conn = connection.get_connection(self.wallet)
def setUpClass(cls): cls.client = app.test_client() cls.wallet = Wallet.query.filter(Wallet.label == 'box1').first() cls.conn = get_connection(cls.wallet) cls.account = 'testaccount-%s' % datetime.datetime.now().isoformat() cls.info = cls.conn.getinfo()