# 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
        files = json.loads(archive.files.replace("'", "\""))
        if prev_same_archive is not None:
            for psa in prev_same_archive:
                md5_flag = 1
                archive.file_md5s = psa.file_md5s
                if psa.archive_file != "ph":
                    archive.archive_file = psa.archive_file
                    tared_flag = 1
                if psa.file_id_remote != "ph":
                    archive.file_id_remote = psa.file_id_remote
                    uploaded_flag = 1
                archive.save()
        if not md5_flag:
            logger.info("Calculating MD5 sums")
            md5_sums = []
            for file in files:
                md5_sums.append(file_md5(file))
            archive.file_md5s = ",".join(md5_sums)
            archive.save()
        if not tared_flag:
            logger.info("Compressing files")
            user_archives = archive.user.queuedb_profile_related.delegate.queuedb_profile_related.archive_folder
            if user_archives != "":
                if not os.path.exists(user_archives):
                    try:
                        os.makedirs(user_archives)
                    except Exception as e:
                        logger.exception(e)
                        archive_folder = ""
            if user_archives == "":

# 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

        files = json.loads(archive.files.replace("'", "\""))
        if prev_same_archive is not None:
            for psa in prev_same_archive:
                md5_flag = 1
                archive.file_md5s = psa.file_md5s
                if psa.archive_file != "ph":
                    archive.archive_file = psa.archive_file
                    tared_flag = 1
                if psa.file_id_remote != "ph":
                    archive.file_id_remote = psa.file_id_remote
                    uploaded_flag = 1
                archive.save()
        if not md5_flag:
            logger.info("Calculating MD5 sums")
            md5_sums = []
            for file in files:
                md5_sums.append(file_md5(file))
            archive.file_md5s = ",".join(md5_sums)
            archive.save()
        if not tared_flag:
            logger.info("Compressing files")
            user_archives = archive.user.queuedb_profile_related.delegate.queuedb_profile_related.archive_folder
            if user_archives != "":
                if not os.path.exists(user_archives):
                    try:
                        os.makedirs(user_archives)
                    except Exception as e:
                        logger.exception(e)
                        archive_folder = ""
            if user_archives == "":

                user_archives = os.path.join(get_config("env", "workspace"),