def jobsXmldata(self):
        jobs = Nodes.getMgmtSetEntriesDeep(self.mgmt, '/sched/job')
        jobIds = jobs.keys()
        jobIds.sort(FormUtils.compareStringInts)
        gmStartEpoch = time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(0))
        localStartEpoch = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(0))
        result = self.doc.createElement('jobs')
        for jobId in jobIds:
            job = jobs[jobId]
            # We need to skip over jobs where we only have the ID but no other
            # parameters (otherwise, an RBM user can only schedule new jobs if
            # they were the one who scheduled the earlier one, assuming no
            # holes - see bug 105123 for details). The enable state is reliably
            # available for jobs (the name may not always exist), so use that
            # as the test for whether the job exists but is denied.
            if not job.get('enable', None):
                continue

            outputInfo = 'None.'
            outputFile = Nodes.present(self.mgmt, '/sched/job/%s/output_file' % jobId, '')
            if outputFile:
                try:
                    outputLines = file(outputFile).readlines()
                    if outputLines and len(outputLines) > 0:
                        outputInfo = '#012;'
                        for outputLine in outputLines:
                            outputInfo += '%s#012;' % cgi.escape(outputLine)
                except:
                    outputInfo = 'None.'

            jobEl = self.doc.createElement('job')
            jobEl.setAttribute('jobId', jobId)
            jobEl.setAttribute('name', job['name'])
            jobEl.setAttribute('comment', job['comment'])
            jobEl.setAttribute('output', outputInfo)
            status = job.get('status', "unknown")
            errorString = job.get('error_string', "")
            # if errorString and 'completed' == status:
            if errorString:
                status = 'error'
            jobEl.setAttribute('status', status)
            jobEl.setAttribute('statusIcon', 'icon_job_%s.gif' % status)
            if not errorString:
                errorString = status.capitalize()
            jobEl.setAttribute('statusDetail', errorString)
            frequency = job.get('recurring', '0')
            jobEl.setAttribute('frequencySeconds', frequency)
            jobEl.setAttribute('frequencyLang', iph(int(frequency)).then(
                'Recurs every %s seconds' % frequency, 'Not recurring'))
            jobEl.setAttribute('recurs', iph(int(frequency)).then('Y', 'N'))
            jobEl.setAttribute('recurIcon', iph(int(frequency)).then(
                'icon_refresh.gif', 'icon_job_once.gif'))
            jobEl.setAttribute('enabled',
                ('true' == job['enable']) and 'enabled' or 'disabled')
            datetime = ' '.join((job['date'], job['time']))
            if gmStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('datetime', datetime)
            datetime = job.get('create_time', '')
            if localStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('creation', datetime)
            datetime = job.get('last_exec_time', '')
            if localStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('lastrun', datetime)
            commandSeqs = [x.split('/')[-1]
                for x in job.keys()
                if x.startswith('commands/') and not x.endswith('/command')]
            commandSeqs.sort(FormUtils.compareStringInts)
            for eachSeq in commandSeqs:
                command = job['commands/%s/command' % eachSeq]
                commandEl = self.doc.createElement('command')
                commandEl.setAttribute('instruction', command)
                jobEl.appendChild(commandEl)
            result.appendChild(jobEl)
        self.doc.documentElement.appendChild(result)
        self.writeXmlDoc()
    def jobsXmldata(self):
        jobs = Nodes.getMgmtSetEntriesDeep(self.mgmt, '/sched/job')
        jobIds = jobs.keys()
        jobIds.sort(FormUtils.compareStringInts)
        gmStartEpoch = time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(0))
        localStartEpoch = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(0))
        result = self.doc.createElement('jobs')
        for jobId in jobIds:
            outputInfo = 'None.'
            outputFile = Nodes.present(self.mgmt, '/sched/job/%s/output_file' % jobId, '')
            if outputFile:
                try:
                    outputLines = file(outputFile).readlines()
                    if outputLines and len(outputLines) > 0:
                        outputInfo = '#012;'
                        for outputLine in outputLines:
                            outputInfo += '%s#012;' % cgi.escape(outputLine)
                except:
                    outputInfo = 'None.'

            job = jobs[jobId]
            jobEl = self.doc.createElement('job')
            jobEl.setAttribute('jobId', jobId)
            jobEl.setAttribute('name', job['name'])
            jobEl.setAttribute('comment', job['comment'])
            jobEl.setAttribute('output', outputInfo)
            status = job.get('status', "unknown")
            errorString = job.get('error_string', "")
            # if errorString and 'completed' == status:
            if errorString:
                status = 'error'
            jobEl.setAttribute('status', status)
            jobEl.setAttribute('statusIcon', 'icon_job_%s.gif' % status)
            if not errorString:
                errorString = status.capitalize()
            jobEl.setAttribute('statusDetail', errorString)
            frequency = job.get('recurring', '0')
            jobEl.setAttribute('frequencySeconds', frequency)
            jobEl.setAttribute('frequencyLang', iph(int(frequency)).then(
                'Recurs every %s seconds' % frequency, 'Not recurring'))
            jobEl.setAttribute('recurs', iph(int(frequency)).then('Y', 'N'))
            jobEl.setAttribute('recurIcon', iph(int(frequency)).then(
                'icon_refresh.gif', 'icon_job_once.gif'))
            jobEl.setAttribute('enabled',
                ('true' == job['enable']) and 'enabled' or 'disabled')
            datetime = ' '.join((job['date'], job['time']))
            if gmStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('datetime', datetime)
            datetime = job.get('create_time', '')
            if localStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('creation', datetime)
            datetime = job.get('last_exec_time', '')
            if localStartEpoch == datetime:
                datetime = ""
            jobEl.setAttribute('lastrun', datetime)
            commandSeqs = [x.split('/')[-1]
                for x in job.keys()
                if x.startswith('commands/') and not x.endswith('/command')]
            commandSeqs.sort(FormUtils.compareStringInts)
            for eachSeq in commandSeqs:
                command = job['commands/%s/command' % eachSeq]
                commandEl = self.doc.createElement('command')
                commandEl.setAttribute('instruction', command)
                jobEl.appendChild(commandEl)
            result.appendChild(jobEl)
        self.doc.documentElement.appendChild(result)
        self.writeXmlDoc()