# Path: OGRgeoConverter/models.py
# class LogEntry(models.Model):
#     session_key = models.CharField(max_length=50)
#     job_id = models.CharField(max_length=50)
# 
#     client_job_token = models.CharField(max_length=50)
#     client_ip = models.CharField(max_length=50)
#     client_language = models.CharField(max_length=50)
#     client_user_agent = models.CharField(max_length=256)
# 
#     input_type = models.CharField(
#         max_length=50, choices=(
#             ('files', 'Files'), ('webservice', 'Webservice')))
#     start_time = models.DateTimeField()
#     end_time = models.DateTimeField()
#     export_format = models.CharField(max_length=100)
#     source_srs = models.CharField(max_length=100)
#     target_srs = models.CharField(max_length=100)
#     simplify_parameter = models.CharField(max_length=100)
#     download_file_size = models.IntegerField(
#         verbose_name='Download file size (KB)')
# 
#     file_downloaded = models.BooleanField()
#     has_download_file = models.BooleanField()
#     all_files_converted = models.BooleanField()
#     has_no_error = models.BooleanField()
# 
#     def __unicode__(self):
#         return str(self.start_time)
# 
#     def duration(self):
#         difference = self.end_time - self.start_time
#         return str(difference)
# 
#     class Meta:
#         verbose_name_plural = "Log entries"
#         db_table = 'ogrgeoconverter_log_entries'
# 
#     @staticmethod
#     def get_log_entry(session_key, job_id):
#         return LogEntry.objects.filter(session_key=session_key, job_id=job_id)
# 
# Path: OGRgeoConverter/models.py
# class OGRlogEntry(models.Model):
#     log_entry = models.ForeignKey(LogEntry)
# 
#     sub_path = models.CharField(max_length=1000)
#     input = models.CharField(max_length=5000)
#     command = models.CharField(max_length=1000)
#     error_message = models.CharField(max_length=10000)
#     has_output_file = models.BooleanField()
# 
#     class Meta:
#         verbose_name = "OGR Log entry"
#         verbose_name_plural = "OGR Log entries"
#         db_table = 'ogrgeoconverter_ogr_log_entries'
# 
#     @staticmethod
#     def get_ogr_log_entry(log_entry):
#         return OGRlogEntry.objects.filter(log_entry=log_entry)
# 
#     @staticmethod
#     def cleanup_by_date(date_limit):
#         OGRlogEntry.objects.filter(
#             log_entry__start_time__lt=date_limit).delete()
# 
# Path: OGRgeoConverter/geoconverter/datetimehandler.py
# def get_default_datetime():
# def get_now():


from OGRgeoConverter.models import LogEntry
from OGRgeoConverter.models import OGRlogEntry
from OGRgeoConverter.geoconverter import datetimehandler
        log_entry = self.__get_log_entry_query_set()
        return log_entry[0].all_files_converted

    def set_has_no_error(self):
        has_no_error = True
        for ogr_log_entry in self.__get_ogr_log_entry_query_set():
            if ogr_log_entry.error_message != '':
                has_no_error = False
                break
        has_no_error = has_no_error and len(
            self.__get_ogr_log_entry_query_set()) > 0

        log_entry = self.__get_log_entry_query_set()
        log_entry.update(has_no_error=has_no_error)

    def get_has_no_error(self):
        log_entry = self.__get_log_entry_query_set()
        return log_entry[0].has_no_error

    def add_ogr_log_entry(
            self,
            sub_path,
            input_string,
            ogr_command,
            ogr_error_message,
            has_output_file):
        command_max_length = OGRlogEntry._meta.get_field('command').max_length
        if len(ogr_command) > command_max_length:
            ogr_command = ogr_command[0:command_max_length - 7] + ' [...]'


# Path: OGRgeoConverter/models.py
# class LogEntry(models.Model):
#     session_key = models.CharField(max_length=50)
#     job_id = models.CharField(max_length=50)
# 
#     client_job_token = models.CharField(max_length=50)
#     client_ip = models.CharField(max_length=50)
#     client_language = models.CharField(max_length=50)
#     client_user_agent = models.CharField(max_length=256)
# 
#     input_type = models.CharField(
#         max_length=50, choices=(
#             ('files', 'Files'), ('webservice', 'Webservice')))
#     start_time = models.DateTimeField()
#     end_time = models.DateTimeField()
#     export_format = models.CharField(max_length=100)
#     source_srs = models.CharField(max_length=100)
#     target_srs = models.CharField(max_length=100)
#     simplify_parameter = models.CharField(max_length=100)
#     download_file_size = models.IntegerField(
#         verbose_name='Download file size (KB)')
# 
#     file_downloaded = models.BooleanField()
#     has_download_file = models.BooleanField()
#     all_files_converted = models.BooleanField()
#     has_no_error = models.BooleanField()
# 
#     def __unicode__(self):
#         return str(self.start_time)
# 
#     def duration(self):
#         difference = self.end_time - self.start_time
#         return str(difference)
# 
#     class Meta:
#         verbose_name_plural = "Log entries"
#         db_table = 'ogrgeoconverter_log_entries'
# 
#     @staticmethod
#     def get_log_entry(session_key, job_id):
#         return LogEntry.objects.filter(session_key=session_key, job_id=job_id)
# 
# Path: OGRgeoConverter/models.py
# class OGRlogEntry(models.Model):
#     log_entry = models.ForeignKey(LogEntry)
# 
#     sub_path = models.CharField(max_length=1000)
#     input = models.CharField(max_length=5000)
#     command = models.CharField(max_length=1000)
#     error_message = models.CharField(max_length=10000)
#     has_output_file = models.BooleanField()
# 
#     class Meta:
#         verbose_name = "OGR Log entry"
#         verbose_name_plural = "OGR Log entries"
#         db_table = 'ogrgeoconverter_ogr_log_entries'
# 
#     @staticmethod
#     def get_ogr_log_entry(log_entry):
#         return OGRlogEntry.objects.filter(log_entry=log_entry)
# 
#     @staticmethod
#     def cleanup_by_date(date_limit):
#         OGRlogEntry.objects.filter(
#             log_entry__start_time__lt=date_limit).delete()
# 
# Path: OGRgeoConverter/geoconverter/datetimehandler.py
# def get_default_datetime():
# def get_now():


# Path: OGRgeoConverter/modelhandlers/loghandler.py
from OGRgeoConverter.models import LogEntry
from OGRgeoConverter.models import OGRlogEntry
from OGRgeoConverter.geoconverter import datetimehandler

        log_entry = self.__get_log_entry_query_set()
        return log_entry[0].all_files_converted

    def set_has_no_error(self):
        has_no_error = True
        for ogr_log_entry in self.__get_ogr_log_entry_query_set():
            if ogr_log_entry.error_message != '':
                has_no_error = False
                break
        has_no_error = has_no_error and len(
            self.__get_ogr_log_entry_query_set()) > 0

        log_entry = self.__get_log_entry_query_set()
        log_entry.update(has_no_error=has_no_error)

    def get_has_no_error(self):
        log_entry = self.__get_log_entry_query_set()
        return log_entry[0].has_no_error

    def add_ogr_log_entry(
            self,
            sub_path,
            input_string,
            ogr_command,
            ogr_error_message,
            has_output_file):
        command_max_length = OGRlogEntry._meta.get_field('command').max_length
        if len(ogr_command) > command_max_length:
            ogr_command = ogr_command[0:command_max_length - 7] + ' [...]'


        error_message_max_length = OGRlogEntry._meta.get_field(