Esempio n. 1
0
def sync_single(path, key=None):
    """Used to sync a single discrete set of run data.

    :param path: Path to run data
    :type path: str
    :param key: Encryption/Decryption base 64 encoded key
    :type key: str
    """
    with DriverContext() as driver:
        run = runs.Run(path, key=key)
        env = EnvironmentEntity(uuid=run.environment_uuid,
                                name=run.environment_name,
                                account_number=run.environment_account_number)
        with lock_environment(driver, env):
            sync_run(driver, run)
Esempio n. 2
0
def sync_paths(paths):
    """Sync all runs indicated by paths.

    :param paths: list of paths indicating runs.
    :type paths: list
    """
    # Start a neo4j driver context.
    with DriverContext() as driver:
        for path in paths:
            run = runs.Run(path)
            # Try to acquire environment lock.
            # @TODO - Implement wait until timeout loop.
            try:
                with lock_environment(driver, run):
                    sync_run(driver, run)
            except EnvironmentLockedError as e:
                logger.error(e)
Esempio n. 3
0
def sync(paths):
    with DriverContext() as driver:
        for path in paths:
            run = runs.Run(path)
            with lock_environment(driver, run):
                try:
                    check_run_time(driver, run)
                    run.start()
                    logger.info("Starting collection on {}".format(run.path))
                    consume(driver, run)
                    logger.info("Run completion time: {}".format(
                        utils.milliseconds(run.completed)))
                    run.finish()
                except RunAlreadySyncedError as e:
                    logger.info(e)
                except RunInvalidStatusError as e:
                    logger.info(e)
                except RunContainsOldDataError as e:
                    logger.info(e)
                except Exception:
                    logger.exception('Unable to complete run.')
                    run.error()