# Path: pyas2/models.py
# DEFAULT_ENTRY = ('', "---------")
#     CONTENT_TYPE_CHOICES = (
#         ('application/EDI-X12', 'application/EDI-X12'),
#         ('application/EDIFACT', 'application/EDIFACT'),
#         ('application/edi-consent', 'application/edi-consent'),
#         ('application/XML', 'application/XML'),
#         ('text/CSV', 'text/CSV'),
#     )
#     ENCRYPT_ALG_CHOICES = (
#         ('des_ede3_cbc', '3DES'),
#         ('des_cbc', 'DES'),
#         ('aes_128_cbc', 'AES-128'),
#         ('aes_192_cbc', 'AES-192'),
#         ('aes_256_cbc', 'AES-256'),
#         ('rc2_40_cbc', 'RC2-40'),
#     )
#     SIGN_ALG_CHOICES = (
#         ('sha1', 'SHA-1'),
#     )
#     MDN_TYPE_CHOICES = (
#         ('SYNC', 'Synchronous'),
#         ('ASYNC', 'Asynchronous'),
#     )
#     DIRECTION_CHOICES = (
#         ('IN', _('Inbound')),
#         ('OUT', _('Outbound')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#         ('P', _('Pending')),
#         ('R', _('Retry')),
#         ('IP', _('In Process')),
#     )
#     MODE_CHOICES = (
#         ('SYNC', _('Synchronous')),
#         ('ASYNC', _('Asynchronous')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Sent')),
#         ('R', _('Received')),
#         ('P', _('Pending')),
#     )
# def get_certificate_path(instance, filename):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def getorganizations():
# def getpartners():
# def check_odirs(sender, instance, created, **kwargs):
# def check_pdirs(sender, instance, created, **kwargs):
# def update_dirs():
# class PrivateCertificate(models.Model):
# class PublicCertificate(models.Model):
# class Organization(models.Model):
# class Partner(models.Model):
# class Message(models.Model):
# class Payload(models.Model):
# class Log(models.Model):
# class MDN(models.Model):
# 
# Path: pyas2/pyas2init.py
# def initialize():
# def initserverlogging(logname):


from django.core.management.base import BaseCommand
from django.utils.translation import ugettext as _
from datetime import timedelta
from django.utils import timezone
from pyas2 import models
from pyas2 import pyas2init
import os
import glob
            if os.path.getmtime(filename) < max_archive_ts:
                pyas2init.logger.debug(
                    _(u'Delete Log file {}'.format(filename)))
                os.remove(filename)

        pyas2init.logger.info(
            _(u'Delete all Archive Files older than max archive days'))
        archive_folders = [
            pyas2init.gsettings['payload_send_store'],
            pyas2init.gsettings['payload_receive_store'],
            pyas2init.gsettings['mdn_send_store'],
            pyas2init.gsettings['mdn_receive_store']
        ]
        for archive_folder in archive_folders:
            for (dir_path, dir_names, arch_files) in os.walk(archive_folder):
                if len(arch_files) > 0:
                    for arch_file in arch_files:
                        filename = os.path.join(dir_path, arch_file)
                        if os.path.getmtime(filename) < max_archive_ts:
                            pyas2init.logger.debug(_(u'Delete Archive file '
                                                     u'{}'.format(filename)))
                            os.remove(filename)

                    # Delete the folder if it is empty
                    try:
                        os.rmdir(dir_path)
                        pyas2init.logger.debug(_(u'Delete Empty Archive folder'
                                                 u' {}'.format(dir_path)))
                    except OSError:
                        pass

# Path: pyas2/models.py
# DEFAULT_ENTRY = ('', "---------")
#     CONTENT_TYPE_CHOICES = (
#         ('application/EDI-X12', 'application/EDI-X12'),
#         ('application/EDIFACT', 'application/EDIFACT'),
#         ('application/edi-consent', 'application/edi-consent'),
#         ('application/XML', 'application/XML'),
#         ('text/CSV', 'text/CSV'),
#     )
#     ENCRYPT_ALG_CHOICES = (
#         ('des_ede3_cbc', '3DES'),
#         ('des_cbc', 'DES'),
#         ('aes_128_cbc', 'AES-128'),
#         ('aes_192_cbc', 'AES-192'),
#         ('aes_256_cbc', 'AES-256'),
#         ('rc2_40_cbc', 'RC2-40'),
#     )
#     SIGN_ALG_CHOICES = (
#         ('sha1', 'SHA-1'),
#     )
#     MDN_TYPE_CHOICES = (
#         ('SYNC', 'Synchronous'),
#         ('ASYNC', 'Asynchronous'),
#     )
#     DIRECTION_CHOICES = (
#         ('IN', _('Inbound')),
#         ('OUT', _('Outbound')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#         ('P', _('Pending')),
#         ('R', _('Retry')),
#         ('IP', _('In Process')),
#     )
#     MODE_CHOICES = (
#         ('SYNC', _('Synchronous')),
#         ('ASYNC', _('Asynchronous')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Success')),
#         ('E', _('Error')),
#         ('W', _('Warning')),
#     )
#     STATUS_CHOICES = (
#         ('S', _('Sent')),
#         ('R', _('Received')),
#         ('P', _('Pending')),
#     )
# def get_certificate_path(instance, filename):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def getorganizations():
# def getpartners():
# def check_odirs(sender, instance, created, **kwargs):
# def check_pdirs(sender, instance, created, **kwargs):
# def update_dirs():
# class PrivateCertificate(models.Model):
# class PublicCertificate(models.Model):
# class Organization(models.Model):
# class Partner(models.Model):
# class Message(models.Model):
# class Payload(models.Model):
# class Log(models.Model):
# class MDN(models.Model):
# 
# Path: pyas2/pyas2init.py
# def initialize():
# def initserverlogging(logname):


# Path: pyas2/management/commands/cleanas2server.py
from django.core.management.base import BaseCommand
from django.utils.translation import ugettext as _
from datetime import timedelta
from django.utils import timezone
from pyas2 import models
from pyas2 import pyas2init
import os
import glob

            if os.path.getmtime(filename) < max_archive_ts:
                pyas2init.logger.debug(
                    _(u'Delete Log file {}'.format(filename)))
                os.remove(filename)

        pyas2init.logger.info(
            _(u'Delete all Archive Files older than max archive days'))
        archive_folders = [
            pyas2init.gsettings['payload_send_store'],
            pyas2init.gsettings['payload_receive_store'],
            pyas2init.gsettings['mdn_send_store'],
            pyas2init.gsettings['mdn_receive_store']
        ]
        for archive_folder in archive_folders:
            for (dir_path, dir_names, arch_files) in os.walk(archive_folder):
                if len(arch_files) > 0:
                    for arch_file in arch_files:
                        filename = os.path.join(dir_path, arch_file)
                        if os.path.getmtime(filename) < max_archive_ts:
                            pyas2init.logger.debug(_(u'Delete Archive file '
                                                     u'{}'.format(filename)))
                            os.remove(filename)

                    # Delete the folder if it is empty
                    try:
                        os.rmdir(dir_path)
                        pyas2init.logger.debug(_(u'Delete Empty Archive folder'
                                                 u' {}'.format(dir_path)))
                    except OSError:
                        pass

        pyas2init.logger.info(_(u'Automatic maintenance process completed'))