• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python timedops.TimedOperation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中timedops.TimedOperation的典型用法代码示例。如果您正苦于以下问题:Python TimedOperation类的具体用法?Python TimedOperation怎么用?Python TimedOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TimedOperation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

class PrinterFinder:
    def __init__ (self):
        self.quit = False

    def find (self, hostname, callback_fn):
        self.hostname = hostname
        self.callback_fn = callback_fn
        self.op = TimedOperation (self._do_find, callback=lambda x, y: None)

    def cancel (self):
        self.op.cancel ()
        self.quit = True

    def _do_find (self):
        self._cached_attributes = dict()
        for fn in [self._probe_jetdirect,
                   self._probe_ipp,
                   self._probe_snmp,
                   self._probe_lpd,
                   self._probe_hplip,
                   self._probe_smb]:
            if self.quit:
                return

            try:
                fn ()
            except Exception, e:
                nonfatalException ()

        # Signal that we've finished.
        if not self.quit:
            self.callback_fn (None)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:32,代码来源:probe_printer.py


示例2: Welcome

class Welcome(Question):
    def __init__ (self, troubleshooter):
        Question.__init__ (self, troubleshooter, "Welcome")
        welcome = gtk.HBox ()
        welcome.set_spacing (12)
        welcome.set_border_width (12)
        image = gtk.Image ()
        image.set_alignment (0, 0)
        image.set_from_stock (gtk.STOCK_PRINT, gtk.ICON_SIZE_DIALOG)
        intro = gtk.Label ('<span weight="bold" size="larger">' +
                           _("Trouble-shooting Printing") +
                           '</span>\n\n' +
                           _("The next few screens will contain some "
                             "questions about your problem with printing. "
                             "Based on your answers a solution may be "
                             "suggested.") + '\n\n' +
                           _("Click 'Forward' to begin."))
        intro.set_alignment (0, 0)
        intro.set_use_markup (True)
        intro.set_line_wrap (True)
        welcome.pack_start (image, False, False, 0)
        welcome.pack_start (intro, True, True, 0)
        page = troubleshooter.new_page (welcome, self)

    def collect_answer (self):
        parent = self.troubleshooter.get_window ()
        # Store the authentication dialog instance in the answers.  This
        # allows the password to be cached.
        factory = AuthConnFactory (parent)
        self.op = TimedOperation (factory.get_connection, parent=parent)
        return {'_authenticated_connection_factory': factory,
                '_authenticated_connection': self.op.run () }

    def cancel_operation (self):
        self.op.cancel ()
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:35,代码来源:Welcome.py


示例3: NetworkCUPSPrinterShared

class NetworkCUPSPrinterShared(Question):
    def __init__ (self, troubleshooter):
        Question.__init__ (self, troubleshooter, "Queue not shared?")
        page = self.initial_vbox (_("Queue Not Shared"),
                                  _("The CUPS printer on the server is not "
                                    "shared."))
        troubleshooter.new_page (page, self)

    def display (self):
        self.answers = {}
        answers = self.troubleshooter.answers
        if ('remote_cups_queue_listed' in answers and
            answers['remote_cups_queue_listed'] == False):
            return False

        parent = self.troubleshooter.get_window ()
        if 'remote_cups_queue_attributes' not in answers:
            if not ('remote_server_try_connect' in answers and
                    'remote_cups_queue' in answers):
                return False

            try:
                host = answers['remote_server_try_connect']
                self.op = TimedOperation (cups.Connection,
                                          kwargs={"host": host},
                                          parent=parent)
                c = self.op.run ()
                self.op = TimedOperation (c.getPrinterAttributes,
                                          args=(answers['remote_cups_queue'],),
                                          parent=parent)
                attr = self.op.run ()
            except RuntimeError:
                return False
            except cups.IPPError:
                return False

            self.answers['remote_cups_queue_attributes'] = attr
        else:
            attr = answers['remote_cups_queue_attributes']

        if 'printer-is-shared' in attr:
            # CUPS >= 1.2
            if not attr['printer-is-shared']:
                return True

        return False

    def can_click_forward (self):
        return False

    def collect_answer (self):
        return self.answers

    def cancel_operation (self):
        self.op.cancel ()
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:55,代码来源:NetworkCUPSPrinterShared.py


示例4: cancel_clicked

    def cancel_clicked (self, widget):
        self.persistent_answers['test_page_jobs_cancelled'] = True
        jobids = []
        for jobid, iter in self.job_to_iter.iteritems ():
            jobids.append (jobid)

        def cancel_jobs (jobids):
            c = self.authconn
            for jobid in jobids:
                try:
                    c.cancelJob (jobid)
                except cups.IPPError as e:
                    (e, s) = e.args
                    if isinstance(s, bytes):
                        s = s.decode('utf-8', 'replace')
                    if e != cups.IPP_NOT_POSSIBLE:
                        self.persistent_answers['test_page_cancel_failure'] = (e, s)

        self.op = TimedOperation (cancel_jobs,
                                  (jobids,),
                                  parent=self.troubleshooter.get_window ())
        try:
            self.op.run ()
        except (OperationCanceled, cups.IPPError):
            pass
开发者ID:incrazyboyy,项目名称:RPiTC-X,代码行数:25,代码来源:PrintTestPage.py


示例5: disconnect_signals

    def disconnect_signals (self):
        if self.bus:
            self.bus.remove_signal_receiver (self.handle_dbus_signal,
                                             path=DBUS_PATH,
                                             dbus_interface=DBUS_IFACE)
                                             
        self.print_button.disconnect (self.print_sigid)
        self.cancel_button.disconnect (self.cancel_sigid)
        self.test_cell.disconnect (self.test_sigid)

        def cancel_subscription (sub_id):
            c = self.authconn
            c.cancelSubscription (sub_id)

        parent = self.troubleshooter.get_window ()
        self.op = TimedOperation (cancel_subscription,
                                  (self.sub_id,),
                                  parent=parent)
        try:
            self.op.run ()
        except (OperationCanceled, cups.IPPError):
            pass

        try:
            del self.sub_seq
        except:
            pass

        GLib.source_remove (self.timer)
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:29,代码来源:PrintTestPage.py


示例6: collect_answer

 def collect_answer (self):
     parent = self.troubleshooter.get_window ()
     # Store the authentication dialog instance in the answers.  This
     # allows the password to be cached.
     factory = AuthConnFactory (parent)
     self.op = TimedOperation (factory.get_connection, parent=parent)
     return {'_authenticated_connection_factory': factory,
             '_authenticated_connection': self.op.run () }
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:8,代码来源:Welcome.py


示例7: collect_answer

    def collect_answer (self):
        answers = self.troubleshooter.answers
        if not answers['cups_queue_listed']:
            return {}

        parent = self.troubleshooter.get_window ()
        self.answers.update (self.persistent_answers)
        if 'error_log_checkpoint' in self.answers:
            return self.answers

        (tmpfd, tmpfname) = tempfile.mkstemp ()
        os.close (tmpfd)
        try:
            self.op = TimedOperation (self.authconn.getFile,
                                      args=('/admin/log/error_log', tmpfname),
                                      parent=parent)
            self.op.run ()
        except (RuntimeError, cups.IPPError):
            try:
                os.remove (tmpfname)
            except OSError:
                pass
        except cups.HTTPError as e:
            try:
                os.remove (tmpfname)
            except OSError:
                pass

            # Abandon the CUPS connection and make another.
            answers = self.troubleshooter.answers
            factory = answers['_authenticated_connection_factory']
            self.authconn = factory.get_connection ()
            self.answers['_authenticated_connection'] = self.authconn

        try:
            statbuf = os.stat (tmpfname)
            os.remove (tmpfname)
        except OSError:
            statbuf = [0, 0, 0, 0, 0, 0, 0]

        self.answers['error_log_checkpoint'] = statbuf[6]
        self.persistent_answers['error_log_checkpoint'] = statbuf[6]

        if journal:
            j = journal.Reader ()
            j.seek_tail ()
            cursor = j.get_previous ()['__CURSOR']
            self.answers['error_log_cursor'] = cursor
            self.persistent_answers['error_log_cursor'] = cursor

        return self.answers
开发者ID:daniel-dressler,项目名称:system-config-printer,代码行数:51,代码来源:ErrorLogCheckpoint.py


示例8: SchedulerNotRunning

class SchedulerNotRunning(Question):
    def __init__ (self, troubleshooter):
        Question.__init__ (self, troubleshooter, "Scheduler not running?")
        page = self.initial_vbox (_("CUPS Service Stopped"),
                                  _("The CUPS print spooler does not appear "
                                    "to be running.  To correct this, choose "
                                    "System->Administration->Services from "
                                    "the main menu and look for the 'cups' "
                                    "service."))
        troubleshooter.new_page (page, self)

    def display (self):
        self.answers = {}
        if self.troubleshooter.answers.get ('cups_queue_listed', False):
            return False

        parent = self.troubleshooter.get_window ()

        # Find out if CUPS is running.
        failure = False
        try:
            self.op = TimedOperation (cups.Connection,
                                      parent=parent)
            c = self.op.run ()
        except RuntimeError:
            failure = True

        self.answers['cups_connection_failure'] = failure
        return failure

    def can_click_forward (self):
        return False

    def collect_answer (self):
        return self.answers

    def cancel_operation (self):
        self.op.cancel ()
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:38,代码来源:SchedulerNotRunning.py


示例9: display

    def display (self):
        self.answers = {}
        answers = self.troubleshooter.answers
        if ('remote_cups_queue_listed' in answers and
            answers['remote_cups_queue_listed'] == False):
            return False

        parent = self.troubleshooter.get_window ()
        if 'remote_cups_queue_attributes' not in answers:
            if not ('remote_server_try_connect' in answers and
                    'remote_cups_queue' in answers):
                return False

            try:
                host = answers['remote_server_try_connect']
                self.op = TimedOperation (cups.Connection,
                                          kwargs={"host": host},
                                          parent=parent)
                c = self.op.run ()
                self.op = TimedOperation (c.getPrinterAttributes,
                                          args=(answers['remote_cups_queue'],),
                                          parent=parent)
                attr = self.op.run ()
            except RuntimeError:
                return False
            except cups.IPPError:
                return False

            self.answers['remote_cups_queue_attributes'] = attr
        else:
            attr = answers['remote_cups_queue_attributes']

        if 'printer-is-shared' in attr:
            # CUPS >= 1.2
            if not attr['printer-is-shared']:
                return True

        return False
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:38,代码来源:NetworkCUPSPrinterShared.py


示例10: collect_answer

    def collect_answer (self):
        if not self.displayed:
            return {}

        self.answers = self.persistent_answers.copy ()
        parent = self.troubleshooter.get_window ()
        success = self.yes.get_active ()
        self.answers['test_page_successful'] = success

        class collect_jobs:
            def __init__ (self, model):
                self.jobs = []
                model.foreach (self.each, None)

            def each (self, model, path, iter, user_data):
                self.jobs.append (model.get (iter, 0, 1, 2, 3, 4))

        model = self.treeview.get_model ()
        jobs = collect_jobs (model).jobs
        def collect_attributes (jobs):
            job_attrs = None
            c = self.authconn
            with_attrs = []
            for (test, jobid, printer, doc, status) in jobs:
                attrs = None
                if test:
                    try:
                        attrs = c.getJobAttributes (jobid)
                    except AttributeError:
                        # getJobAttributes was introduced in pycups 1.9.35.
                        if job_attrs == None:
                            job_attrs = c.getJobs (which_jobs='all')

                        attrs = self.job_attrs[jobid]

                with_attrs.append ((test, jobid, printer, doc, status, attrs))

            return with_attrs

        self.op = TimedOperation (collect_attributes,
                                  (jobs,),
                                  parent=parent)
        try:
            with_attrs = self.op.run ()
            self.answers['test_page_job_status'] = with_attrs
        except (OperationCanceled, cups.IPPError):
            pass

        return self.answers
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:49,代码来源:PrintTestPage.py


示例11: collect_answer

    def collect_answer (self):
        answers = self.troubleshooter.answers
        if not answers['cups_queue_listed']:
            return {}

        parent = self.troubleshooter.get_window ()
        self.answers.update (self.persistent_answers)
        if 'error_log_checkpoint' in self.answers:
            return self.answers

        tmpf = NamedTemporaryFile()
        try:
            self.op = TimedOperation (self.authconn.getFile,
                                        args=["/admin/log/error_log"],
                                        kwargs={'file': tmpf},
                                        parent=parent)
            self.op.run ()
        except (RuntimeError, cups.IPPError) as e:
            self.answers['error_log_checkpoint_exc'] = e
        except cups.HTTPError as e:
            self.answers['error_log_checkpoint_exc'] = e

            # Abandon the CUPS connection and make another.
            answers = self.troubleshooter.answers
            factory = answers['_authenticated_connection_factory']
            self.authconn = factory.get_connection ()
            self.answers['_authenticated_connection'] = self.authconn

        try:
            statbuf = os.stat (tmpf.name)
        except OSError:
            statbuf = [0, 0, 0, 0, 0, 0, 0]

        self.answers['error_log_checkpoint'] = statbuf[6]
        self.persistent_answers['error_log_checkpoint'] = statbuf[6]

        if journal:
            j = journal.Reader ()
            j.seek_tail ()
            cursor = j.get_previous ()['__CURSOR']
            self.answers['error_log_cursor'] = cursor
            self.persistent_answers['error_log_cursor'] = cursor
            now = datetime.datetime.fromtimestamp (time.time ())
            timestamp = now.strftime ("%F %T")
            self.answers['error_log_timestamp'] = timestamp
            self.persistent_answers['error_log_timestamp'] = timestamp

        return self.answers
开发者ID:bigon,项目名称:system-config-printer,代码行数:48,代码来源:ErrorLogCheckpoint.py


示例12: display

    def display (self):
        self.answers = {}
        if self.troubleshooter.answers.get ('cups_queue_listed', False):
            return False

        parent = self.troubleshooter.get_window ()

        # Find out if CUPS is running.
        failure = False
        try:
            self.op = TimedOperation (cups.Connection,
                                      parent=parent)
            c = self.op.run ()
        except RuntimeError:
            failure = True

        self.answers['cups_connection_failure'] = failure
        return failure
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:18,代码来源:SchedulerNotRunning.py


示例13: display

    def display (self):
        self.answers = {}
        answers = self.troubleshooter.answers
        if not answers['cups_queue_listed']:
            return False

        self.authconn = answers['_authenticated_connection']
        parent = self.troubleshooter.get_window ()

        def getServerSettings ():
            # Fail if auth required.
            cups.setPasswordCB (lambda x: '')
            cups.setServer ('')
            c = cups.Connection ()
            return c.adminGetServerSettings ()

        try:
            self.op = TimedOperation (getServerSettings, parent=parent)
            settings = self.op.run ()
        except RuntimeError:
            return False
        except cups.IPPError:
            settings = {}

        self.forward_allowed = False
        self.label.set_text ('')
        if len (settings.keys ()) == 0:
            # Requires root
            return True
        else:
            self.persistent_answers['cups_server_settings'] = settings

        try:
            if int (settings[cups.CUPS_SERVER_DEBUG_LOGGING]) != 0:
                # Already enabled
                return False
        except KeyError:
            pass
        except ValueError:
            pass

        return True
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:42,代码来源:ErrorLogCheckpoint.py


示例14: collect_answer

    def collect_answer (self):
        answers = self.troubleshooter.answers
        if not answers['cups_queue_listed']:
            return {}

        parent = self.troubleshooter.get_window ()
        self.answers.update (self.persistent_answers)
        if self.answers.has_key ('error_log_checkpoint'):
            return self.answers

        (tmpfd, tmpfname) = tempfile.mkstemp ()
        os.close (tmpfd)
        try:
            self.op = TimedOperation (self.authconn.getFile,
                                      args=('/admin/log/error_log', tmpfname),
                                      parent=parent)
            self.op.run ()
        except RuntimeError:
            try:
                os.remove (tmpfname)
            except OSError:
                pass

            return self.answers
        except cups.IPPError:
            try:
                os.remove (tmpfname)
            except OSError:
                pass

            return self.answers

        statbuf = os.stat (tmpfname)
        os.remove (tmpfname)
        self.answers['error_log_checkpoint'] = statbuf[6]
        self.persistent_answers['error_log_checkpoint'] = statbuf[6]
        return self.answers
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:37,代码来源:ErrorLogCheckpoint.py


示例15: connect_signals

    def connect_signals (self, handler):
        self.print_sigid = self.print_button.connect ("clicked",
                                                      self.print_clicked)
        self.cancel_sigid = self.cancel_button.connect ("clicked",
                                                        self.cancel_clicked)
        self.test_sigid = self.test_cell.connect ('toggled',
                                                  self.test_toggled)

        def create_subscription ():
            c = self.authconn
            sub_id = c.createSubscription ("/",
                                           events=["job-created",
                                                   "job-completed",
                                                   "job-stopped",
                                                   "job-progress",
                                                   "job-state-changed"])
            return sub_id

        parent = self.troubleshooter.get_window ()
        self.op = TimedOperation (create_subscription, parent=parent)
        try:
            self.sub_id = self.op.run ()
        except (OperationCanceled, cups.IPPError):
            pass

        try:
            bus = dbus.SystemBus ()
        except:
            bus = None

        self.bus = bus
        if bus:
            bus.add_signal_receiver (self.handle_dbus_signal,
                                     path=DBUS_PATH,
                                     dbus_interface=DBUS_IFACE)

        self.timer = GLib.timeout_add_seconds (1, self.update_jobs_list)
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:37,代码来源:PrintTestPage.py


示例16: display

    def display (self):
        answers = self.troubleshooter.answers
        parent = self.troubleshooter.get_window ()
        self.answers = {}
        checkpoint = answers.get ('error_log_checkpoint')
        cursor = answers.get ('error_log_cursor')
        timestamp = answers.get ('error_log_timestamp')

        if ('error_log' in self.persistent_answers or
            'journal' in self.persistent_answers):
            checkpoint = None
            cursor = None

        def fetch_log (c):
            prompt = c._get_prompt_allowed ()
            c._set_prompt_allowed (False)
            c._connect ()
            with tempfile.NamedTemporaryFile (delete=False) as tmpf:
                success = False
                try:
                    c.getFile ('/admin/log/error_log', tmpf.file)
                    success = True
                except cups.HTTPError:
                    try:
                        os.remove (tmpf.file)
                    except OSError:
                        pass

                c._set_prompt_allowed (prompt)
                if success:
                    return tmpf.file

            return None

        now = datetime.datetime.fromtimestamp (time.time ()).strftime ("%F %T")
        self.authconn = self.troubleshooter.answers['_authenticated_connection']
        if 'error_log_debug_logging_set' in answers:
            try:
                self.op = TimedOperation (self.authconn.adminGetServerSettings,
                                          parent=parent)
                settings = self.op.run ()
            except cups.IPPError:
                return False

            settings[cups.CUPS_SERVER_DEBUG_LOGGING] = '0'
            orig_settings = answers['cups_server_settings']
            settings['MaxLogSize'] = orig_settings.get ('MaxLogSize', '2000000')
            success = False
            def set_settings (connection, settings):
                connection.adminSetServerSettings (settings)

                # Now reconnect.
                attempt = 1
                while attempt <= 5:
                    try:
                        time.sleep (1)
                        connection._connect ()
                        break
                    except RuntimeError:
                        # Connection failed
                        attempt += 1

            try:

                self.op = TimedOperation (set_settings,
                                          (self.authconn, settings),
                                          parent=parent)
                self.op.run ()
                self.persistent_answers['error_log_debug_logging_unset'] = True
            except cups.IPPError:
                pass

        self.answers = {}
        if journal and cursor != None:
            def journal_format (x):
                try:
                    priority = "XACEWNIDd"[x['PRIORITY']]
                except (IndexError, TypeError):
                    priority = " "

                return (priority + " " +
                        x['__REALTIME_TIMESTAMP'].strftime("[%m/%b/%Y:%T]") +
                        " " + x['MESSAGE'])

            r = journal.Reader ()
            r.seek_cursor (cursor)
            r.add_match (_SYSTEMD_UNIT="cups.service")
            self.answers['journal'] = [journal_format (x) for x in r]

        if checkpoint != None:
            self.op = TimedOperation (fetch_log,
                                      (self.authconn,),
                                      parent=parent)
            tmpfname = self.op.run ()
            if tmpfname != None:
                f = open (tmpfname)
                f.seek (checkpoint)
                lines = f.readlines ()
                os.remove (tmpfname)
                self.answers = { 'error_log': [x.strip () for x in lines] }
#.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:101,代码来源:ErrorLogFetch.py


示例17: ErrorLogFetch

class ErrorLogFetch(Question):
    def __init__ (self, troubleshooter):
        Question.__init__ (self, troubleshooter, "Error log fetch")
        page = self.initial_vbox (_("Retrieve Journal Entries"),
                                  _("No system journal entries were found. "
                                    "This may be because you are not an "
                                    "administrator. To fetch journal entries "
                                    "please run this command:"))
        self.entry = Gtk.Entry ()
        self.entry.set_editable (False)
        page.pack_start (self.entry, False, False, 0)
        troubleshooter.new_page (page, self)
        self.persistent_answers = {}

    def display (self):
        answers = self.troubleshooter.answers
        parent = self.troubleshooter.get_window ()
        self.answers = {}
        checkpoint = answers.get ('error_log_checkpoint')
        cursor = answers.get ('error_log_cursor')
        timestamp = answers.get ('error_log_timestamp')

        if ('error_log' in self.persistent_answers or
            'journal' in self.persistent_answers):
            checkpoint = None
            cursor = None

        def fetch_log (c):
            prompt = c._get_prompt_allowed ()
            c._set_prompt_allowed (False)
            c._connect ()
            with tempfile.NamedTemporaryFile (delete=False) as tmpf:
                success = False
                try:
                    c.getFile ('/admin/log/error_log', tmpf.file)
                    success = True
                except cups.HTTPError:
                    try:
                        os.remove (tmpf.file)
                    except OSError:
                        pass

                c._set_prompt_allowed (prompt)
                if success:
                    return tmpf.file

            return None

        now = datetime.datetime.fromtimestamp (time.time ()).strftime ("%F %T")
        self.authconn = self.troubleshooter.answers['_authenticated_connection']
        if 'error_log_debug_logging_set' in answers:
            try:
                self.op = TimedOperation (self.authconn.adminGetServerSettings,
                                          parent=parent)
                settings = self.op.run ()
            except cups.IPPError:
                return False

            settings[cups.CUPS_SERVER_DEBUG_LOGGING] = '0'
            orig_settings = answers['cups_server_settings']
            settings['MaxLogSize'] = orig_settings.get ('MaxLogSize', '2000000')
            success = False
            def set_settings (connection, settings):
                connection.adminSetServerSettings (settings)

                # Now reconnect.
                attempt = 1
                while attempt <= 5:
                    try:
                        time.sleep (1)
                        connection._connect ()
                        break
                    except RuntimeError:
                        # Connection failed
                        attempt += 1

            try:

                self.op = TimedOperation (set_settings,
                                          (self.authconn, settings),
                                          parent=parent)
                self.op.run ()
                self.persistent_answers['error_log_debug_logging_unset'] = True
            except cups.IPPError:
                pass

        self.answers = {}
        if journal and cursor != None:
            def journal_format (x):
                try:
                    priority = "XACEWNIDd"[x['PRIORITY']]
                except (IndexError, TypeError):
                    priority = " "

                return (priority + " " +
                        x['__REALTIME_TIMESTAMP'].strftime("[%m/%b/%Y:%T]") +
                        " " + x['MESSAGE'])

            r = journal.Reader ()
            r.seek_cursor (cursor)
#.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:101,代码来源:ErrorLogFetch.py


示例18: display

    def display (self):
        # Collect information useful for the various checks.

        self.answers = {}

        answers = self.troubleshooter.answers
        if not answers['cups_queue_listed']:
            return False

        name = answers['cups_queue']

        parent = self.troubleshooter.get_window ()

        # Find out if this is a printer or a class.
        try:
            cups.setServer ('')
            c = TimedOperation (cups.Connection, parent=parent).run ()
            printers = TimedOperation (c.getPrinters, parent=parent).run ()
            if printers.has_key (name):
                self.answers['is_cups_class'] = False
                queue = printers[name]
                self.answers['cups_printer_dict'] = queue
            else:
                self.answers['is_cups_class'] = True
                classes = TimedOperation (c.getClasses, parent=parent).run ()
                queue = classes[name]
                self.answers['cups_class_dict'] = queue

            attrs = TimedOperation (c.getPrinterAttributes, (name,),
                                    parent=parent).run ()
            self.answers['local_cups_queue_attributes'] = attrs
        except:
            pass

        if self.answers.has_key ('cups_printer_dict'):
            cups_printer_dict = self.answers['cups_printer_dict']
            uri = cups_printer_dict['device-uri']
            (scheme, rest) = urllib.splittype (uri)
            self.answers['cups_device_uri_scheme'] = scheme
            if scheme in ["ipp", "http", "https"]:
                (hostport, rest) = urllib.splithost (rest)
                (host, port) = urllib.splitnport (hostport, defport=631)
                self.answers['remote_server_name'] = host
                self.answers['remote_server_port'] = port
            elif scheme == "smb":
                u = smburi.SMBURI (uri)
                (group, host, share, user, password) = u.separate ()
                new_environ = os.environ.copy()
                new_environ['LC_ALL'] = "C"
                if group:
                    args = ["nmblookup", "-W", group, host]
                else:
                    args = ["nmblookup", host]
                try:
                    p = TimedSubprocess (parent=parent,
                                         timeout=5000,
                                         args=args,
                                         env=new_environ,
                                         close_fds=True,
                                         stdin=file("/dev/null"),
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
                    result = p.run ()
                    self.answers['nmblookup_output'] = result
                    for line in result[0]:
                        if line.startswith ("querying"):
                            continue
                        spc = line.find (' ')
                        if (spc != -1 and
                            not line[spc:].startswith (" failed ")):
                            # Remember the IP address.
                            self.answers['remote_server_name'] = line[:spc]
                            break
                except OSError:
                    # Problem executing command.
                    pass
            elif scheme == "hp":
                new_environ = os.environ.copy()
                new_environ['LC_ALL'] = "C"
                new_environ['DISPLAY'] = ""
                try:
                    p = TimedSubprocess (parent=parent,
                                         timeout=3000,
                                         args=["hp-info", "-d" + uri],
                                         close_fds=True,
                                         env=new_environ,
                                         stdin=file("/dev/null"),
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
                    self.answers['hplip_output'] = p.run ()
                except OSError:
                    # Problem executing command.
                    pass

            r = cups_printer_dict['printer-type'] & cups.CUPS_PRINTER_REMOTE
            self.answers['cups_printer_remote'] = (r != 0)
        return False
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:97,代码来源:CheckPrinterSanity.py


示例19: _on_authentication_response

            self._on_authentication_response (d, response)

    def _on_authentication_response (self, dialog, response):
        (user, self._use_password) = dialog.get_auth_info ()
        if user != '':
            self._use_user = user
        global_authinfocache.cache_auth_info ((self._use_user,
                                               self._use_password),
                                              host=self._server,
                                              port=self._port)
        dialog.destroy ()

        if (response == Gtk.ResponseType.CANCEL or
            response == Gtk.ResponseType.DELETE_EVENT):
            self._cancel = True

        if self._lock:
            self._gui_event.set ()

if __name__ == '__main__':
    # Test it out.
    Gdk.threads_init ()
    from timedops import TimedOperation
    set_debugging (True)
    c = TimedOperation (Connection, args=(None,)).run ()
    debugprint ("Connected")
    c._set_lock (True)
    print(TimedOperation (c.getFile,
                          args=('/admin/conf/cupsd.conf',
                                '/dev/stdout')).run ())
开发者ID:Distrotech,项目名称:system-config-printer,代码行数:30,代码来源:authconn.py


示例20: find

 def find (self, hostname, callback_fn):
     self.hostname = hostname
     self.callback_fn = callback_fn
     self.op = TimedOperation (self._do_find, callback=lambda x, y: None)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:4,代码来源:probe_printer.py



注:本文中的timedops.TimedOperation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python timedops.TimedSubprocess类代码示例发布时间:2022-05-27
下一篇:
Python timecode.Timecode类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap