# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/celery_ext/tasks.py
# DB_SUCCESS = "Completed SQL database transcation."
# DB_FAILURE = "An unexpected error occurred during SQL database transaction."
# def create_database(job_id):
# def modify_database(job_id):
# def database_success(job_id):
# def database_failure(job_id):
# def database_task(job_id, task):
# def clean_job(job_record):
# def get_alchemist():
# def get_job(job_id):
# def get_database(database_id):
#     def __init__(self, job_id):
#     def handle_call(self, code, *args, **kwargs):
# class CallbackObserver(object):
# 
# Path: webphamerator/app/sqlalchemy_ext/models.py
# class Database(db.Model):
# class Job(db.Model):
# class JobOrganismToDelete(db.Model):
# class GenbankFile(db.Model):
# class Password(db.Model):
#     def url(self):
#     def mysql_name_for(cls, name):
#     def phamerator_name_for(cls, name):
#     def mysql_name(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):


import tempfile
import shutil
import os
import pham.genbank
import pham.db
import flask
from pathlib import Path
from flask import (abort, Blueprint, current_app, request)
from pdm_utils import AlchemyHandler
from webphamerator.app import sqlalchemy_ext as sqlext
from webphamerator.app import filters
from webphamerator.app.celery_ext import tasks
from webphamerator.app.sqlalchemy_ext import models
    job_record = models.Job(database_id=database_record.id,
                            status_code='queued',
                            status_message='Waiting to run.',
                            database_name=database_record.display_name,
                            seen=False)
    sqlext.db.session.add(job_record)
    sqlext.db.session.commit()
    job_id = job_record.id

    for phage_id in phage_ids:
        record = models.JobOrganismToDelete(organism_id=phage_id,
                                            job_id=job_id)
        sqlext.db.session.add(record)
    if len(phage_ids):
        sqlext.db.session.commit()

    if len(file_ids):
        (sqlext.db.session.query(models.GenbankFile)
            .filter(models.GenbankFile.id.in_(file_ids))
            .update({models.GenbankFile.job_id: job_id},
                    synchronize_session='fetch')
         )
        sqlext.db.session.commit()

    if not test:
        if description is not None:
            database_record.description = description
        database_record.locked = True
        sqlext.db.session.commit()


# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/celery_ext/tasks.py
# DB_SUCCESS = "Completed SQL database transcation."
# DB_FAILURE = "An unexpected error occurred during SQL database transaction."
# def create_database(job_id):
# def modify_database(job_id):
# def database_success(job_id):
# def database_failure(job_id):
# def database_task(job_id, task):
# def clean_job(job_record):
# def get_alchemist():
# def get_job(job_id):
# def get_database(database_id):
#     def __init__(self, job_id):
#     def handle_call(self, code, *args, **kwargs):
# class CallbackObserver(object):
# 
# Path: webphamerator/app/sqlalchemy_ext/models.py
# class Database(db.Model):
# class Job(db.Model):
# class JobOrganismToDelete(db.Model):
# class GenbankFile(db.Model):
# class Password(db.Model):
#     def url(self):
#     def mysql_name_for(cls, name):
#     def phamerator_name_for(cls, name):
#     def mysql_name(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):


# Path: webphamerator/app/api.py
import tempfile
import shutil
import os
import pham.genbank
import pham.db
import flask
from pathlib import Path
from flask import (abort, Blueprint, current_app, request)
from pdm_utils import AlchemyHandler
from webphamerator.app import sqlalchemy_ext as sqlext
from webphamerator.app import filters
from webphamerator.app.celery_ext import tasks
from webphamerator.app.sqlalchemy_ext import models

    job_record = models.Job(database_id=database_record.id,
                            status_code='queued',
                            status_message='Waiting to run.',
                            database_name=database_record.display_name,
                            seen=False)
    sqlext.db.session.add(job_record)
    sqlext.db.session.commit()
    job_id = job_record.id

    for phage_id in phage_ids:
        record = models.JobOrganismToDelete(organism_id=phage_id,
                                            job_id=job_id)
        sqlext.db.session.add(record)
    if len(phage_ids):
        sqlext.db.session.commit()

    if len(file_ids):
        (sqlext.db.session.query(models.GenbankFile)
            .filter(models.GenbankFile.id.in_(file_ids))
            .update({models.GenbankFile.job_id: job_id},
                    synchronize_session='fetch')
         )
        sqlext.db.session.commit()

    if not test:
        if description is not None:
            database_record.description = description
        database_record.locked = True
        sqlext.db.session.commit()


        tasks.modify_database.delay(job_id)