Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Fix imports & use typing in domain.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkin committed Jun 16, 2017
1 parent 145d5dd commit bed0445
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions qubesdbus/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,33 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' D-Bus Domain object '''

from typing import Dict, Union

import dbus
import dbus.service
import qubesadmin
from dbus._dbus import SessionBus
from dbus.service import BusName

import qubesadmin
import qubesdbus.service

try:
# Check mypy types. pylint: disable=ungrouped-imports, unused-import
from typing import Any, Union
import dbus
from dbus._dbus import SessionBus
from dbus.service import BusName
except ImportError:
pass
DBusString = Union[str, dbus.String]

INTERFACE = 'org.qubes.Domain'


class Domain(qubesdbus.service.PropertiesObject):
''' `Domain` is managed by `DomainManager1` and represents a domain. Its D-Bus
object path is `/org/qubes/DomainManager1/domains/QID`
'''

def __init__(self, bus, bus_name, bus_path, data):
# type: (SessionBus, BusName , str, Dict[Union[str,dbus.String], Any]) -> None
def __init__(self, bus: SessionBus, bus_name: BusName, bus_path: str,
data: Dict[Union[str, dbus.String]]) -> None:
self.properties = data
bus_path = '/'.join([bus_path, 'domains', str(data['qid'])])
self.name = data['name']
super(Domain, self).__init__(self.name, 'org.qubes.Domain1', data,
bus=bus, bus_name=bus_name,
bus_path=bus_path)
super(Domain, self).__init__(self.name, INTERFACE, data, bus=bus,
bus_name=bus_name, bus_path=bus_path)

@dbus.service.method("org.qubes.Domain", out_signature="b")
def Shutdown(self):
Expand Down

0 comments on commit bed0445

Please sign in to comment.