Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
monitor.Monitor Class Reference
Collaboration diagram for monitor.Monitor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get_printers
def get_jobs
def get_ppdcache
def cleanup
def set_process_pending
def check_still_connecting
def update_connecting_devices
def check_state_reasons
def get_notifications
def refresh
def fetch_jobs
def sort_jobs_by_printer
def update_jobs
def update
def handle_dbus_signal

Public Attributes

 my_jobs
 specific_dests
 monitor_jobs
 jobs
 printer_state_reasons
 printers
 process_pending_events
 fetch_jobs_timer
 cups_connection_in_error
 user
 host
 port
 encryption
 ppdcache
 which_jobs
 reasons_seen
 connecting_timers
 still_connecting
 connecting_to_device
 received_any_dbus_signals
 update_timer
 bus
 sub_id
 sub_seq
 fetch_first_job_id

Static Public Attributes

string DBUS_PATH = "/com/redhat/PrinterSpooler"
string DBUS_IFACE = "com.redhat.PrinterSpooler"

Static Private Attributes

dictionary __gsignals__

Detailed Description

Definition at line 64 of file monitor.py.


Constructor & Destructor Documentation

def monitor.Monitor.__init__ (   self,
  bus = None,
  my_jobs = True,
  specific_dests = None,
  monitor_jobs = True,
  host = None,
  port = None,
  encryption = None 
)

Definition at line 110 of file monitor.py.

00110 
00111                  port=None, encryption=None):
00112         gobject.GObject.__init__ (self)
00113         self.my_jobs = my_jobs
00114         self.specific_dests = specific_dests
00115         self.monitor_jobs = monitor_jobs
00116         self.jobs = {}
00117         self.printer_state_reasons = {}
00118         self.printers = set()
00119         self.process_pending_events = True
00120         self.fetch_jobs_timer = None
00121         self.cups_connection_in_error = False
00122 
00123         if host:
00124             cups.setServer (host)
00125         if port:
00126             cups.setPort (port)
00127         if encryption:
00128             cups.setEncryption (encryption)
00129         self.user = cups.getUser ()
00130         self.host = cups.getServer ()
00131         self.port = cups.getPort ()
00132         self.encryption = cups.getEncryption ()
00133         self.ppdcache = ppdcache.PPDCache (host=self.host,
00134                                            port=self.port,
00135                                            encryption=self.encryption)
00136 
00137         self.which_jobs = "not-completed"
00138         self.reasons_seen = {}
00139         self.connecting_timers = {}
00140         self.still_connecting = set()
00141         self.connecting_to_device = {}
00142         self.received_any_dbus_signals = False
00143         self.update_timer = None
00144 
00145         if bus == None:
00146             try:
00147                 bus = dbus.SystemBus ()
00148             except dbus.exceptions.DBusException:
00149                 # System bus not running.
00150                 pass
00151 
00152         self.bus = bus
00153         if bus != None:
00154             bus.add_signal_receiver (self.handle_dbus_signal,
00155                                      path=self.DBUS_PATH,
00156                                      dbus_interface=self.DBUS_IFACE)
00157         self.sub_id = -1


Member Function Documentation

def monitor.Monitor.check_state_reasons (   self,
  my_printers = set(),
  printer_jobs = {} 
)

Definition at line 279 of file monitor.py.

00279 
00280     def check_state_reasons(self, my_printers=set(), printer_jobs={}):
00281         # Look for any new reasons since we last checked.
00282         old_reasons_seen_keys = self.reasons_seen.keys ()
00283         reasons_now = set()
00284         for printer, reasons in self.printer_state_reasons.iteritems ():
00285             for reason in reasons:
00286                 tuple = reason.get_tuple ()
00287                 printer = reason.get_printer ()
00288                 reasons_now.add (tuple)
00289                 if not self.reasons_seen.has_key (tuple):
00290                     # New reason.
00291                     self.emit ('state-reason-added', reason)
00292                     self.reasons_seen[tuple] = reason
00293 
00294                 if (reason.get_reason () == "connecting-to-device" and
00295                     not self.connecting_to_device.has_key (printer)):
00296                     # First time we've seen this.
00297 
00298                     have_processing_job = False
00299                     for job, data in \
00300                             printer_jobs.get (printer, {}).iteritems ():
00301                         state = data.get ('job-state',
00302                                           cups.IPP_JOB_CANCELED)
00303                         if state == cups.IPP_JOB_PROCESSING:
00304                             have_processing_job = True
00305                             break
00306 
00307                     if have_processing_job:
00308                         t = gobject.timeout_add_seconds (
00309                             (1 + CONNECTING_TIMEOUT),
00310                             self.check_still_connecting,
00311                             printer)
00312                         self.connecting_timers[printer] = t
00313                         debugprint ("Start connecting timer for `%s'" %
00314                                     printer)
00315                     else:
00316                         # Don't notify about this, as it must be stale.
00317                         debugprint ("Ignoring stale connecting-to-device")
00318                         if get_debugging ():
00319                             debugprint (pprint.pformat (printer_jobs))
00320 
00321         self.update_connecting_devices (printer_jobs)
00322         items = self.reasons_seen.keys ()
00323         for tuple in items:
00324             if not tuple in reasons_now:
00325                 # Reason no longer present.
00326                 reason = self.reasons_seen[tuple]
00327                 del self.reasons_seen[tuple]
00328                 self.emit ('state-reason-removed', reason)

Here is the call graph for this function:

Here is the caller graph for this function:

def monitor.Monitor.check_still_connecting (   self,
  printer 
)
Timer callback to check on connecting-to-device reasons.

Definition at line 198 of file monitor.py.

00198 
00199     def check_still_connecting(self, printer):
00200         """Timer callback to check on connecting-to-device reasons."""
00201         if not self.process_pending_events:
00202             # Defer the timer by setting a new one.
00203             timer = gobject.timeout_add (200, self.check_still_connecting,
00204                                          printer)
00205             self.connecting_timers[printer] = timer
00206             return False
00207 
00208         if self.connecting_timers.has_key (printer):
00209             del self.connecting_timers[printer]
00210 
00211         debugprint ("Still-connecting timer fired for `%s'" % printer)
00212         (printer_jobs, my_printers) = self.sort_jobs_by_printer ()
00213         self.update_connecting_devices (printer_jobs)
00214 
00215         # Don't run this callback again.
00216         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def monitor.Monitor.cleanup (   self)

Definition at line 167 of file monitor.py.

00167 
00168     def cleanup (self):
00169         if self.sub_id != -1:
00170             user = cups.getUser ()
00171             try:
00172                 cups.setUser (self.user)
00173                 c = cups.Connection (host=self.host,
00174                                      port=self.port,
00175                                      encryption=self.encryption)
00176                 c.cancelSubscription (self.sub_id)
00177                 debugprint ("Canceled subscription %d" % self.sub_id)
00178             except:
00179                 pass
00180             cups.setUser (user)
00181 
00182         if self.bus != None:
00183             self.bus.remove_signal_receiver (self.handle_dbus_signal,
00184                                              path=self.DBUS_PATH,
00185                                              dbus_interface=self.DBUS_IFACE)
00186 
00187         timers = self.connecting_timers.values ()
00188         for timer in [self.update_timer, self.fetch_jobs_timer]:
00189             if timer:
00190                 timers.append (timer)
00191         for timer in timers:
00192             gobject.source_remove (timer)
00193 
00194         self.emit ('monitor-exited')

Here is the call graph for this function:

def monitor.Monitor.fetch_jobs (   self,
  refresh_all 
)

Definition at line 607 of file monitor.py.

00607 
00608     def fetch_jobs (self, refresh_all):
00609         if not self.process_pending_events:
00610             # Skip this call.  We'll get called again soon.
00611             return True
00612 
00613         user = cups.getUser ()
00614         try:
00615             cups.setUser (self.user)
00616             c = cups.Connection (host=self.host,
00617                                  port=self.port,
00618                                  encryption=self.encryption)
00619         except RuntimeError:
00620             self.emit ('cups-connection-error')
00621             self.fetch_jobs_timer = None
00622             cups.setUser (user)
00623             return False
00624 
00625         limit = 1
00626         r = ["job-id",
00627              "job-printer-uri",
00628              "job-state",
00629              "job-originating-user-name",
00630              "job-k-octets",
00631              "job-name",
00632              "time-at-creation"]
00633         try:
00634             fetched = c.getJobs (which_jobs=self.which_jobs,
00635                                  my_jobs=self.my_jobs,
00636                                  first_job_id=self.fetch_first_job_id,
00637                                  limit=limit,
00638                                  requested_attributes=r)
00639         except cups.IPPError, (e, m):
00640             self.emit ('cups-ipp-error', e, m)
00641             self.fetch_jobs_timer = None
00642             cups.setUser (user)
00643             return False
00644 
00645         cups.setUser (user)
00646         got = len (fetched)
00647         debugprint ("Got %s jobs, asked for %s" % (got, limit))
00648 
00649         jobs = self.jobs.copy ()
00650         jobids = fetched.keys ()
00651         jobids.sort ()
00652         if got > 0:
00653             last_jobid = jobids[got - 1]
00654             if last_jobid < self.fetch_first_job_id:
00655                 last_jobid = self.fetch_first_job_id + limit - 1
00656                 debugprint ("Unexpected job IDs returned: %s" % repr (jobids))
00657                 debugprint ("That's not what we asked for!")
00658         else:
00659             last_jobid = self.fetch_first_job_id + limit - 1
00660         for jobid in xrange (self.fetch_first_job_id, last_jobid + 1):
00661             try:
00662                 job = fetched[jobid]
00663                 if self.specific_dests != None:
00664                     uri = job.get('job-printer-uri', '/')
00665                     i = uri.rfind ('/')
00666                     printer = uri[i + 1:]
00667                     if printer not in self.specific_dests:
00668                         raise KeyError
00669 
00670                 if jobs.has_key (jobid):
00671                     n = 'job-event'
00672                 else:
00673                     n = 'job-added'
00674 
00675                 jobs[jobid] = job
00676                 self.emit (n, jobid, '', {}, job.copy ())
00677             except KeyError:
00678                 # No job by that ID.
00679                 if jobs.has_key (jobid):
00680                     del jobs[jobid]
00681                     self.emit ('job-removed', jobid, '', {})
00682 
00683         jobids = jobs.keys ()
00684         jobids.sort ()
00685         if got < limit:
00686             trim = False
00687             for i in range (len (jobids)):
00688                 jobid = jobids[i]
00689                 if not trim and jobid > last_jobid:
00690                     trim = True
00691             
00692                 if trim:
00693                     del jobs[jobid]
00694                     self.emit ('job-removed', jobid, '', {})
00695 
00696         self.update_jobs (jobs)
00697         self.jobs = jobs
00698 
00699         if got < limit:
00700             # That's all.  Don't run this timer again.
00701             self.fetch_jobs_timer = None
00702             return False
00703 
00704         # Remember where we got up to and run this timer again.
00705         next = jobid + 1
00706 
00707         while not refresh_all and self.jobs.has_key (next):
00708             next += 1
00709 
00710         self.fetch_first_job_id = next
00711         return True

Here is the call graph for this function:

def monitor.Monitor.get_jobs (   self)

Definition at line 161 of file monitor.py.

00161 
00162     def get_jobs (self):
00163         return self.jobs.copy ()

Definition at line 329 of file monitor.py.

00329 
00330     def get_notifications(self):
00331         if not self.process_pending_events:
00332             # Defer the timer callback.
00333             if self.update_timer:
00334                 gobject.source_remove (self.update_timer)
00335 
00336             self.update_timer = gobject.timeout_add (200,
00337                                                      self.get_notifications)
00338             debugprint ("Deferred get_notifications by 200ms")
00339             return False
00340 
00341         debugprint ("get_notifications")
00342         user = cups.getUser ()
00343         try:
00344             cups.setUser (self.user)
00345             c = cups.Connection (host=self.host,
00346                                  port=self.port,
00347                                  encryption=self.encryption)
00348 
00349             try:
00350                 try:
00351                     notifications = c.getNotifications ([self.sub_id],
00352                                                         [self.sub_seq + 1])
00353                 except AttributeError:
00354                     notifications = c.getNotifications ([self.sub_id])
00355             except cups.IPPError, (e, m):
00356                 cups.setUser (user)
00357                 if e == cups.IPP_NOT_FOUND:
00358                     # Subscription lease has expired.
00359                     self.sub_id = -1
00360                     debugprint ("Subscription not found, will refresh")
00361                     self.refresh ()
00362                     return False
00363 
00364                 self.emit ('cups-ipp-error', e, m)
00365                 if e == cups.IPP_FORBIDDEN:
00366                     return False
00367 
00368                 debugprint ("getNotifications failed with %d (%s)" % (e, m))
00369                 return True
00370         except RuntimeError:
00371             cups.setUser (user)
00372             debugprint ("cups-connection-error, will retry")
00373             self.cups_connection_in_error = True
00374             self.emit ('cups-connection-error')
00375             return True
00376 
00377         if self.cups_connection_in_error:
00378             self.cups_connection_in_error = False
00379             debugprint ("cups-connection-recovered")
00380             self.emit ('cups-connection-recovered')
00381 
00382         cups.setUser (user)
00383         jobs = self.jobs.copy ()
00384         for event in notifications['events']:
00385             seq = event['notify-sequence-number']
00386             self.sub_seq = seq
00387             nse = event['notify-subscribed-event']
00388             debugprint ("%d %s %s" % (seq, nse, event['notify-text']))
00389             if get_debugging ():
00390                 debugprint (pprint.pformat (event))
00391             if nse.startswith ('printer-'):
00392                 # Printer events
00393                 name = event['printer-name']
00394                 if nse == 'printer-added' and name not in self.printers:
00395                     self.printers.add (name)
00396                     self.emit ('printer-added', name)
00397 
00398                 elif nse == 'printer-deleted' and name in self.printers:
00399                     self.printers.remove (name)
00400                     items = self.reasons_seen.keys ()
00401                     for tuple in items:
00402                         if tuple[1] == name:
00403                             reason = self.reasons_seen[tuple]
00404                             del self.reasons_seen[tuple]
00405                             self.emit ('state-reason-removed', reason)
00406                             
00407                     if self.printer_state_reasons.has_key (name):
00408                         del self.printer_state_reasons[name]
00409 
00410                     self.emit ('printer-removed', name)
00411                 elif name in self.printers:
00412                     printer_state_reasons = event['printer-state-reasons']
00413                     reasons = []
00414                     for reason in printer_state_reasons:
00415                         if reason == "none":
00416                             break
00417                         if state_reason_is_harmless (reason):
00418                             continue
00419                         reasons.append (StateReason (name, reason,
00420                                                      self.ppdcache))
00421                     self.printer_state_reasons[name] = reasons
00422 
00423                     self.emit ('printer-event', name, nse, event)
00424                 continue
00425 
00426             # Job events
00427             if not nse.startswith ("job-"):
00428                 # Some versions of CUPS give empty
00429                 # notify-subscribed-event attributes (STR #3608).
00430                 debugprint ("Unhandled nse %s" % repr (nse))
00431                 continue
00432 
00433             jobid = event['notify-job-id']
00434             if (nse == 'job-created' or
00435                 (nse == 'job-state-changed' and
00436                  not jobs.has_key (jobid) and
00437                  event['job-state'] == cups.IPP_JOB_PROCESSING)):
00438                 if (self.specific_dests != None and
00439                     event['printer-name'] not in self.specific_dests):
00440                     continue
00441 
00442                 try:
00443                     attrs = c.getJobAttributes (jobid)
00444                     if (self.my_jobs and
00445                         attrs['job-originating-user-name'] != cups.getUser ()):
00446                         continue
00447 
00448                     jobs[jobid] = attrs
00449                 except KeyError:
00450                     jobs[jobid] = {'job-k-octets': 0}
00451                 except cups.IPPError, (e, m):
00452                     self.emit ('cups-ipp-error', e, m)
00453                     jobs[jobid] = {'job-k-octets': 0}
00454 
00455                 self.emit ('job-added', jobid, nse, event, jobs[jobid].copy ())
00456             elif (nse == 'job-completed' or
00457                   (nse == 'job-state-changed' and
00458                    event['job-state'] == cups.IPP_JOB_COMPLETED)):
00459                 if not (self.which_jobs in ['completed', 'all']):
00460                     try:
00461                         del jobs[jobid]
00462                         self.emit ('job-removed', jobid, nse, event)
00463                     except KeyError:
00464                         pass
00465                     continue
00466 
00467             try:
00468                 job = jobs[jobid]
00469             except KeyError:
00470                 continue
00471 
00472             for attribute in ['job-state',
00473                               'job-name']:
00474                 job[attribute] = event[attribute]
00475             if event.has_key ('notify-printer-uri'):
00476                 job['job-printer-uri'] = event['notify-printer-uri']
00477 
00478             self.emit ('job-event', jobid, nse, event, job.copy ())
00479 
00480         self.set_process_pending (False)
00481         self.update_jobs (jobs)
00482         self.jobs = jobs
00483         self.set_process_pending (True)
00484 
00485         # Update again when we're told to.  If we're getting CUPS
00486         # D-Bus signals, however, rely on those instead.
00487         if not self.received_any_dbus_signals:
00488             if self.update_timer:
00489                 gobject.source_remove (self.update_timer)
00490 
00491             interval = notifications['notify-get-interval']
00492             t = gobject.timeout_add_seconds (interval,
00493                                              self.get_notifications)
00494             debugprint ("Next notifications fetch in %ds" % interval)
00495             self.update_timer = t
00496 
00497         return False

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file monitor.py.

00164 
00165     def get_ppdcache (self):
00166         return self.ppdcache

Definition at line 158 of file monitor.py.

00158 
00159     def get_printers (self):
00160         return self.printers.copy ()

def monitor.Monitor.handle_dbus_signal (   self,
  args 
)

Definition at line 746 of file monitor.py.

00746 
00747     def handle_dbus_signal(self, *args):
00748         debugprint ("D-Bus signal from CUPS... calling update")
00749         self.update ()
00750         if not self.received_any_dbus_signals:
00751             self.received_any_dbus_signals = True
00752 
00753 gobject.type_register (Monitor)

Here is the call graph for this function:

Here is the caller graph for this function:

def monitor.Monitor.refresh (   self,
  which_jobs = None,
  refresh_all = True 
)

Definition at line 498 of file monitor.py.

00498 
00499     def refresh(self, which_jobs=None, refresh_all=True):
00500         debugprint ("refresh")
00501 
00502         self.emit ('refresh')
00503         if which_jobs != None:
00504             self.which_jobs = which_jobs
00505 
00506         user = cups.getUser ()
00507         try:
00508             cups.setUser (self.user)
00509             c = cups.Connection (host=self.host,
00510                                  port=self.port,
00511                                  encryption=self.encryption)
00512         except RuntimeError:
00513             self.emit ('cups-connection-error')
00514             cups.setUser (user)
00515             return
00516 
00517         if self.sub_id != -1:
00518             try:
00519                 c.cancelSubscription (self.sub_id)
00520             except cups.IPPError, (e, m):
00521                 self.emit ('cups-ipp-error', e, m)
00522 
00523             if self.update_timer:
00524                 gobject.source_remove (self.update_timer)
00525 
00526             debugprint ("Canceled subscription %d" % self.sub_id)
00527 
00528         try:
00529             del self.sub_seq
00530         except AttributeError:
00531             pass
00532 
00533         events = ["printer-added",
00534                   "printer-deleted",
00535                   "printer-state-changed"]
00536         if self.monitor_jobs:
00537             events.extend (["job-created",
00538                             "job-completed",
00539                             "job-stopped",
00540                             "job-state-changed",
00541                             "job-progress"])
00542 
00543         try:
00544             self.sub_id = c.createSubscription ("/", events=events)
00545             debugprint ("Created subscription %d, events=%s" % (self.sub_id,
00546                                                                 repr (events)))
00547         except cups.IPPError, (e, m):
00548             self.emit ('cups-ipp-error', e, m)
00549 
00550         cups.setUser (user)
00551 
00552         if self.sub_id != -1:
00553             self.update_timer = gobject.timeout_add_seconds (
00554                 MIN_REFRESH_INTERVAL,
00555                 self.get_notifications)
00556             debugprint ("Next notifications fetch in %ds" %
00557                         MIN_REFRESH_INTERVAL)
00558 
00559         if self.monitor_jobs:
00560             jobs = self.jobs.copy ()
00561             if self.which_jobs not in ['all', 'completed']:
00562                 # Filter out completed jobs.
00563                 filtered = {}
00564                 for jobid, job in jobs.iteritems ():
00565                     if job.get ('job-state',
00566                                 cups.IPP_JOB_CANCELED) < cups.IPP_JOB_CANCELED:
00567                         filtered[jobid] = job
00568                 jobs = filtered
00569 
00570             self.fetch_first_job_id = 1
00571             if self.fetch_jobs_timer:
00572                 gobject.source_remove (self.fetch_jobs_timer)
00573             self.fetch_jobs_timer = gobject.timeout_add (5, self.fetch_jobs,
00574                                                          refresh_all)
00575         else:
00576             jobs = {}
00577 
00578         try:
00579             r = collect_printer_state_reasons (c, self.ppdcache)
00580             self.printer_state_reasons = r
00581             dests = c.getPrinters ()
00582             self.printers = set(dests.keys ())
00583         except cups.IPPError, (e, m):
00584             self.emit ('cups-ipp-error', e, m)
00585             return
00586         except RuntimeError:
00587             self.emit ('cups-connection-error')
00588             return
00589 
00590         if self.specific_dests != None:
00591             for jobid in jobs.keys ():
00592                 uri = jobs[jobid].get('job-printer-uri', '/')
00593                 i = uri.rfind ('/')
00594                 printer = uri[i + 1:]
00595                 if printer not in self.specific_dests:
00596                     del jobs[jobid]
00597 
00598         self.set_process_pending (False)
00599         for printer in self.printers:
00600             self.emit ('printer-added', printer)
00601         for jobid, job in jobs.iteritems ():
00602             self.emit ('job-added', jobid, '', {}, job)
00603         self.update_jobs (jobs)
00604         self.jobs = jobs
00605         self.set_process_pending (True)
00606         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def monitor.Monitor.set_process_pending (   self,
  whether 
)

Definition at line 195 of file monitor.py.

00195 
00196     def set_process_pending (self, whether):
00197         self.process_pending_events = whether

def monitor.Monitor.sort_jobs_by_printer (   self,
  jobs = None 
)

Definition at line 712 of file monitor.py.

00712 
00713     def sort_jobs_by_printer (self, jobs=None):
00714         if jobs == None:
00715             jobs = self.jobs
00716 
00717         my_printers = set()
00718         printer_jobs = {}
00719         for job, data in jobs.iteritems ():
00720             state = data.get ('job-state', cups.IPP_JOB_CANCELED)
00721             if state >= cups.IPP_JOB_CANCELED:
00722                 continue
00723             uri = data.get ('job-printer-uri', '')
00724             i = uri.rfind ('/')
00725             if i == -1:
00726                 continue
00727             printer = uri[i + 1:]
00728             my_printers.add (printer)
00729             if not printer_jobs.has_key (printer):
00730                 printer_jobs[printer] = {}
00731             printer_jobs[printer][job] = data
00732 
00733         return (printer_jobs, my_printers)

Here is the caller graph for this function:

def monitor.Monitor.update (   self)

Definition at line 739 of file monitor.py.

00739 
00740     def update(self):
00741         if self.update_timer:
00742             gobject.source_remove (self.update_timer)
00743 
00744         self.update_timer = gobject.timeout_add (200, self.get_notifications)
00745         debugprint ("Next notifications fetch in 200ms (update called)")

Here is the call graph for this function:

Here is the caller graph for this function:

def monitor.Monitor.update_connecting_devices (   self,
  printer_jobs = {} 
)
Updates connecting_to_device dict and still_connecting set.

Definition at line 217 of file monitor.py.

00217 
00218     def update_connecting_devices(self, printer_jobs={}):
00219         """Updates connecting_to_device dict and still_connecting set."""
00220         time_now = time.time ()
00221         connecting_to_device = {}
00222         trouble = False
00223         for printer, reasons in self.printer_state_reasons.iteritems ():
00224             connected = True
00225             for reason in reasons:
00226                 if reason.get_reason () == "connecting-to-device":
00227                     have_processing_job = False
00228                     for job, data in \
00229                             printer_jobs.get (printer, {}).iteritems ():
00230                         state = data.get ('job-state',
00231                                           cups.IPP_JOB_CANCELED)
00232                         if state == cups.IPP_JOB_PROCESSING:
00233                             have_processing_job = True
00234                             break
00235 
00236                     if not have_processing_job:
00237                         debugprint ("Ignoring stale connecting-to-device x")
00238                         continue
00239 
00240                     # Build a new connecting_to_device dict.  If our existing
00241                     # dict already has an entry for this printer, use that.
00242                     printer = reason.get_printer ()
00243                     t = self.connecting_to_device.get (printer, time_now)
00244                     connecting_to_device[printer] = t
00245                     debugprint ("Connecting time: %d" % (time_now - t))
00246                     if time_now - t >= CONNECTING_TIMEOUT:
00247                         if have_processing_job:
00248                             if printer not in self.still_connecting:
00249                                 self.still_connecting.add (printer)
00250                                 self.emit ('still-connecting', reason)
00251                             if self.connecting_timers.has_key (printer):
00252                                 gobject.source_remove (self.connecting_timers
00253                                                        [printer])
00254                                 del self.connecting_timers[printer]
00255                                 debugprint ("Stopped connecting timer "
00256                                             "for `%s'" % printer)
00257 
00258                     connected = False
00259                     break
00260 
00261             if connected and self.connecting_timers.has_key (printer):
00262                 gobject.source_remove (self.connecting_timers[printer])
00263                 del self.connecting_timers[printer]
00264                 debugprint ("Stopped connecting timer for `%s'" % printer)
00265 
00266         # Clear any previously-notified errors that are now fine.
00267         remove = set()
00268         for printer in self.still_connecting:
00269             if not connecting_to_device.has_key (printer):
00270                 remove.add (printer)
00271                 self.emit ('now-connected', printer)
00272                 if self.connecting_timers.has_key (printer):
00273                     gobject.source_remove (self.connecting_timers[printer])
00274                     del self.connecting_timers[printer]
00275                     debugprint ("Stopped connecting timer for `%s'" % printer)
00276 
00277         self.still_connecting = self.still_connecting.difference (remove)
00278         self.connecting_to_device = connecting_to_device

Here is the caller graph for this function:

def monitor.Monitor.update_jobs (   self,
  jobs 
)

Definition at line 734 of file monitor.py.

00734 
00735     def update_jobs(self, jobs):
00736         debugprint ("update_jobs")
00737         (printer_jobs, my_printers) = self.sort_jobs_by_printer (jobs)
00738         self.check_state_reasons (my_printers, printer_jobs)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

dictionary monitor.Monitor.__gsignals__ [static, private]

Definition at line 65 of file monitor.py.

Definition at line 151 of file monitor.py.

Definition at line 138 of file monitor.py.

Definition at line 140 of file monitor.py.

Definition at line 120 of file monitor.py.

string monitor.Monitor.DBUS_IFACE = "com.redhat.PrinterSpooler" [static]

Definition at line 106 of file monitor.py.

string monitor.Monitor.DBUS_PATH = "/com/redhat/PrinterSpooler" [static]

Definition at line 105 of file monitor.py.

Definition at line 131 of file monitor.py.

Definition at line 569 of file monitor.py.

Definition at line 119 of file monitor.py.

Definition at line 129 of file monitor.py.

Definition at line 115 of file monitor.py.

Definition at line 114 of file monitor.py.

Definition at line 112 of file monitor.py.

Definition at line 130 of file monitor.py.

Definition at line 132 of file monitor.py.

Definition at line 116 of file monitor.py.

Definition at line 117 of file monitor.py.

Definition at line 118 of file monitor.py.

Definition at line 137 of file monitor.py.

Definition at line 141 of file monitor.py.

Definition at line 113 of file monitor.py.

Definition at line 139 of file monitor.py.

Definition at line 156 of file monitor.py.

Definition at line 385 of file monitor.py.

Definition at line 142 of file monitor.py.

Definition at line 128 of file monitor.py.

Definition at line 136 of file monitor.py.


The documentation for this class was generated from the following file: