Esempio n. 1
0
    def call(self, cmd, args, env={}, progress_url=None,):
        stdout = [""]
        self.exe, b_require_output = self.filter_exe(cmd)
        env = self.filter_env(env)
        args, tmpfile_map = self.__process_args(args)
        #log.debug('####### args: %s' % args)
        if b_require_output and not tmpfile_map:
            raise MProcessorError('No output files specified among the arguments')
        if progress_url and not self.progress_regex:
            raise MProcessorError('No configuration for progress report found (option %s/%s)' %
                (self.cfgsection, 'progress_regex'))
        elif progress_url:
            cb_func = get_progress_cb(progress_url, 'gstreamer-progressreport')
            cb_arg = []
        else:
            stdout = [u""]
            cb_arg = [stdout]
            cb_func = self.accumulate_stdout

        log.debug('Executing RunProc')
        try:
            result = RunProc.run(self.exe, args, env, cb=cb_func, cbargv=cb_arg, do_log=1)
            result = self._cb_done(result, tmpfile_map, stdout)
        except Exception as e:
            result = self._cb_err({'data' : ''}, tmpfile_map)
            raise
        return result
Esempio n. 2
0
 def accumulate_stdout(self, data, stdout):
     #log.debug('script output:\n%s\n' % data)
     data = data.decode('latin-1')
     stdout[0] = stdout[0][-self.max_output:] + data
     now = time.time()
     if now - self.lastlog > 2:
         log.debug('%s: still running: last output:\n%s' % (self.exe, data.strip()))
         self.lastlog = now
Esempio n. 3
0
    def progress(self, data):
        def log_ok(page):
            pass

        def log_err(failure):
            log.error('Error in sending update notifications: %s' % str(failure))

        print '****************** progress search on data:'
        print data
        print '******************'
        g = self.re.search(data)
        if not g:
            #log.debug('progress: no completion in %s' % data)
            return
        completion = g.group(1)
        log.debug('Progress report to %s: completion at %s%%' % (self.url, completion))
        url='%s/%s' % (self.url, completion)
        try:
            data = doHTTP(url)
            log_ok(data)
        except e:
            log_err(e)
            raise
Esempio n. 4
0
                            xmp.set_property_int(str(ns), str(i), int(changes[ns]["fields"][i]["value"][0]))
                        except XMPError, err:
                            log.error("XMPError in set_property_int: %s" % err)
                    elif changes[ns]["fields"][i]["type"] == "float":
                        try:
                            xmp.set_property_float(str(ns), str(i), float(changes[ns]["fields"][i]["value"][0]))
                        except XMPError, err:
                            log.error("XMPError in set_property_float: %s" % err)
                    elif changes[ns]["fields"][i]["type"] == "long":
                        try:
                            xmp.set_property_long(str(ns), str(i), long(changes[ns]["fields"][i]["value"][0]))
                        except XMPError, err:
                            log.error("XMPError in set_property_long: %s" % err)
                    else:
                        try:
                            log.debug("%s %s %s" % (str(ns), str(i), str(changes[ns]["fields"][i]["value"][0])))
                            xmp.set_property(str(ns), str(i), str(changes[ns]["fields"][i]["value"][0]))
                        except XMPError, err:
                            log.error("XMPError in set_property: %s" % err)
                else:

                    # Property IS ARRAY
                    if changes[ns]["fields"][i]["xpath"] != []:  # so it is a structure
                        log.error("Sorry. Array of structures is not supported by xmplib")
                        continue
                    if property_exists == False:
                        # if it is an array and the property does not exist,
                        # it must be created, otherwise, it will not be set.
                        try:
                            if (
                                changes[ns]["fields"][i]["is_array"] == "alt"