Ejemplo n.º 1
0
def main():
    session = database.make_session()
    try:
        print "WARNING: DO NOT RUN WHILE SPUTNIK IS RUNNING. SHUT EVERYTHING DOWN FIRST"
        leo = LowEarthOrbit(session)
        if len(sys.argv) == 1:
            try:
                while True:
                    leo.parse(raw_input("leo> "))
            except EOFError:
                pass
        else:
            leo.parse(" ".join(sys.argv[1:]))

        # Before committing run a sanity check on all contracts
        contracts = session.query(models.Contract)
        failures = [contract.ticker for contract in contracts if not contract.sanity_check]
        if len(failures):
            print "CONTRACTS FAILED SANITY CHECK"
            print failures
            session.rollback()
        else:
            session.commit()

    except Exception, e:
        print e
        session.rollback()
	raise e
Ejemplo n.º 2
0
def main():
    session = database.make_session()
    try:
        print "WARNING: DO NOT RUN WHILE SPUTNIK IS RUNNING. SHUT EVERYTHING DOWN FIRST"
        leo = LowEarthOrbit(session)
        if len(sys.argv) == 1:
            try:
                while True:
                    leo.parse(raw_input("leo> "))
            except EOFError:
                pass
        else:
            leo.parse(" ".join(sys.argv[1:]))

        # Before committing run a sanity check on all contracts
        contracts = session.query(models.Contract)
        failures = [
            contract.ticker for contract in contracts
            if not contract.sanity_check
        ]
        if len(failures):
            print "CONTRACTS FAILED SANITY CHECK"
            print failures
            session.rollback()
        else:
            session.commit()

    except Exception, e:
        print e
        session.rollback()
        raise e
Ejemplo n.º 3
0
    def setUp(self):
        logging.basicConfig(format='%(asctime)s - %(levelname)s - %(funcName)s() %(lineno)d:\t %(message)s',
                            level=logging.DEBUG)
        os.chdir(os.path.dirname(os.path.abspath(__file__)))
        fix_config()

        from sputnik import database, models

        self.session = database.make_session()

        import leo

        self.leo = leo.LowEarthOrbit(self.session)
        self.run_leo(db_init)
Ejemplo n.º 4
0
from sputnik import config
from sputnik import database, models, util
from datetime import datetime
from sqlalchemy.orm.exc import NoResultFound
import time

parser = argparse.ArgumentParser(description="Audit the ledger")
parser.add_argument("-a",
                    "--adjust",
                    dest="adjust",
                    action="store_true",
                    help="should we adjust positions",
                    default=False)

kwargs = vars(parser.parse_args())
session = database.make_session()

adjust = kwargs['adjust']

if adjust:
    print "BE SURE EVERYTHING IS SHUT BEFORE RUNNING THIS PROGRAM"
    time.sleep(30)

# Go through journal entries
journals = session.query(models.Journal)
total = journals.count()
print "%d journals to cover" % total
count = 0
for journal in journals:
    print "%d/%d" % (count, total)
    if not journal.audit:
from sqlalchemy.orm.exc import NoResultFound
import sys
import os

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
    "../server"))
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
    "../dist/config"))

from sputnik import database, models
from sputnik import txbitcoinrpc
import getpass
from sputnik import config
from twisted.internet import defer, reactor, task

db_session = database.make_session(username=getpass.getuser())
print config.get("cashier","bitcoin_conf")
conn = txbitcoinrpc.BitcoinRpc(config.get("cashier", "bitcoin_conf"))

#conn.walletpassphrase('pass',10, dont_raise=True)
count = 0
def go():
    d = conn.keypoolrefill()

    def get_addresses(result):
        quantity = 100

        dl = defer.DeferredList([conn.getnewaddress() for i in range(quantity)])

        def add_addresses(results):
            for r in results:
Ejemplo n.º 6
0
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
    "../server"))

from sputnik import config
from sputnik import database, models, util
from datetime import datetime
from sqlalchemy.orm.exc import NoResultFound
import time

parser = argparse.ArgumentParser(description="Audit the ledger")
parser.add_argument("-a", "--adjust", dest="adjust", action="store_true",
                    help="should we adjust positions", default=False)

kwargs = vars(parser.parse_args())
session = database.make_session()

adjust = kwargs['adjust']

if adjust:
    print "BE SURE EVERYTHING IS SHUT BEFORE RUNNING THIS PROGRAM"
    time.sleep(30)

# Go through journal entries
journals = session.query(models.Journal)
total = journals.count()
print "%d journals to cover" % total
count = 0
for journal in journals:
    print "%d/%d" % (count, total)
    if not journal.audit: