Esempio n. 1
0
async def _clear_dbs(root):
    # make sure to completely clear db before carrying on...
    async for db in iter_databases(root):
        storage = db.storage
        if IPostgresStorage.providedBy(storage) or ICockroachStorage.providedBy(storage):
            async with storage.pool.acquire() as conn:
                await conn.execute('''
DELETE from {}
WHERE zoid != '{}' AND zoid != '{}'
'''.format(storage._objects_table_name, ROOT_ID, TRASHED_ID))
Esempio n. 2
0
async def _clear_dbs(root):
    # make sure to completely clear db before carrying on...
    async for db in iter_databases(root):
        storage = db.storage
        if IPostgresStorage.providedBy(
                storage) or ICockroachStorage.providedBy(storage):
            async with storage.pool.acquire() as conn:
                await conn.execute('''
DELETE from {}
WHERE zoid != '{}' AND zoid != '{}'
'''.format(storage._objects_table_name, ROOT_ID, TRASHED_ID))
Esempio n. 3
0
    async def run(self, arguments, settings, app):
        script = os.path.abspath(arguments.script)
        spec = importlib.util.spec_from_file_location("module.name", script)
        module = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)
        if not hasattr(module, "run"):
            logger.warn(f"Not `async def run()` function found in file {script}")
            return
        sig = inspect.signature(module.run)
        if "container" in sig.parameters:
            async for db in iter_databases():
                # preload dynamic dbs
                pass

            async for txn, tm, container in get_containers():
                await module.run(container)
                await tm.commit(txn=txn)
        else:
            await lazy_apply(module.run, app)
Esempio n. 4
0
 async def run(self, arguments, settings, app):
     async for db in iter_databases():
         await self.migrate(db)
Esempio n. 5
0
 async def run(self, arguments, settings, app):
     async for db in iter_databases():
         await self.migrate(db)
Esempio n. 6
0
 async def run(self, arguments, settings, app):
     async for db in iter_databases():
         try:
             await self.vacuum(db)
         except Exception:  # pragma: no cover
             logger.error("Error vacuuming db", exc_info=True)
Esempio n. 7
0
    async def get_banner(self):
        db_ids = []
        async for db in utils.iter_databases():
            db_ids.append('- ' + db.id)

        return self.banner.format('\n'.join(db_ids))