Пример #1
0
 def encoder(obj):
     items = []
     for item in obj:
         # Check if hidden (TODO: this method is slow)
         if models.Transfer.objects.is_hidden(item['sipuuid']):
             continue
         jobs = helpers.get_jobs_by_sipuuid(item['sipuuid'])
         item['directory'] = os.path.basename(utils.get_directory_name(jobs[0]))
         item['timestamp'] = calendar.timegm(item['timestamp'].timetuple())
         item['uuid'] = item['sipuuid']
         item['id'] = item['sipuuid']
         del item['sipuuid']
         item['jobs'] = []
         for job in jobs:
             newJob = {}
             item['jobs'].append(newJob)
             newJob['uuid'] = job.jobuuid
             newJob['type'] = job.jobtype
             newJob['microservicegroup'] = job.microservicegroup
             newJob['subjobof'] = job.subjobof
             newJob['currentstep'] = job.currentstep
             newJob['timestamp'] = '%d.%s' % (calendar.timegm(job.createdtime.timetuple()), str(job.createdtimedec).split('.')[-1])
             try: mcp_status
             except NameError: pass
             else:
                 xml_unit = mcp_status.xpath('choicesAvailableForUnit[UUID="%s"]' % job.jobuuid)
                 if xml_unit:
                     xml_unit_choices = xml_unit[0].findall('choices/choice')
                     choices = {}
                     for choice in xml_unit_choices:
                         choices[choice.find("chainAvailable").text] = choice.find("description").text
                     newJob['choices'] = choices
         items.append(item)
     return items
Пример #2
0
 def encoder(obj):
     items = []
     for item in obj:
         # Check if hidden (TODO: this method is slow)
         if models.Transfer.objects.is_hidden(item['sipuuid']):
             continue
         jobs = helpers.get_jobs_by_sipuuid(item['sipuuid'])
         item['directory'] = os.path.basename(utils.get_directory_name(jobs[0]))
         item['timestamp'] = calendar.timegm(item['timestamp'].timetuple())
         item['uuid'] = item['sipuuid']
         item['id'] = item['sipuuid']
         del item['sipuuid']
         item['jobs'] = []
         for job in jobs:
             newJob = {}
             item['jobs'].append(newJob)
             newJob['uuid'] = job.jobuuid
             newJob['type'] = job.jobtype
             newJob['microservicegroup'] = job.microservicegroup
             newJob['subjobof'] = job.subjobof
             newJob['currentstep'] = job.currentstep
             newJob['timestamp'] = '%d.%s' % (calendar.timegm(job.createdtime.timetuple()), str(job.createdtimedec).split('.')[-1])
             try: mcp_status
             except NameError: pass
             else:
                 xml_unit = mcp_status.xpath('choicesAvailableForUnit[UUID="%s"]' % job.jobuuid)
                 if xml_unit:
                     xml_unit_choices = xml_unit[0].findall('choices/choice')
                     choices = {}
                     for choice in xml_unit_choices:
                         choices[choice.find("chainAvailable").text] = choice.find("description").text
                     newJob['choices'] = choices
         items.append(item)
     return items
Пример #3
0
    def encoder(obj):
        items = []
        for item in obj:
            # Check if hidden (TODO: this method is slow)
            if models.SIP.objects.is_hidden(item['sipuuid']):
                continue
            jobs = helpers.get_jobs_by_sipuuid(item['sipuuid'])
            item['directory'] = utils.get_directory_name_from_job(jobs)
            item['timestamp'] = calendar.timegm(item['timestamp'].timetuple())
            item['uuid'] = item['sipuuid']
            item['id'] = item['sipuuid']
            del item['sipuuid']
            item['jobs'] = []
            for job in jobs:
                newJob = {}
                item['jobs'].append(newJob)

                # allow user to know name of file that has failed normalization
                if job.jobtype == 'Access normalization failed - copying' or job.jobtype == 'Preservation normalization failed - copying' or job.jobtype == 'thumbnail normalization failed - copying':
                    task = models.Task.objects.get(job=job)
                    newJob['filename'] = task.filename

                newJob['uuid'] = job.jobuuid
                newJob['type'] = job.jobtype
                newJob['microservicegroup'] = job.microservicegroup
                newJob['subjobof'] = job.subjobof
                newJob['currentstep'] = job.currentstep
                newJob['timestamp'] = '%d.%s' % (calendar.timegm(
                    job.createdtime.timetuple()), str(
                        job.createdtimedec).split('.')[-1])
                try:
                    mcp_status
                except NameError:
                    pass
                else:
                    xml_unit = mcp_status.xpath(
                        'choicesAvailableForUnit[UUID="%s"]' % job.jobuuid)
                    if xml_unit:
                        xml_unit_choices = xml_unit[0].findall(
                            'choices/choice')
                        choices = {}
                        for choice in xml_unit_choices:
                            choices[choice.find("chainAvailable").
                                    text] = choice.find("description").text
                        newJob['choices'] = choices
            items.append(item)
        return items