Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.distribution.text():
options['args'].extend(['--distribution',
self.distribution.text()])
record_usage(docker_distribution=True)
if self.install_pkgs.isChecked():
options['args'].append('--install-pkgs')
record_usage(root=options['root'],
docker_install_pkgs=self.install_pkgs.isChecked())
return options
class VagrantOptions(UnpackerOptions):
def __init__(self):
super(VagrantOptions, self).__init__()
self.image = QtGui.QLineEdit(placeholderText='detect')
self.add_row("Base box:", self.image)
self.distribution = QtGui.QLineEdit(placeholderText='detect')
self.add_row("Distribution:", self.distribution)
self.memory = QtGui.QSpinBox(suffix="MB", minimum=99, maximum=64000,
specialValueText="(default)", value=99)
self.add_row("Memory:", self.memory)
self.gui = QtGui.QCheckBox("Enable local GUI")
self.add_row("GUI:", self.gui)
class UnpackerOptions(QtGui.QWidget):
def __init__(self):
super(UnpackerOptions, self).__init__()
self.setLayout(QtGui.QGridLayout())
def add_row(self, label, widget):
layout = self.layout()
row = layout.rowCount()
layout.addWidget(QtGui.QLabel(label), row, 0)
layout.addWidget(widget, row, 1)
def options(self):
return {'args': []}
class DirectoryOptions(UnpackerOptions):
def __init__(self):
super(DirectoryOptions, self).__init__()
self.layout().addWidget(
QtGui.QLabel("(directory unpacker has no option)"),
0, 0, 1, 2)
class ChrootOptions(UnpackerOptions):
def __init__(self):
super(ChrootOptions, self).__init__()
self.root = QtGui.QComboBox(editable=False)
self.root.addItems(ROOT.TEXT)
self.add_row("Elevate privileges:", self.root)
self.preserve_owner = QtGui.QCheckBox("enabled", tristate=True)
layout.addWidget(QtGui.QLabel(label), row, 0)
layout.addWidget(widget, row, 1)
def options(self):
return {'args': []}
class DirectoryOptions(UnpackerOptions):
def __init__(self):
super(DirectoryOptions, self).__init__()
self.layout().addWidget(
QtGui.QLabel("(directory unpacker has no option)"),
0, 0, 1, 2)
class ChrootOptions(UnpackerOptions):
def __init__(self):
super(ChrootOptions, self).__init__()
self.root = QtGui.QComboBox(editable=False)
self.root.addItems(ROOT.TEXT)
self.add_row("Elevate privileges:", self.root)
self.preserve_owner = QtGui.QCheckBox("enabled", tristate=True)
self.preserve_owner.setCheckState(QtCore.Qt.PartiallyChecked)
self.add_row("Preserve file ownership:", self.preserve_owner)
self.magic_dirs = QtGui.QCheckBox(
"mount /dev and /proc inside the chroot", tristate=True)
self.magic_dirs.setCheckState(QtCore.Qt.PartiallyChecked)
self.add_row("Mount magic dirs:", self.magic_dirs)
elif self.preserve_owner.checkState() == QtCore.Qt.Checked:
options['args'].append('--preserve-owner')
if self.magic_dirs.checkState() == QtCore.Qt.Unchecked:
options['args'].append('--dont-bind-magic-dirs')
elif self.magic_dirs.checkState() == QtCore.Qt.Checked:
options['args'].append('--bind-magic-dirs')
record_usage(
chroot_preserve_owner=self.preserve_owner.checkState(),
chroot_magic_dirs=self.magic_dirs.checkState())
return options
class DockerOptions(UnpackerOptions):
def __init__(self):
super(DockerOptions, self).__init__()
self.root = QtGui.QComboBox(editable=False)
self.root.addItems(ROOT.TEXT)
self.add_row("Elevate privileges:", self.root)
try:
cmd = ['docker-machine', 'ls', '-q']
query = subprocess.Popen(cmd, stdout=subprocess.PIPE)
out, _ = query.communicate()
if query.returncode != 0:
raise subprocess.CalledProcessError(query.returncode, cmd)
self.machine = QtGui.QComboBox(editable=False)
if 'DOCKER_HOST' in os.environ:
self.machine.addItem("Custom config from environment", None)
def __init__(self):
super(UnpackerOptions, self).__init__()
self.setLayout(QtGui.QGridLayout())