1
by Ubuntu daily release
Import upstream version 1.4.1+14.10.20140430 |
1 |
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
|
2 |
#
|
|
3 |
# Autopilot Functional Test Tool
|
|
4 |
# Copyright (C) 2012-2013 Canonical
|
|
5 |
#
|
|
6 |
# This program is free software: you can redistribute it and/or modify
|
|
7 |
# it under the terms of the GNU General Public License as published by
|
|
8 |
# the Free Software Foundation, either version 3 of the License, or
|
|
9 |
# (at your option) any later version.
|
|
10 |
#
|
|
11 |
# This program is distributed in the hope that it will be useful,
|
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
# GNU General Public License for more details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License
|
|
17 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18 |
#
|
|
19 |
||
20 |
||
21 |
import dbus |
|
22 |
||
23 |
from PyQt4 import QtGui |
|
24 |
||
25 |
||
26 |
def get_qt_icon(): |
|
27 |
return QtGui.QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png") |
|
28 |
||
29 |
||
30 |
def dbus_string_rep(dbus_type): |
|
31 |
"""Get a string representation of various dbus types."""
|
|
32 |
if isinstance(dbus_type, dbus.Boolean): |
|
33 |
return repr(bool(dbus_type)) |
|
34 |
if isinstance(dbus_type, dbus.String): |
|
35 |
return dbus_type.encode('utf-8', errors='ignore').decode('utf-8') |
|
36 |
if (isinstance(dbus_type, dbus.Int16) or |
|
37 |
isinstance(dbus_type, dbus.UInt16) or |
|
38 |
isinstance(dbus_type, dbus.Int32) or |
|
39 |
isinstance(dbus_type, dbus.UInt32) or |
|
40 |
isinstance(dbus_type, dbus.Int64) or |
|
41 |
isinstance(dbus_type, dbus.UInt64)): |
|
42 |
return repr(int(dbus_type)) |
|
43 |
if isinstance(dbus_type, dbus.Double): |
|
44 |
return repr(float(dbus_type)) |
|
45 |
if (isinstance(dbus_type, dbus.Array) or |
|
46 |
isinstance(dbus_type, dbus.Struct)): |
|
47 |
return ', '.join([dbus_string_rep(i) for i in dbus_type]) |
|
48 |
else: |
|
49 |
return repr(dbus_type) |