diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-08-12 13:08:10 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-08-12 13:08:10 (GMT) |
commit | 50c8d2b016477ba168fa3646639c3dfc0a1d8bc8 (patch) | |
tree | c6e34b0dfffc16bafe15f6b79dfc701aa9082a39 /scripts | |
parent | b189cd3bfde6a9c25d5f4d1586e98d82af90e059 (diff) |
Add a ui check
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/check.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/check.py b/scripts/check.py index 19224f1..4d0310b 100644 --- a/scripts/check.py +++ b/scripts/check.py @@ -6,6 +6,8 @@ import signal import subprocess import time +import gobject + from jhbuild.commands import Command, register_command scripts_dir = os.path.dirname(__file__) @@ -18,6 +20,48 @@ def check_display(display): stderr=open(os.devnull, "w")) return result == 0 +class UICheck(object): + def start(self): + self._mainloop = gobject.MainLoop() + self._exit_code = 0 + + self._start_shell() + + gobject.idle_add(self._start_ui_check_cb) + + self._mainloop.run() + + return self._exit_code + + def _start_shell(self): + print 'Launch the shell.' + + args = ['dbus-launch', '--exit-with-session', 'sugar-shell'] + shell_process = subprocess.Popen(args) + + def _ui_check_exit_cb(self, pid, condition): + self.exit_code = os.WEXITSTATUS(condition) + self._mainloop.quit() + + def _ui_check_read_cb(self, fd, condition): + f = os.fdopen(fd, 'r') + print f.read() + f.close() + + return True + + def _start_ui_check_cb(self): + print 'Launch UI check.' + + pid, stdin, stdout, stderr = gobject.spawn_async( + ['sugar-ui-check'], standard_output=True, standard_error=True, + flags=gobject.SPAWN_SEARCH_PATH | gobject.SPAWN_DO_NOT_REAP_CHILD) + + gobject.io_add_watch(stdout, gobject.IO_IN, self._ui_check_read_cb) + gobject.io_add_watch(stderr, gobject.IO_IN, self._ui_check_read_cb) + + gobject.child_watch_add(pid, self._ui_check_exit_cb) + class cmd_check(Command): name = 'check' @@ -72,6 +116,10 @@ class cmd_check(Command): os.chdir(cwd) + def check_ui(self, config): + ui_check = UICheck() + return ui_check.start() + def check_pylint(self, config): sugar_path = os.path.join(config.prefix, 'share', 'sugar') @@ -90,6 +138,8 @@ class cmd_check(Command): try: if options.type == 'pylint': self.check_pylint(config) + if options.type == 'ui': + self.check_ui(config) finally: if xvfb_pid: os.kill(xvfb_pid, signal.SIGTERM) |