manager/qubesmanager/common_threads.py

55 lines
1.7 KiB
Python
Raw Normal View History

#!/usr/bin/python2
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2011 Marek Marczykowski <marmarek@mimuw.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
from PyQt4 import QtCore # pylint: disable=import-error
from qubesadmin import exc
# pylint: disable=too-few-public-methods
class RemoveVMThread(QtCore.QThread):
def __init__(self, vm):
QtCore.QThread.__init__(self)
self.vm = vm
self.msg = None
def run(self):
try:
del self.vm.app.domains[self.vm.name]
except exc.QubesException as ex:
self.msg = ("Error removing Qube!", str(ex))
# pylint: disable=too-few-public-methods
class CloneVMThread(QtCore.QThread):
def __init__(self, src_vm, dst_name):
QtCore.QThread.__init__(self)
self.src_vm = src_vm
self.dst_name = dst_name
self.msg = None
def run(self):
try:
2018-10-20 23:01:35 +02:00
self.src_vm.app.clone_vm(self.src_vm, self.dst_name)
self.msg = ("Sucess", "The qube was cloned sucessfully.")
except exc.QubesException as ex:
self.msg = ("Error while cloning Qube!", str(ex))