예제 #1
0
def reset_session(session_hash):
    if not session_hash in couchdb_server:
        logger.info(f"Didn't find session database {session_hash}")
        return

    session_db = fetch_db(session_hash)
    session_data = SessionData()
    session_data.fetch(session_db)

    project_hash = get_hash(session_data.project_name)
    project_db = fetch_db(project_hash)
    project_data = ProjectData()
    project_data.fetch(project_db)
    del project_data.sessions[session_data.name]
    project_data.push(project_db)

    try:
        couchdb_server.delete(session_hash)
        logger.info(f'Deleted session database {session_hash}')
    except Exception as e:
        logger.info(f'Failed to delete session database {session_hash}')
        logger.exception(e)
        raise (e)

    return
예제 #2
0
def reset_project(project_name):
    project_hash = get_hash(project_name)
    if not project_hash in couchdb_server:
        logger.info(
            f"Didn't find database {project_hash} for project {project_name}")
        return

    project_db = fetch_db(project_hash)
    project_data = ProjectData()
    project_data.fetch(project_db)

    failure_occured = False
    for session_hash in project_data.sessions.values():
        try:
            reset_session(session_hash)
        except:
            failure_occured = True

    if not failure_occured:
        couchdb_server.delete(project_hash)
        logger.info(
            f'Deleted database {project_hash} for project {project_name}')
    else:
        logger.info(
            f'Did not delete project database due to remaining session databases.'
        )
예제 #3
0
    def add_one_passport(self, username, password, email):

        passport = self.create(username=username,
                               password=get_hash(password),
                               email=email)

        return passport
예제 #4
0
 def model_project(self, name):
     project = ProjectData()
     project.name = name
     project.hash = get_hash(name)
     project.sessions = {}
     project.db = fetch_db(project.hash)
     project.fetch(project.db)
     return project
예제 #5
0
    def model_session(self, directory, mask):
        names = self.parse_directory_path_for_names(directory, mask)

        session = SessionData()
        # double cast for consistent path string formatting
        session.directory = str(Path(directory))
        session.name = names.session
        session.long_name = '{}--{}--{}'.format(names.project, names.sample,
                                                names.session)
        session.hash = get_hash(session.long_name)
        session.sample = names.sample
        session.project = names.project
        return session
예제 #6
0
def show_project_info(project_name):
    project_hash = get_hash(project_name)
    db = fetch_db(project_hash)
    project = ProjectData()
    project.fetch(db)

    print('\n')
    print(f'{project_name}')
    print(f'{project_hash}')
    print(f'{get_config().base_url}/web-view/project/{project_hash}')

    print('\n')
    print("Sessions")
    print("------------------------------")
    if project.sessions is None:
        print('No sessions')
        return
    for name, hash in project.sessions.items():
        print(f'- {name}')
        print(f'  {hash}')
        print(f'  {get_config().base_url}/web-view/session/{hash}')
        print('\n')
예제 #7
0
def show_hash(input):
    hash = get_hash(input)
    print(f'\n{hash}\n')
예제 #8
0
 def get_one_passport(self, username, password):
     try:
         passport = self.get(username=username, password=get_hash(password))
     except Exception:
         passport = None
     return passport