diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 18f7cdd0..df9033bf 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -332,6 +332,13 @@ class QubesVm(object): for hook in self.hooks_init: hook(self) + def __repr__(self): + return '<{} at {:#0x} qid={!r} name={!r}>'.format( + self.__class__.__name__, + id(self), + self.qid, + self.name) + def absolute_path(self, arg, default): if arg is not None and os.path.isabs(arg): return arg diff --git a/core/qubes.py b/core/qubes.py index 37adc7e2..ea630d1e 100755 --- a/core/qubes.py +++ b/core/qubes.py @@ -170,9 +170,11 @@ class QubesHost(object): class QubesVmLabel(object): def __init__(self, index, color, name, dispvm=False): - self.name = name self.index = index self.color = color + self.name = name + self.dispvm = dispvm + self.icon = '{}-{}'.format(('dispvm' if dispvm else 'appvm'), name) # self.icon_path is obsolete @@ -180,6 +182,14 @@ class QubesVmLabel(object): self.icon_path = os.path.join( system_path['qubes_icon_dir'], self.icon) + ".png" + def __repr__(self): + return '{}({!r}, {!r}, {!r}, dispvm={!r})'.format( + self.__class__.__name__, + self.index, + self.color, + self.name, + self.dispvm) + # Globally defined lables QubesVmLabels = { "red": QubesVmLabel(1, "0xcc0000", "red" ), @@ -230,6 +240,9 @@ class QubesVmCollection(dict): self.clockvm_qid = None self.qubes_store_file = None + def __repr__(self): + return '<{} {!r}>'.format(self.__class__.__name__, list(sorted(self.keys()))) + def values(self): for qid in self.keys(): yield self[qid]