1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2012 Canonical
3
# Author: Thomi Richards
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
10
"""A collection of Unity-specific emulators."""
12
from time import sleep
14
from autopilot.introspection.dbus import DBusIntrospectionObject
17
class UnityIntrospectionObject(DBusIntrospectionObject):
19
DBUS_SERVICE = "com.canonical.Unity"
20
DBUS_OBJECT = "/com/canonical/Unity/Debug"
23
def ensure_unity_is_running(timeout=300):
24
"""Poll the unity debug interface, and return when it's ready for use.
26
The default timeout is 300 seconds (5 minutes) to account for the case where
27
Unity has crashed and is taking a while to get restarted (on a slow VM for
30
If, after the timeout period, unity is still not up, this function raises a
31
RuntimeError exception.
35
for i in range(0, timeout, sleep_period):
37
UnityIntrospectionObject.get_state_by_path("/")
41
raise RuntimeError("Unity debug interface is down after %d seconds of polling." % (timeout))