Initial setup
Initialize .pylintrc, put ignore in used files' headers.
This commit is contained in:
parent
2f3d60b27a
commit
41b602ec48
196
.pylintrc
Normal file
196
.pylintrc
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
[MASTER]
|
||||||
|
persistent=no
|
||||||
|
ignore=tests
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
# abstract-class-little-used: see http://www.logilab.org/ticket/111138
|
||||||
|
# deprecated-method:
|
||||||
|
# enable again after disabling py-3.4.3 asyncio.ensure_future compat hack
|
||||||
|
disable=
|
||||||
|
abstract-class-little-used,
|
||||||
|
bad-continuation,
|
||||||
|
cyclic-import,
|
||||||
|
deprecated-method,
|
||||||
|
duplicate-code,
|
||||||
|
file-ignored,
|
||||||
|
fixme,
|
||||||
|
locally-disabled,
|
||||||
|
locally-enabled,
|
||||||
|
logging-format-interpolation,
|
||||||
|
missing-docstring,
|
||||||
|
star-args,
|
||||||
|
wrong-import-order
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
|
||||||
|
# Set the output format. Available formats are text, parseable, colorized, msvs
|
||||||
|
# (visual studio) and html
|
||||||
|
output-format=colorized
|
||||||
|
|
||||||
|
#files-output=no
|
||||||
|
reports=yes
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
#ignored-classes=
|
||||||
|
|
||||||
|
ignore-mixin-members=yes
|
||||||
|
generated-members=
|
||||||
|
iter_entry_points,
|
||||||
|
Element,ElementTree,QName,SubElement,fromstring,parse,tostring,
|
||||||
|
|
||||||
|
[BASIC]
|
||||||
|
|
||||||
|
# List of builtins function names that should not be used, separated by a comma
|
||||||
|
bad-functions=
|
||||||
|
|
||||||
|
# Regular expression which should only match correct module names
|
||||||
|
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct module level names
|
||||||
|
const-rgx=(([A-Za-z_][A-Za-z0-9_]*)|(__.*__))$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct class names
|
||||||
|
class-rgx=([A-Z_][a-zA-Z0-9]+|TC_\d\d_[a-zA-Z0-9_]+)$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct function names
|
||||||
|
function-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct method names
|
||||||
|
method-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct instance attribute names
|
||||||
|
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct argument names
|
||||||
|
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct variable names
|
||||||
|
variable-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||||
|
|
||||||
|
# Regular expression which should only match correct list comprehension /
|
||||||
|
# generator expression variable names
|
||||||
|
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
|
||||||
|
|
||||||
|
# Good variable names which should always be accepted, separated by a comma
|
||||||
|
good-names=e,i,j,k,m,p,v,ex,Run,_,log,vm
|
||||||
|
|
||||||
|
# Bad variable names which should always be refused, separated by a comma
|
||||||
|
bad-names=foo,bar,baz,toto,tutu,tata
|
||||||
|
|
||||||
|
# Regular expression which should only match functions or classes name which do
|
||||||
|
# not require a docstring
|
||||||
|
no-docstring-rgx=__.*__
|
||||||
|
|
||||||
|
|
||||||
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
|
notes=FIXME,FIX,XXX,TODO
|
||||||
|
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
|
||||||
|
# Maximum number of characters on a single line.
|
||||||
|
max-line-length=80
|
||||||
|
|
||||||
|
# Maximum number of lines in a module
|
||||||
|
max-module-lines=3000
|
||||||
|
|
||||||
|
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||||
|
# tab).
|
||||||
|
indent-string=' '
|
||||||
|
|
||||||
|
|
||||||
|
[VARIABLES]
|
||||||
|
|
||||||
|
# Tells whether we should check for unused import in __init__ files.
|
||||||
|
init-import=no
|
||||||
|
|
||||||
|
# A regular expression matching the beginning of the name of dummy variables
|
||||||
|
# (i.e. not used).
|
||||||
|
dummy-variables-rgx=_|dummy
|
||||||
|
|
||||||
|
|
||||||
|
[SIMILARITIES]
|
||||||
|
|
||||||
|
# Minimum lines number of a similarity.
|
||||||
|
min-similarity-lines=4
|
||||||
|
|
||||||
|
# Ignore comments when computing similarities.
|
||||||
|
ignore-comments=yes
|
||||||
|
|
||||||
|
# Ignore docstrings when computing similarities.
|
||||||
|
ignore-docstrings=yes
|
||||||
|
|
||||||
|
|
||||||
|
[CLASSES]
|
||||||
|
|
||||||
|
# List of method names used to declare (i.e. assign) instance attributes.
|
||||||
|
defining-attr-methods=__init__,__new__,setUp
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a class method.
|
||||||
|
valid-classmethod-first-arg=cls
|
||||||
|
|
||||||
|
|
||||||
|
[IMPORTS]
|
||||||
|
|
||||||
|
# Deprecated modules which should not be used, separated by a comma
|
||||||
|
deprecated-modules=regsub,TERMIOS,Bastion,rexec
|
||||||
|
|
||||||
|
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||||
|
# given file (report RP0402 must not be disabled)
|
||||||
|
import-graph=
|
||||||
|
|
||||||
|
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
ext-import-graph=
|
||||||
|
|
||||||
|
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
int-import-graph=
|
||||||
|
|
||||||
|
|
||||||
|
[DESIGN]
|
||||||
|
|
||||||
|
# Maximum number of arguments for function / method
|
||||||
|
max-args=35
|
||||||
|
|
||||||
|
# Argument names that match this expression will be ignored. Default to name
|
||||||
|
# with leading underscore
|
||||||
|
ignored-argument-names=_.*
|
||||||
|
|
||||||
|
# Maximum number of locals for function / method body
|
||||||
|
# Let's have max-args + 5
|
||||||
|
max-locals=40
|
||||||
|
|
||||||
|
# Maximum number of return / yield for function / method body
|
||||||
|
max-returns=6
|
||||||
|
|
||||||
|
# Maximum number of branch for function / method body
|
||||||
|
# 4x the default value
|
||||||
|
max-branches=48
|
||||||
|
|
||||||
|
# Maximum number of statements in function / method body
|
||||||
|
# Double default
|
||||||
|
max-statements=100
|
||||||
|
|
||||||
|
# Maximum number of parents for a class (see R0901).
|
||||||
|
max-parents=7
|
||||||
|
|
||||||
|
# Maximum number of attributes for a class (see R0902).
|
||||||
|
max-attributes=15
|
||||||
|
|
||||||
|
# Minimum number of public methods for a class (see R0903).
|
||||||
|
min-public-methods=2
|
||||||
|
|
||||||
|
# Maximum number of public methods for a class (see R0904).
|
||||||
|
max-public-methods=100
|
||||||
|
|
||||||
|
|
||||||
|
[EXCEPTIONS]
|
||||||
|
|
||||||
|
# Exceptions that will emit a warning when being caught. Defaults to
|
||||||
|
# "Exception"
|
||||||
|
overgeneral-exceptions=Exception,EnvironmentError
|
||||||
|
|
||||||
|
# vim: ft=conf
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# -*- coding: utf8 -*-
|
# -*- coding: utf8 -*-
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
@ -43,12 +43,12 @@ from . import thread_monitor
|
|||||||
|
|
||||||
from .appmenu_select import AppmenuSelectManager
|
from .appmenu_select import AppmenuSelectManager
|
||||||
from .backup_utils import get_path_for_vm
|
from .backup_utils import get_path_for_vm
|
||||||
from .firewall import *
|
from . import firewall
|
||||||
|
|
||||||
from .ui_settingsdlg import *
|
from . import ui_settingsdlg
|
||||||
from .bootfromdevice import main as bootfromdevice
|
from .bootfromdevice import main as bootfromdevice
|
||||||
|
|
||||||
class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, firewall.QDialog):
|
||||||
tabs_indices = collections.OrderedDict((
|
tabs_indices = collections.OrderedDict((
|
||||||
('basic', 0),
|
('basic', 0),
|
||||||
('advanced', 1),
|
('advanced', 1),
|
||||||
@ -75,8 +75,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
assert (idx in range(self.tabWidget.count()))
|
assert (idx in range(self.tabWidget.count()))
|
||||||
self.tabWidget.setCurrentIndex(idx)
|
self.tabWidget.setCurrentIndex(idx)
|
||||||
|
|
||||||
self.connect(self.buttonBox, SIGNAL("accepted()"), self.save_and_apply)
|
self.connect(self.buttonBox, firewall.SIGNAL("accepted()"), self.save_and_apply)
|
||||||
self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
|
self.connect(self.buttonBox, firewall.SIGNAL("rejected()"), self.reject)
|
||||||
|
|
||||||
self.tabWidget.currentChanged.connect(self.current_tab_changed)
|
self.tabWidget.currentChanged.connect(self.current_tab_changed)
|
||||||
|
|
||||||
@ -92,18 +92,18 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
###### advanced tab
|
###### advanced tab
|
||||||
self.__init_advanced_tab__()
|
self.__init_advanced_tab__()
|
||||||
self.include_in_balancing.stateChanged.connect(self.include_in_balancing_state_changed)
|
self.include_in_balancing.stateChanged.connect(self.include_in_balancing_state_changed)
|
||||||
self.connect(self.init_mem, SIGNAL("editingFinished()"), self.check_mem_changes)
|
self.connect(self.init_mem, firewall.SIGNAL("editingFinished()"), self.check_mem_changes)
|
||||||
self.connect(self.max_mem_size, SIGNAL("editingFinished()"), self.check_mem_changes)
|
self.connect(self.max_mem_size, firewall.SIGNAL("editingFinished()"), self.check_mem_changes)
|
||||||
self.bootFromDeviceButton.clicked.connect(self.boot_from_cdrom_button_pressed)
|
self.bootFromDeviceButton.clicked.connect(self.boot_from_cdrom_button_pressed)
|
||||||
|
|
||||||
###### firewall tab
|
###### firewall tab
|
||||||
if self.tabWidget.isTabEnabled(self.tabs_indices['firewall']):
|
if self.tabWidget.isTabEnabled(self.tabs_indices['firewall']):
|
||||||
model = QubesFirewallRulesModel()
|
model = firewall.QubesFirewallRulesModel()
|
||||||
try:
|
try:
|
||||||
model.set_vm(vm)
|
model.set_vm(vm)
|
||||||
self.set_fw_model(model)
|
self.set_fw_model(model)
|
||||||
self.firewallModifiedOutsidelabel.setVisible(False)
|
self.firewallModifiedOutsidelabel.setVisible(False)
|
||||||
except FirewallModifiedOutsideError as ex:
|
except firewall.FirewallModifiedOutsideError as ex:
|
||||||
self.disable_all_fw_conf()
|
self.disable_all_fw_conf()
|
||||||
|
|
||||||
self.newRuleButton.clicked.connect(self.new_rule_button_pressed)
|
self.newRuleButton.clicked.connect(self.new_rule_button_pressed)
|
||||||
@ -114,7 +114,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
####### devices tab
|
####### devices tab
|
||||||
self.__init_devices_tab__()
|
self.__init_devices_tab__()
|
||||||
self.connect(self.dev_list, SIGNAL("selected_changed()"), self.devices_selection_changed)
|
self.connect(self.dev_list, firewall.SIGNAL("selected_changed()"), self.devices_selection_changed)
|
||||||
|
|
||||||
####### services tab
|
####### services tab
|
||||||
self.__init_services_tab__()
|
self.__init_services_tab__()
|
||||||
@ -141,7 +141,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
progress = QProgressDialog(
|
progress = firewall.QProgressDialog(
|
||||||
self.tr("Applying settings to <b>{0}</b>...").format(self.vm.name), "", 0, 0)
|
self.tr("Applying settings to <b>{0}</b>...").format(self.vm.name), "", 0, 0)
|
||||||
progress.setCancelButton(None)
|
progress.setCancelButton(None)
|
||||||
progress.setModal(True)
|
progress.setModal(True)
|
||||||
@ -154,7 +154,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
progress.hide()
|
progress.hide()
|
||||||
|
|
||||||
if not t_monitor.success:
|
if not t_monitor.success:
|
||||||
QMessageBox.warning(None,
|
firewall.QMessageBox.warning(None,
|
||||||
self.tr("Error while changing settings for {0}!").format(self.vm.name),
|
self.tr("Error while changing settings for {0}!").format(self.vm.name),
|
||||||
self.tr("ERROR: {0}").format(t_monitor.error_msg))
|
self.tr("ERROR: {0}").format(t_monitor.error_msg))
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
netvm = self.vm.netvm
|
netvm = self.vm.netvm
|
||||||
if netvm is not None and \
|
if netvm is not None and \
|
||||||
not netvm.features.check_with_template('qubes-firewall', False):
|
not netvm.features.check_with_template('qubes-firewall', False):
|
||||||
QMessageBox.warning(None,
|
firewall.QMessageBox.warning(None,
|
||||||
self.tr("VM configuration problem!"),
|
self.tr("VM configuration problem!"),
|
||||||
self.tr("The '{vm}' AppVM is network connected to "
|
self.tr("The '{vm}' AppVM is network connected to "
|
||||||
"'{netvm}', which does not support firewall!<br/>"
|
"'{netvm}', which does not support firewall!<br/>"
|
||||||
@ -236,7 +236,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def __init_basic_tab__(self):
|
def __init_basic_tab__(self):
|
||||||
self.vmname.setText(self.vm.name)
|
self.vmname.setText(self.vm.name)
|
||||||
self.vmname.setValidator(QRegExpValidator(QRegExp("[a-zA-Z0-9-]*", Qt.CaseInsensitive), None))
|
self.vmname.setValidator(firewall.QRegExpValidator(firewall.QRegExp("[a-zA-Z0-9-]*", firewall.Qt.CaseInsensitive), None))
|
||||||
self.vmname.setEnabled(False)
|
self.vmname.setEnabled(False)
|
||||||
self.rename_vm_button.setEnabled(not self.vm.is_running())
|
self.rename_vm_button.setEnabled(not self.vm.is_running())
|
||||||
self.delete_vm_button.setEnabled(not self.vm.is_running())
|
self.delete_vm_button.setEnabled(not self.vm.is_running())
|
||||||
@ -394,14 +394,14 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def check_mem_changes(self):
|
def check_mem_changes(self):
|
||||||
if self.max_mem_size.value() < self.init_mem.value():
|
if self.max_mem_size.value() < self.init_mem.value():
|
||||||
QMessageBox.warning(None,
|
firewall.QMessageBox.warning(None,
|
||||||
self.tr("Warning!"),
|
self.tr("Warning!"),
|
||||||
self.tr("Max memory can not be less than initial memory.<br>"
|
self.tr("Max memory can not be less than initial memory.<br>"
|
||||||
"Setting max memory to equal initial memory."))
|
"Setting max memory to equal initial memory."))
|
||||||
self.max_mem_size.setValue(self.init_mem.value())
|
self.max_mem_size.setValue(self.init_mem.value())
|
||||||
# Linux specific limit: init memory must not be below max_mem_size/10.79 in order to allow scaling up to max_mem_size (or else "add_memory() failed: -17" problem)
|
# Linux specific limit: init memory must not be below max_mem_size/10.79 in order to allow scaling up to max_mem_size (or else "add_memory() failed: -17" problem)
|
||||||
if self.init_mem.value() * 10 < self.max_mem_size.value():
|
if self.init_mem.value() * 10 < self.max_mem_size.value():
|
||||||
QMessageBox.warning(None,
|
firewall.QMessageBox.warning(None,
|
||||||
self.tr("Warning!"),
|
self.tr("Warning!"),
|
||||||
self.tr("Initial memory can not be less than one tenth "
|
self.tr("Initial memory can not be less than one tenth "
|
||||||
"Max memory.<br>Setting initial memory to the minimum "
|
"Max memory.<br>Setting initial memory to the minimum "
|
||||||
@ -419,7 +419,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
if not t_monitor.success:
|
if not t_monitor.success:
|
||||||
QMessageBox.warning(None,
|
firewall.QMessageBox.warning(None,
|
||||||
self.tr("Error!"),
|
self.tr("Error!"),
|
||||||
self.tr("ERROR: {}").format(
|
self.tr("ERROR: {}").format(
|
||||||
t_monitor.error_msg))
|
t_monitor.error_msg))
|
||||||
@ -438,7 +438,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def rename_vm(self):
|
def rename_vm(self):
|
||||||
|
|
||||||
new_vm_name, ok = QInputDialog.getText(self,
|
new_vm_name, ok = firewall.QInputDialog.getText(self,
|
||||||
self.tr('Rename VM'),
|
self.tr('Rename VM'),
|
||||||
self.tr('New name: (WARNING: '
|
self.tr('New name: (WARNING: '
|
||||||
'all other changes will be discarded)'))
|
'all other changes will be discarded)'))
|
||||||
@ -458,7 +458,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def remove_vm(self):
|
def remove_vm(self):
|
||||||
|
|
||||||
answer, ok = QInputDialog.getText(
|
answer, ok = firewall.QInputDialog.getText(
|
||||||
self,
|
self,
|
||||||
self.tr('Delete VM'),
|
self.tr('Delete VM'),
|
||||||
self.tr('Are you absolutely sure you want to delete this VM? '
|
self.tr('Are you absolutely sure you want to delete this VM? '
|
||||||
@ -472,7 +472,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
self.done(0)
|
self.done(0)
|
||||||
|
|
||||||
elif ok:
|
elif ok:
|
||||||
QMessageBox.warning(
|
firewall.QMessageBox.warning(
|
||||||
None,
|
None,
|
||||||
self.tr("Removal cancelled"),
|
self.tr("Removal cancelled"),
|
||||||
self.tr("The VM will not be removed."))
|
self.tr("The VM will not be removed."))
|
||||||
@ -488,14 +488,14 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def clone_vm(self):
|
def clone_vm(self):
|
||||||
|
|
||||||
cloned_vm_name, ok = QInputDialog.getText(
|
cloned_vm_name, ok = firewall.QInputDialog.getText(
|
||||||
self,
|
self,
|
||||||
self.tr('Clone VM'),
|
self.tr('Clone VM'),
|
||||||
self.tr('Name for the cloned VM:'))
|
self.tr('Name for the cloned VM:'))
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
self._run_in_thread(self._clone_vm, cloned_vm_name)
|
self._run_in_thread(self._clone_vm, cloned_vm_name)
|
||||||
QMessageBox.warning(
|
firewall.QMessageBox.warning(
|
||||||
None,
|
None,
|
||||||
self.tr("Success"),
|
self.tr("Success"),
|
||||||
self.tr("The VM was cloned successfully."))
|
self.tr("The VM was cloned successfully."))
|
||||||
@ -602,7 +602,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
for dev in lspci.splitlines():
|
for dev in lspci.splitlines():
|
||||||
devs.append((dev.rstrip(), dev.split(' ')[0]))
|
devs.append((dev.rstrip(), dev.split(' ')[0]))
|
||||||
|
|
||||||
class DevListWidgetItem(QListWidgetItem):
|
class DevListWidgetItem(firewall.QListWidgetItem):
|
||||||
def __init__(self, name, ident, parent = None):
|
def __init__(self, name, ident, parent = None):
|
||||||
super(DevListWidgetItem, self).__init__(name, parent)
|
super(DevListWidgetItem, self).__init__(name, parent)
|
||||||
self.ident = ident
|
self.ident = ident
|
||||||
@ -645,7 +645,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
for i in range(self.dev_list.selected_list.count())]
|
for i in range(self.dev_list.selected_list.count())]
|
||||||
for ident in new:
|
for ident in new:
|
||||||
if ident not in old:
|
if ident not in old:
|
||||||
ass = qubesadmin.devices.DeviceAssignment(
|
ass = firewall.qubesadmin.devices.DeviceAssignment(
|
||||||
self.vm.app.domains['dom0'],
|
self.vm.app.domains['dom0'],
|
||||||
ident.replace(':', '_'),
|
ident.replace(':', '_'),
|
||||||
persistent=True)
|
persistent=True)
|
||||||
@ -671,7 +671,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if self.dev_list.selected_list.count() > 0:
|
if self.dev_list.selected_list.count() > 0:
|
||||||
if state == QtCore.Qt.Checked:
|
if state == ui_settingsdlg.QtCore.Qt.Checked:
|
||||||
self.dmm_warning_adv.show()
|
self.dmm_warning_adv.show()
|
||||||
self.dmm_warning_dev.show()
|
self.dmm_warning_dev.show()
|
||||||
else:
|
else:
|
||||||
@ -736,23 +736,23 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
if not feature.startswith('service.'):
|
if not feature.startswith('service.'):
|
||||||
continue
|
continue
|
||||||
service = feature[len('service.'):]
|
service = feature[len('service.'):]
|
||||||
item = QListWidgetItem(service)
|
item = firewall.QListWidgetItem(service)
|
||||||
item.setCheckState(QtCore.Qt.Checked
|
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked
|
||||||
if self.vm.features[feature] else QtCore.Qt.Unchecked)
|
if self.vm.features[feature] else ui_settingsdlg.QtCore.Qt.Unchecked)
|
||||||
self.services_list.addItem(item)
|
self.services_list.addItem(item)
|
||||||
self.new_srv_dict[service] = self.vm.features[feature]
|
self.new_srv_dict[service] = self.vm.features[feature]
|
||||||
|
|
||||||
self.connect(self.services_list, SIGNAL("itemClicked(QListWidgetItem *)"), self.services_item_clicked)
|
self.connect(self.services_list, firewall.SIGNAL("itemClicked(QListWidgetItem *)"), self.services_item_clicked)
|
||||||
|
|
||||||
def __add_service__(self):
|
def __add_service__(self):
|
||||||
srv = str(self.service_line_edit.text()).strip()
|
srv = str(self.service_line_edit.text()).strip()
|
||||||
if srv != "":
|
if srv != "":
|
||||||
if srv in self.new_srv_dict:
|
if srv in self.new_srv_dict:
|
||||||
QMessageBox.information(None, '',
|
firewall.QMessageBox.information(None, '',
|
||||||
self.tr('Service already on the list!'))
|
self.tr('Service already on the list!'))
|
||||||
else:
|
else:
|
||||||
item = QListWidgetItem(srv)
|
item = firewall.QListWidgetItem(srv)
|
||||||
item.setCheckState(QtCore.Qt.Checked)
|
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked)
|
||||||
self.services_list.addItem(item)
|
self.services_list.addItem(item)
|
||||||
self.new_srv_dict[srv] = True
|
self.new_srv_dict[srv] = True
|
||||||
|
|
||||||
@ -762,7 +762,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
if not item:
|
if not item:
|
||||||
return
|
return
|
||||||
if str(item.text()) == 'meminfo-writer':
|
if str(item.text()) == 'meminfo-writer':
|
||||||
QMessageBox.information(None,
|
firewall.QMessageBox.information(None,
|
||||||
self.tr('Service can not be removed'),
|
self.tr('Service can not be removed'),
|
||||||
self.tr('Service meminfo-writer can not be removed from the list.'))
|
self.tr('Service meminfo-writer can not be removed from the list.'))
|
||||||
return
|
return
|
||||||
@ -774,10 +774,10 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
|
|
||||||
def services_item_clicked(self, item):
|
def services_item_clicked(self, item):
|
||||||
if str(item.text()) == 'meminfo-writer':
|
if str(item.text()) == 'meminfo-writer':
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == ui_settingsdlg.QtCore.Qt.Checked:
|
||||||
if not self.include_in_balancing.isChecked():
|
if not self.include_in_balancing.isChecked():
|
||||||
self.include_in_balancing.setChecked(True)
|
self.include_in_balancing.setChecked(True)
|
||||||
elif item.checkState() == QtCore.Qt.Unchecked:
|
elif item.checkState() == ui_settingsdlg.QtCore.Qt.Unchecked:
|
||||||
if self.include_in_balancing.isChecked():
|
if self.include_in_balancing.isChecked():
|
||||||
self.include_in_balancing.setChecked(False)
|
self.include_in_balancing.setChecked(False)
|
||||||
|
|
||||||
@ -788,7 +788,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
try:
|
try:
|
||||||
for r in range(self.services_list.count()):
|
for r in range(self.services_list.count()):
|
||||||
item = self.services_list.item(r)
|
item = self.services_list.item(r)
|
||||||
self.new_srv_dict[str(item.text())] = (item.checkState() == QtCore.Qt.Checked)
|
self.new_srv_dict[str(item.text())] = (item.checkState() == ui_settingsdlg.QtCore.Qt.Checked)
|
||||||
|
|
||||||
balancing_was_checked = self.vm.features.get('service.meminfo-writer', True)
|
balancing_was_checked = self.vm.features.get('service.meminfo-writer', True)
|
||||||
balancing_is_checked = self.include_in_balancing.isChecked()
|
balancing_is_checked = self.include_in_balancing.isChecked()
|
||||||
@ -821,14 +821,14 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
def set_fw_model(self, model):
|
def set_fw_model(self, model):
|
||||||
self.fw_model = model
|
self.fw_model = model
|
||||||
self.rulesTreeView.setModel(model)
|
self.rulesTreeView.setModel(model)
|
||||||
self.rulesTreeView.header().setResizeMode(QHeaderView.ResizeToContents)
|
self.rulesTreeView.header().setResizeMode(firewall.QHeaderView.ResizeToContents)
|
||||||
self.rulesTreeView.header().setResizeMode(0, QHeaderView.Stretch)
|
self.rulesTreeView.header().setResizeMode(0, firewall.QHeaderView.Stretch)
|
||||||
self.set_allow(model.allow)
|
self.set_allow(model.allow)
|
||||||
if model.tempFullAccessExpireTime:
|
if model.tempFullAccessExpireTime:
|
||||||
self.tempFullAccess.setChecked(True)
|
self.tempFullAccess.setChecked(True)
|
||||||
self.tempFullAccessTime.setValue(
|
self.tempFullAccessTime.setValue(
|
||||||
(model.tempFullAccessExpireTime -
|
(model.tempFullAccessExpireTime -
|
||||||
int(datetime.datetime.now().strftime("%s")))/60)
|
int(firewall.datetime.datetime.now().strftime("%s"))) / 60)
|
||||||
|
|
||||||
def disable_all_fw_conf(self):
|
def disable_all_fw_conf(self):
|
||||||
self.firewallModifiedOutsidelabel.setVisible(True)
|
self.firewallModifiedOutsidelabel.setVisible(True)
|
||||||
@ -857,7 +857,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
self.policyDenyRadioButton.isChecked())
|
self.policyDenyRadioButton.isChecked())
|
||||||
|
|
||||||
def new_rule_button_pressed(self):
|
def new_rule_button_pressed(self):
|
||||||
dialog = NewFwRuleDlg()
|
dialog = firewall.NewFwRuleDlg()
|
||||||
self.fw_model.run_rule_dialog(dialog)
|
self.fw_model.run_rule_dialog(dialog)
|
||||||
|
|
||||||
def edit_rule_button_pressed(self):
|
def edit_rule_button_pressed(self):
|
||||||
@ -865,7 +865,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
selected = self.rulesTreeView.selectedIndexes()
|
selected = self.rulesTreeView.selectedIndexes()
|
||||||
|
|
||||||
if len(selected) > 0:
|
if len(selected) > 0:
|
||||||
dialog = NewFwRuleDlg()
|
dialog = firewall.NewFwRuleDlg()
|
||||||
dialog.set_ok_enabled(True)
|
dialog.set_ok_enabled(True)
|
||||||
row = self.rulesTreeView.selectedIndexes().pop().row()
|
row = self.rulesTreeView.selectedIndexes().pop().row()
|
||||||
self.fw_model.populate_edit_dialog(dialog, row)
|
self.fw_model.populate_edit_dialog(dialog, row)
|
||||||
@ -883,7 +883,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
def handle_exception(exc_type, exc_value, exc_traceback):
|
||||||
|
|
||||||
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
||||||
filename = os.path.basename(filename)
|
filename = firewall.os.path.basename(filename)
|
||||||
error = "%s: %s" % (exc_type.__name__, exc_value)
|
error = "%s: %s" % (exc_type.__name__, exc_value)
|
||||||
|
|
||||||
strace = ""
|
strace = ""
|
||||||
@ -896,9 +896,9 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
|||||||
strace += "line no.: %d\n" %line
|
strace += "line no.: %d\n" %line
|
||||||
strace += "file: %s\n" %filename
|
strace += "file: %s\n" %filename
|
||||||
|
|
||||||
msg_box = QMessageBox()
|
msg_box = firewall.QMessageBox()
|
||||||
msg_box.setDetailedText(strace)
|
msg_box.setDetailedText(strace)
|
||||||
msg_box.setIcon(QMessageBox.Critical)
|
msg_box.setIcon(firewall.QMessageBox.Critical)
|
||||||
msg_box.setWindowTitle("Houston, we have a problem...")
|
msg_box.setWindowTitle("Houston, we have a problem...")
|
||||||
msg_box.setText("Whoops. A critical error has occured. This is most likely a bug "
|
msg_box.setText("Whoops. A critical error has occured. This is most likely a bug "
|
||||||
"in Qubes Manager.<br><br>"
|
"in Qubes Manager.<br><br>"
|
||||||
@ -909,7 +909,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
|
|||||||
msg_box.exec_()
|
msg_box.exec_()
|
||||||
|
|
||||||
|
|
||||||
parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
|
parser = firewall.qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
|
||||||
|
|
||||||
parser.add_argument('--tab', metavar='TAB',
|
parser.add_argument('--tab', metavar='TAB',
|
||||||
action='store',
|
action='store',
|
||||||
@ -925,13 +925,13 @@ def main(args=None):
|
|||||||
args = parser.parse_args(args)
|
args = parser.parse_args(args)
|
||||||
vm = args.domains.pop()
|
vm = args.domains.pop()
|
||||||
|
|
||||||
qapp = QApplication(sys.argv)
|
qapp = firewall.QApplication(firewall.sys.argv)
|
||||||
qapp.setOrganizationName('Invisible Things Lab')
|
qapp.setOrganizationName('Invisible Things Lab')
|
||||||
qapp.setOrganizationDomain("https://www.qubes-os.org/")
|
qapp.setOrganizationDomain("https://www.qubes-os.org/")
|
||||||
qapp.setApplicationName("Qubes VM Settings")
|
qapp.setApplicationName("Qubes VM Settings")
|
||||||
|
|
||||||
if not utils.is_debug():
|
if not utils.is_debug():
|
||||||
sys.excepthook = handle_exception
|
firewall.sys.excepthook = handle_exception
|
||||||
|
|
||||||
settings_window = VMSettingsWindow(vm, qapp, args.tab)
|
settings_window = VMSettingsWindow(vm, qapp, args.tab)
|
||||||
settings_window.show()
|
settings_window.show()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python2
|
#!/usr/bin/python2
|
||||||
# -*- coding: utf8 -*-
|
# -*- coding: utf8 -*-
|
||||||
|
# pylint: skip-file
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user