def create_layers(context, num_layers):
    layers = []
    for i in range(num_layers):
        db_path = get_db_path(i)
        setup_db(db_path)
        # dev_mode is True because otherwise the layer's ip is set to the
        # public ip of the node
        layers.append(CryptoTransportLayer(ip_address(i), port, i,
                                           Obdb(db_path), dev_mode=True))
    context.layers = layers
Exemplo n.º 2
0
def create_layers(context, num_layers):
    layers = []

    for i in range(num_layers):
        # dev_mode is True because otherwise the layer's ip is set to the
        # public ip of the node
        ob_ctx = OpenBazaarContext.create_default_instance()
        ob_ctx.dev_mode = True
        ob_ctx.server_ip = ip_address(i)
        ob_ctx.server_port = port
        db_path = get_db_path(i)
        setup_db(db_path, ob_ctx.disable_sqlite_crypt)
        layers.append(CryptoTransportLayer(ob_ctx, Obdb(db_path)))
    context.layers = layers
Exemplo n.º 3
0
def create_layers(context, num_layers):
    layers = []

    for i in range(num_layers):
        # dev_mode is True because otherwise the layer's ip is set to the
        # public ip of the node
        ob_ctx = OpenBazaarContext.create_default_instance()
        ob_ctx.dev_mode = True
        ob_ctx.server_ip = ip_address(i)
        ob_ctx.server_port = PORT
        db_path = get_db_path(i)
        setup_db(db_path, ob_ctx.disable_sqlite_crypt)
        layers.append(CryptoTransportLayer(ob_ctx, Obdb(db_path)))
    context.layers = layers
def create_layers(context, num_layers):
    layers = []
    for i in range(num_layers):
        db_path = get_db_path(i)
        setup_db(db_path)
        # dev_mode is True because otherwise the layer's ip is set to the
        # public ip of the node
        layers.append(
            CryptoTransportLayer(ip_address(i),
                                 port,
                                 i,
                                 Obdb(db_path),
                                 dev_mode=True))
    context.layers = layers
Exemplo n.º 5
0
def ensure_database_setup(ob_ctx, defaults):
    db_path = ob_ctx.db_path
    default_db_path = os.path.join(defaults['db_dir'], defaults['db_file'])
    default_dev_db_path = os.path.join(defaults['db_dir'],
                                       defaults['dev_db_file'])

    if ob_ctx.dev_mode and db_path == default_db_path:
        # override default db_path to developer database path.
        db_path = default_dev_db_path

    # make sure the folder exists wherever it is
    db_dirname = os.path.dirname(db_path)
    if not os.path.exists(db_dirname):
        os.makedirs(db_dirname, 0o755)

    if not os.path.exists(db_path):
        # setup the database if file not there.
        print "[openbazaar] bootstrapping database ", os.path.basename(db_path)
        setup_db.setup_db(db_path, ob_ctx.disable_sqlite_crypt)
        print "[openbazaar] database setup completed\n"
Exemplo n.º 6
0
def ensure_database_setup(ob_ctx, defaults):
    db_path = ob_ctx.db_path
    default_db_path = os.path.join(defaults['db_dir'], defaults['db_file'])
    default_dev_db_path = os.path.join(defaults['db_dir'],
                                       defaults['dev_db_file'])

    if ob_ctx.dev_mode and db_path == default_db_path:
        # override default db_path to developer database path.
        db_path = default_dev_db_path

    # make sure the folder exists wherever it is
    db_dirname = os.path.dirname(db_path)
    if not os.path.exists(db_dirname):
        os.makedirs(db_dirname, 0o755)

    if not os.path.exists(db_path):
        # setup the database if file not there.
        print "[openbazaar] bootstrapping database ", os.path.basename(db_path)
        setup_db.setup_db(db_path, ob_ctx.disable_sqlite_crypt)
        print "[openbazaar] database setup completed\n"
Exemplo n.º 7
0
def setUpModule():
    # Create a test db.
    if not os.path.isfile(TEST_DB_PATH):
        print "Creating test db: %s" % TEST_DB_PATH
        setup_db(TEST_DB_PATH)
Exemplo n.º 8
0
def setUpModule():
    # Create a test db.
    if not os.path.isfile(TEST_DB_PATH):
        print "Creating test db: %s" % TEST_DB_PATH
        setup_db(TEST_DB_PATH)
Exemplo n.º 9
0
 def setup_db(cls):
     setup_db.setup_db(
         cls.db_path,
         disable_sqlite_crypt=cls.disable_sqlite_crypt
     )
Exemplo n.º 10
0
 def setup_db(cls):
     setup_db.setup_db(cls.db_path,
                       disable_sqlite_crypt=cls.disable_sqlite_crypt)
Exemplo n.º 11
0
 def test_setup_existing(self):
     _, self.db_path = tempfile.mkstemp(suffix='.db')
     setup_db.setup_db(self.db_path, disable_sqlite_crypt=True)
Exemplo n.º 12
0
 def test_setup_db_nocrypt(self):
     setup_db.setup_db(self.db_path, disable_sqlite_crypt=True)
Exemplo n.º 13
0
 def test_setup_db(self):
     setup_db.setup_db(self.db_path)