예제 #1
0
def _run_qrexec_repo(service, arg=''):
    # Set default locale to C in order to prevent error msg
    # in subprocess call related to falling back to C locale
    env = os.environ.copy()
    env['LC_ALL'] = 'C'
    # Fake up a "qrexec call" to dom0 because dom0 can't qrexec to itself yet
    cmd = '/etc/qubes-rpc/' + service
    p = subprocess.run(
        ['sudo', cmd, arg],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=False,
        env=env
    )
    if p.stderr:
        raise exc.QubesException(
            QtCore.QCoreApplication.translate(
                "GlobalSettings", 'qrexec call stderr was not empty'),
            {'stderr': p.stderr.decode('utf-8')})
    if p.returncode != 0:
        raise exc.QubesException(
            QtCore.QCoreApplication.translate(
                "GlobalSettings",
                'qrexec call exited with non-zero return code'),
            {'returncode': p.returncode})
    return p.stdout.decode('utf-8')
예제 #2
0
    def test_03_backup_thread_error(self):
        vm = unittest.mock.Mock(spec=['is_running', 'app'],
                                **{'is_running.return_value': True})

        vm.app = unittest.mock.Mock()
        vm.app.qubesd_call.side_effect = exc.QubesException('Error')

        thread = backup.BackupThread(vm)
        thread.run()

        self.assertIsNotNone(thread.msg)
예제 #3
0
    def test_22_loading_settings_exc(self, mock_info, mock_load):

        mock_load.side_effect = exc.QubesException('Error')

        self.dialog.hide()
        self.dialog.deleteLater()
        self.qtapp.processEvents()

        self.dialog = backup.BackupVMsWindow(
            self.qtapp, self.qapp, self.dispatcher)
        self.dialog.show()

        # check error was reported
        self.assertEqual(mock_info.call_count, 1, "Warning not shown")
 async def perform_restart(self):
     try:
         self.vm.shutdown()
         while self.vm.is_running():
             await asyncio.sleep(1)
         proc = await asyncio.create_subprocess_exec('qvm-start',
                                                     self.vm.name,
                                                     stderr=subprocess.PIPE)
         _stdout, stderr = await proc.communicate()
         if proc.returncode != 0:
             raise exc.QubesException(stderr)
     except exc.QubesException as ex:
         show_error(
             _("Error restarting qube"),
             _("The following error occurred while attempting to "
               "restart qube {0}:\n{1}").format(self.vm.name, str(ex)))