~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to softwarecenter/backend/spawn_helper.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-12-06 17:30:50 UTC
  • Revision ID: package-import@ubuntu.com-20121206173050-n7mxi5fzlsvtdh9l
Tags: 5.5.2
* lp:~mvo/software-center/fix-pygobject-deprecation-warnings:
  - fix deprecation warninings with the latest python-gi
* lp:~mvo/software-center/minor-logging-fixes:
  - drop some LOG.info() messages to LOG.debug() to spam the user
    less
* lp:~mvo/software-center/trivial-close-ui-tweak:
  - hide the main window immediately when closing down
* lp:~mvo/software-center/5.4-fix-save-person-to-config:
  - This branch ensures that the "username" is saved everytime
    that the ubuntu sso whoami call is done
* lp:~mvo/software-center/use-dpkg-builddeps:
  - use dpkg-checkbuilddeps to find test-dependencies
* lp:~mvo/software-center/update-sc-cmdline-flexibility:
  - update-software-center-agent: 
    + add --target-db-path commandline
  - update-software-center: 
    + add --app-install-desktop-dir and --target-db-path commandline
* lp:~mvo/software-center/raring-pep8:
  - fixes for new pep8

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import softwarecenter.paths
34
34
from softwarecenter.paths import PistonHelpers
35
35
 
36
 
from gi.repository import GObject
 
36
from gi.repository import GObject, GLib
37
37
 
38
38
LOG = logging.getLogger(__name__)
39
39
 
52
52
        "error": (GObject.SIGNAL_RUN_LAST,
53
53
                  GObject.TYPE_NONE,
54
54
                  (str,),
55
 
                 ),
56
 
        }
 
55
                  ),
 
56
    }
57
57
 
58
58
    def __init__(self, format="pickle"):
59
59
        super(SpawnHelper, self).__init__()
93
93
        if "SOFTWARE_CENTER_DISABLE_SPAWN_HELPER" in os.environ:
94
94
            return
95
95
        self._cmd = cmd
96
 
        (pid, stdin, stdout, stderr) = GObject.spawn_async(
 
96
        (pid, stdin, stdout, stderr) = GLib.spawn_async(
97
97
            cmd, flags=GObject.SPAWN_DO_NOT_REAP_CHILD,
98
98
            standard_output=True, standard_error=True)
99
99
        LOG.debug("running: '%s' as pid: '%s'" % (cmd, pid))
100
 
        self._child_watch = GObject.child_watch_add(
101
 
            pid, self._helper_finished, data=(stdout, stderr))
102
 
        self._io_watch = GObject.io_add_watch(
103
 
            stdout, GObject.IO_IN, self._helper_io_ready, (stdout, ))
 
100
        self._child_watch = GLib.child_watch_add(
 
101
            GLib.PRIORITY_DEFAULT, pid, self._helper_finished,
 
102
            data=(stdout, stderr))
 
103
        channel = GLib.IOChannel.unix_new(stdout)
 
104
        self._io_watch = GLib.io_add_watch(
 
105
            channel, GLib.PRIORITY_DEFAULT, GObject.IO_IN,
 
106
            self._helper_io_ready, (stdout, ))
104
107
 
105
108
    def _helper_finished(self, pid, status, (stdout, stderr)):
106
109
        LOG.debug("helper_finished: '%s' '%s'" % (pid, status))
120
123
        if self._io_watch:
121
124
            # remove with a delay timeout delay to ensure that any
122
125
            # pending data is still flushed
123
 
            GObject.timeout_add(100, GObject.source_remove, self._io_watch)
 
126
            GLib.timeout_add(100, GLib.source_remove, self._io_watch)
124
127
        if self._child_watch:
125
 
            GObject.source_remove(self._child_watch)
 
128
            GLib.source_remove(self._child_watch)
126
129
 
127
130
    def _helper_io_ready(self, source, condition, (stdout,)):
128
131
        # read the raw data