# Path: worker/bases.py
# def get_config(section, key, const=0):
#     """
#     Get a configuration
#     :param section: string, the config insides which section
#     :param key: string
#     :param const: int, 0 means to look up user's conf, 1 means to look up bioqueue's conf
#     :return:
#     """
#     try:
#         config = config_init(const)
#         return config.get(section, key)
#     except:
#         return None
# 
# Path: QueueDB/models.py
# class FileArchive(_OwnerModel):
#     protocol = models.ForeignKey('ProtocolList', on_delete=models.PROTECT,
#                                  related_name="%(app_label)s_%(class)s_related")
#     protocol_ver = models.CharField(max_length=33, null=True)
#     inputs = models.TextField()
#     files = models.TextField()
#     file_md5s = models.TextField()
#     job = models.ForeignKey(Job, on_delete=models.PROTECT, null=True, blank=True)
#     raw_files = models.TextField(null=True, blank=True)
#     audit = models.SmallIntegerField(default=0)
#     description = models.TextField(null=True, blank=True)
#     comment = models.TextField(null=True, blank=True)
#     status = models.SmallIntegerField(default=0)
#     archive_file = models.TextField(null=True, blank=True)
#     create_time = models.DateTimeField(auto_now_add=True)
#     shared_with = models.TextField(null=True, blank=True)
#     file_id_remote = models.TextField(null=True, blank=True, default="ph")
# 
# Path: ui/views.py



import hashlib
import os
import json
            import tarfile
from worker.bases import get_config
from QueueDB.models import FileArchive  #, GoogleDriveConnection
from .views import audit_job_atom
#!/usr/bin/env python
# coding=utf-8
# @Author: Li Yao
# @Date: 1/28/20
# from .plugins.google_drive import GoogleDrive


def save_job(archive_id, logger):
    def file_md5(file_path):
        hash_md5 = hashlib.md5()
        with open(file_path, "rb") as fh:
            for chunk in iter(lambda: fh.read(4096), b""):
                hash_md5.update(chunk)
        return hash_md5.hexdigest()

    try:

# Path: worker/bases.py
# def get_config(section, key, const=0):
#     """
#     Get a configuration
#     :param section: string, the config insides which section
#     :param key: string
#     :param const: int, 0 means to look up user's conf, 1 means to look up bioqueue's conf
#     :return:
#     """
#     try:
#         config = config_init(const)
#         return config.get(section, key)
#     except:
#         return None
# 
# Path: QueueDB/models.py
# class FileArchive(_OwnerModel):
#     protocol = models.ForeignKey('ProtocolList', on_delete=models.PROTECT,
#                                  related_name="%(app_label)s_%(class)s_related")
#     protocol_ver = models.CharField(max_length=33, null=True)
#     inputs = models.TextField()
#     files = models.TextField()
#     file_md5s = models.TextField()
#     job = models.ForeignKey(Job, on_delete=models.PROTECT, null=True, blank=True)
#     raw_files = models.TextField(null=True, blank=True)
#     audit = models.SmallIntegerField(default=0)
#     description = models.TextField(null=True, blank=True)
#     comment = models.TextField(null=True, blank=True)
#     status = models.SmallIntegerField(default=0)
#     archive_file = models.TextField(null=True, blank=True)
#     create_time = models.DateTimeField(auto_now_add=True)
#     shared_with = models.TextField(null=True, blank=True)
#     file_id_remote = models.TextField(null=True, blank=True, default="ph")
# 
# Path: ui/views.py



# Path: ui/cron_jobs.py
import hashlib
import os
import json
            import tarfile
from worker.bases import get_config
from QueueDB.models import FileArchive  #, GoogleDriveConnection
from .views import audit_job_atom

#!/usr/bin/env python
# coding=utf-8
# @Author: Li Yao
# @Date: 1/28/20
# from .plugins.google_drive import GoogleDrive


def save_job(archive_id, logger):
    def file_md5(file_path):
        hash_md5 = hashlib.md5()
        with open(file_path, "rb") as fh:
            for chunk in iter(lambda: fh.read(4096), b""):
                hash_md5.update(chunk)
        return hash_md5.hexdigest()

    try:

        archive = FileArchive.objects.get(id=archive_id)