Esempio n. 1
0
    def upload(self, jobxml, ignore_missing_tasks=False):
        """
        Queues a new job.

        :param jobxml: XML description of job to be queued
        :type jobxml: string
        :param ignore_missing_tasks: pass True for this parameter to cause 
            unknown tasks to be silently discarded (default is False)
        :type ignore_missing_tasks: bool
        """
        # xml.sax (and thus, xmltramp) expect raw bytes, not unicode
        if isinstance(jobxml, unicode):
            jobxml = jobxml.encode('utf8')
        xml = xmltramp_parse_untrusted(jobxml)
        xmljob = XmlJob(xml)
        job = self.process_xmljob(xmljob,identity.current.user,
                ignore_missing_tasks=ignore_missing_tasks)
        session.flush() # so that we get an id
        return "J:%s" % job.id
Esempio n. 2
0
    def upload(self, jobxml, ignore_missing_tasks=False):
        """
        Queues a new job.

        :param jobxml: XML description of job to be queued
        :type jobxml: string
        :param ignore_missing_tasks: pass True for this parameter to cause 
            unknown tasks to be silently discarded (default is False)
        :type ignore_missing_tasks: bool
        """
        # xml.sax (and thus, xmltramp) expect raw bytes, not unicode
        if isinstance(jobxml, unicode):
            jobxml = jobxml.encode('utf8')
        xml = xmltramp_parse_untrusted(jobxml)
        xmljob = XmlJob(xml)
        job = self.process_xmljob(xmljob,
                                  identity.current.user,
                                  ignore_missing_tasks=ignore_missing_tasks)
        session.flush()  # so that we get an id
        return "J:%s" % job.id
Esempio n. 3
0
     try:
         # xml.sax (and thus, xmltramp) expect raw bytes, not unicode
         textxml = textxml.encode('utf8')
         if not confirmed:
             job_schema = lxml.etree.RelaxNG(self.job_schema_doc)
             if not job_schema.validate(lxml.etree.fromstring(textxml)):
                 log.debug('Job failed validation, with errors: %r',
                           job_schema.error_log)
                 return dict(
                     title=title,
                     form=self.job_form,
                     action='clone',
                     options={'xsd_errors': job_schema.error_log},
                     value=dict(textxml=textxml, confirmed=True),
                 )
         xmljob = XmlJob(xmltramp_parse_untrusted(textxml))
         job = self.process_xmljob(xmljob, identity.current.user)
         session.flush()
     except Exception, err:
         session.rollback()
         flash(_(u'Failed to import job because of: %s' % err))
         return dict(
             title=title,
             form=self.job_form,
             action='./clone',
             options={},
             value=dict(textxml="%s" % textxml, confirmed=confirmed),
         )
     else:
         self.success_redirect(job.id)
 return dict(
Esempio n. 4
0
     try:
         # xml.sax (and thus, xmltramp) expect raw bytes, not unicode
         textxml = textxml.encode('utf8')
         if not confirmed:
             job_schema = lxml.etree.RelaxNG(self.job_schema_doc)
             if not job_schema.validate(lxml.etree.fromstring(textxml)):
                 log.debug('Job failed validation, with errors: %r',
                         job_schema.error_log)
                 return dict(
                     title = title,
                     form = self.job_form,
                     action = 'clone',
                     options = {'xsd_errors': job_schema.error_log},
                     value = dict(textxml=textxml, confirmed=True),
                 )
         xmljob = XmlJob(xmltramp_parse_untrusted(textxml))
         job = self.process_xmljob(xmljob,identity.current.user)
         session.flush()
     except Exception,err:
         session.rollback()
         flash(_(u'Failed to import job because of: %s' % err))
         return dict(
             title = title,
             form = self.job_form,
             action = './clone',
             options = {},
             value = dict(textxml = "%s" % textxml, confirmed=confirmed),
         )
     else:
         self.success_redirect(job.id)
 return dict(