~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to tests/autopilot/unity8/process_helpers.py

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
#
3
3
# Unity Autopilot Utilities
4
 
# Copyright (C) 2013 Canonical
 
4
# Copyright (C) 2013, 2014 Canonical
5
5
#
6
6
# This program is free software: you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
23
23
)
24
24
import logging
25
25
import subprocess
26
 
from unity8.shell.emulators import UnityEmulatorBase
27
 
from unity8.shell.emulators.main_window import MainWindow
 
26
from unity8.shell import emulators
 
27
from unity8.shell.emulators import main_window as main_window_emulator
28
28
 
29
29
logger = logging.getLogger(__name__)
30
30
 
54
54
        try:
55
55
            pid = _get_unity_pid()
56
56
            unity = _get_unity_proxy_object(pid)
57
 
            main_window = MainWindow(unity)
 
57
            main_window = unity.select_single(main_window_emulator.QQuickView)
58
58
        except ProcessSearchError as e:
59
59
            raise CannotAccessUnity(
60
60
                "Cannot introspect unity, make sure that it has been started "
64
64
                % str(e)
65
65
            )
66
66
    else:
67
 
        main_window = MainWindow(unity_proxy_obj)
 
67
        main_window = unity_proxy_obj.select_single(
 
68
            main_window_emulator.QQuickView)
68
69
 
69
70
    greeter = main_window.get_greeter()
70
71
    if greeter.created == False:
110
111
    status = _get_unity_status()
111
112
    if "start/" in status:
112
113
        try:
113
 
            output = subprocess.check_output(['/sbin/initctl', 'stop', 'unity8'])
 
114
            output = subprocess.check_output(
 
115
                ['/sbin/initctl', 'stop', 'unity8'])
114
116
            logger.info(output)
115
117
        except subprocess.CalledProcessError as e:
116
118
            e.args += (
140
142
            '/sbin/initctl',
141
143
            'status',
142
144
            'unity8'
143
 
        ])
 
145
        ], universal_newlines=True)
144
146
    except subprocess.CalledProcessError as e:
145
147
        raise CannotAccessUnity("Unable to get unity's status: %s" % str(e))
146
148
 
155
157
def _get_unity_proxy_object(pid):
156
158
    return get_proxy_object_for_existing_process(
157
159
        pid=pid,
158
 
        emulator_base=UnityEmulatorBase,
 
160
        emulator_base=emulators.UnityEmulatorBase,
159
161
    )