~aptdaemon-developers/aptdaemon/add-license-key-call

« back to all changes in this revision

Viewing changes to aptdaemon/debconf.py

  • Committer: Martin Pitt
  • Date: 2011-08-17 05:58:09 UTC
  • Revision ID: martin.pitt@ubuntu.com-20110817055809-g42ql4v2uekt1fs0
convert aptdaemon/client.py and aptdaemon/debconf.py from gobject to GObject as well; works with earlier pygobject versions and gtkclient.py, and makes this work with pygobject 2.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import subprocess
37
37
import tempfile
38
38
 
39
 
import gobject
 
39
from gi.repository import GObject
40
40
 
41
41
log = logging.getLogger("AptClient.DebconfProxy")
42
42
 
84
84
        """Start listening on the socket."""
85
85
        logging.debug("debconf.start()")
86
86
        self.socket.listen(1)
87
 
        self._listener_id = gobject.io_add_watch(self.socket,
88
 
                                         gobject.IO_IN,
 
87
        self._listener_id = GObject.io_add_watch(self.socket,
 
88
                                         GObject.IO_IN,
89
89
                                         self._accept_connection,
90
 
                                         priority=gobject.PRIORITY_DEFAULT_IDLE)
 
90
                                         priority=GObject.PRIORITY_DEFAULT_IDLE)
91
91
 
92
92
    def stop(self):
93
93
        """Stop listening on the socket."""
94
94
        logging.debug("debconf.stop()")
95
95
        self.socket.close()
96
96
        if self._listener_id is not None:
97
 
            gobject.source_remove(self._listener_id)
 
97
            GObject.source_remove(self._listener_id)
98
98
            self._listener_id = None
99
99
        if self.temp_dir:
100
100
            try:
109
109
            return True
110
110
        conn, addr = socket.accept()
111
111
        self._active_conn = conn
112
 
        mask = gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP | gobject.IO_NVAL
 
112
        mask = GObject.IO_IN | GObject.IO_ERR | GObject.IO_HUP | GObject.IO_NVAL
113
113
        self.helper = subprocess.Popen(["debconf-communicate"],
114
114
                                       stdin=subprocess.PIPE,
115
115
                                       stdout=subprocess.PIPE,
116
116
                                       env=self._get_debconf_env())
117
 
        gobject.io_add_watch(conn, mask,
 
117
        GObject.io_add_watch(conn, mask,
118
118
                             self._copy_conn, self.helper.stdin,
119
 
                             priority=gobject.PRIORITY_HIGH_IDLE)
120
 
        gobject.io_add_watch(self.helper.stdout, mask,
 
119
                             priority=GObject.PRIORITY_HIGH_IDLE)
 
120
        GObject.io_add_watch(self.helper.stdout, mask,
121
121
                             self._copy_stdout, conn,
122
 
                             priority=gobject.PRIORITY_HIGH_IDLE)
 
122
                             priority=GObject.PRIORITY_HIGH_IDLE)
123
123
        return True
124
124
 
125
125
    def _copy_stdout(self, source, condition, conn):
172
172
        os.remove(socket_path)
173
173
    proxy = DebconfProxy("gnome", socket_path)
174
174
    proxy.start()
175
 
    loop = gobject.MainLoop()
 
175
    loop = GObject.MainLoop()
176
176
    loop.run()
177
177
 
178
178
if __name__ == "__main__":