From 570cbe5225580c1004deff6b19c49bb7457489e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 21 Feb 2017 00:46:58 +0100 Subject: [PATCH] qubes: py3k related fixes --- qubes/ext/gui.py | 10 +++++----- qubes/storage/__init__.py | 2 +- qubes/vm/qubesvm.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qubes/ext/gui.py b/qubes/ext/gui.py index 9d46d1cc..c68b7402 100644 --- a/qubes/ext/gui.py +++ b/qubes/ext/gui.py @@ -30,7 +30,7 @@ import qubes.ext # "LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm" -REGEX_OUTPUT = re.compile(r''' +REGEX_OUTPUT = re.compile(rb''' (?x) # ignore whitespace ^ # start of string (?P[A-Za-z0-9\-]*)[ ] # LVDS VGA etc @@ -58,7 +58,7 @@ def get_monitor_layout(): for line in subprocess.Popen( ['xrandr', '-q'], stdout=subprocess.PIPE).stdout: - if not line.startswith("Screen") and not line.startswith(" "): + if not line.startswith(b"Screen") and not line.startswith(b" "): output_params = REGEX_OUTPUT.match(line).groupdict() if output_params['width']: phys_size = "" @@ -109,9 +109,9 @@ class GUI(qubes.ext.Extension): # get owner of X11 session session_owner = None for line in subprocess.check_output(['xhost']).splitlines(): - if line == 'SI:localuser:root': + if line == b'SI:localuser:root': pass - elif line.startswith('SI:localuser:'): + elif line.startswith(b'SI:localuser:'): session_owner = line.split(":")[2] if session_owner is not None: data_dir = os.path.expanduser( @@ -277,7 +277,7 @@ class GUI(qubes.ext.Extension): pipe = vm.run('QUBESRPC qubes.SetMonitorLayout dom0', passio_popen=True, wait=True) - pipe.stdin.write(''.join(layout)) + pipe.stdin.write(''.join(layout).encode()) pipe.stdin.close() pipe.wait() diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 0bbb52a3..da57401b 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -327,7 +327,7 @@ class Storage(object): volume = self.vm.volumes[volume] self.get_pool(volume).resize(volume, size) if self.vm.is_running(): - self.vm.run_service('qubes.ResizeDisk', input=volume.name, + self.vm.run_service('qubes.ResizeDisk', input=volume.name.encode(), user='root', wait=True) def create(self): diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 7acb65b8..abf16597 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -1203,7 +1203,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): # Note : User root is redefined to SYSTEM in the Windows agent code p = self.run('QUBESRPC qubes.WaitForSession none', user="root", passio_popen=True, gui=False, wait=True) - p.communicate(input=self.default_user) + p.communicate(input=self.default_user.encode()) def create_on_disk(self, pool=None, pools=None): '''Create files needed for VM.