Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes
timedops.TimedSubprocess Class Reference
Inheritance diagram for timedops.TimedSubprocess:
Inheritance graph
[legend]
Collaboration diagram for timedops.TimedSubprocess:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run
def do_timeout
def watcher
def show_wait_window
def wait_window_response
def cancel

Public Attributes

 subp
 output
 io_source
 watchers
 timeout
 parent
 show_dialog
 wait_window
 wait_source
 timeout_source

Detailed Description

Definition at line 46 of file timedops.py.


Constructor & Destructor Documentation

def timedops.TimedSubprocess.__init__ (   self,
  timeout = 60000,
  parent = None,
  show_dialog = True,
  args 
)

Definition at line 48 of file timedops.py.

00048 
00049                   **args):
00050         self.subp = subprocess.Popen (**args)
00051         self.output = dict()
00052         self.io_source = []
00053         self.watchers = 2
00054         self.timeout = timeout
00055         self.parent = parent
00056         self.show_dialog = show_dialog
00057         for f in [self.subp.stdout, self.subp.stderr]:
00058             if f != None:
00059                 source = gobject.io_add_watch (f,
00060                                                gobject.IO_IN |
00061                                                gobject.IO_HUP |
00062                                                gobject.IO_ERR,
00063                                                self.watcher)
00064                 self.io_source.append (source)
00065 
00066         self.wait_window = None


Member Function Documentation

Reimplemented from timedops.Timed.

Definition at line 128 of file timedops.py.

00128 
00129     def cancel (self):
00130         if self.watchers > 0:
00131             debugprint ("Command canceled")
00132             gtk.main_quit ()
00133             self.watchers = 0
00134 
00135         return False

Definition at line 87 of file timedops.py.

00087 
00088     def do_timeout (self):
00089         gtk.main_quit ()
00090         return False

Reimplemented from timedops.Timed.

Definition at line 67 of file timedops.py.

00067 
00068     def run (self):
00069         if self.show_dialog:
00070             self.wait_source = gobject.timeout_add_seconds (
00071                 1,
00072                 self.show_wait_window)
00073 
00074         self.timeout_source = gobject.timeout_add (self.timeout,
00075                                                    self.do_timeout)
00076         gtk.main ()
00077         gobject.source_remove (self.timeout_source)
00078         if self.show_dialog:
00079             gobject.source_remove (self.wait_source)
00080         for source in self.io_source:
00081             gobject.source_remove (source)
00082         if self.wait_window != None:
00083             self.wait_window.destroy ()
00084         return (self.output.get (self.subp.stdout, '').split ('\n'),
00085                 self.output.get (self.subp.stderr, '').split ('\n'),
00086                 self.subp.poll ())

Definition at line 105 of file timedops.py.

00105 
00106     def show_wait_window (self):
00107         gtk.gdk.threads_enter ()
00108         wait = gtk.MessageDialog (self.parent,
00109                                   gtk.DIALOG_MODAL |
00110                                   gtk.DIALOG_DESTROY_WITH_PARENT,
00111                                   gtk.MESSAGE_INFO,
00112                                   gtk.BUTTONS_CANCEL,
00113                                   _("Please wait"))
00114         wait.connect ("delete_event", lambda *args: False)
00115         wait.connect ("response", self.wait_window_response)
00116         if self.parent:
00117             wait.set_transient_for (self.parent)
00118         wait.set_position (gtk.WIN_POS_CENTER_ON_PARENT)
00119         wait.format_secondary_text (_("Gathering information"))
00120         wait.show_all ()
00121         self.wait_window = wait
00122         gtk.gdk.threads_leave ()
00123         return False

Here is the call graph for this function:

def timedops.TimedSubprocess.wait_window_response (   self,
  dialog,
  response 
)

Definition at line 124 of file timedops.py.

00124 
00125     def wait_window_response (self, dialog, response):
00126         if response == gtk.RESPONSE_CANCEL:
00127             self.cancel ()

Here is the call graph for this function:

Here is the caller graph for this function:

def timedops.TimedSubprocess.watcher (   self,
  source,
  condition 
)

Definition at line 91 of file timedops.py.

00091 
00092     def watcher (self, source, condition):
00093         if condition & gobject.IO_IN:
00094             buffer = self.output.get (source, '')
00095             buffer += source.read ()
00096             self.output[source] = buffer
00097 
00098         if condition & gobject.IO_HUP:
00099             self.watchers -= 1
00100             if self.watchers == 0:
00101                 gtk.main_quit ()
00102                 return False
00103 
00104         return True


Member Data Documentation

Definition at line 51 of file timedops.py.

Definition at line 50 of file timedops.py.

Definition at line 54 of file timedops.py.

Definition at line 55 of file timedops.py.

Definition at line 49 of file timedops.py.

Definition at line 53 of file timedops.py.

Definition at line 73 of file timedops.py.

Definition at line 69 of file timedops.py.

Definition at line 65 of file timedops.py.

Definition at line 52 of file timedops.py.


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