def _directory_changed(self, new_dir=None, force=False): if not force and self.directory_widget.text() == self.directory: return self.directory = self.directory_widget.text() unpacker = reprounzip.check_directory(self.directory) self.runs_widget.clear() if unpacker is not None: with open(self.directory + '/config.yml') as fp: self.config = yaml.load(fp) self.run_widget.setEnabled(True) self.destroy_widget.setEnabled(True) self.files_button.setEnabled(True) self.unpacker = unpacker self.unpacker_widget.setText(unpacker) for run in self.config['runs']: self.runs_widget.addItem(' '.join( reprounzip.shell_escape(arg) for arg in run['argv'])) self.runs_widget.selectAll() self.unpacker_options.setCurrentIndex( dict((n, i) for i, (n, w) in enumerate(self.UNPACKERS)).get(unpacker, 4)) else: self.run_widget.setEnabled(False) self.destroy_widget.setEnabled(False) self.files_button.setEnabled(False) self.unpacker = None self.unpacker_widget.setText("-") self.unpacker_options.setCurrentIndex(len(self.UNPACKERS))
def _directory_changed(self, new_dir=None, force=False): if not force and self.directory_widget.text() == self.directory: return self.directory = self.directory_widget.text() unpacker = reprounzip.check_directory(self.directory) self.run_jupyter_notebook.setChecked(False) self.run_jupyter_notebook.setEnabled(False) self.runs_widget.clear() if unpacker is not None: with open(self.directory + '/config.yml') as fp: self.config = yaml.safe_load(fp) self.run_widget.setEnabled(True) self.destroy_widget.setEnabled(True) self.files_button.setEnabled(True) self.unpacker = unpacker self.unpacker_widget.setText(unpacker) for run in self.config['runs']: self.runs_widget.addItem(' '.join(reprounzip.shell_escape(arg) for arg in run['argv'])) self.runs_widget.selectAll() self.unpacker_options.setCurrentIndex( dict((n, i) for i, (n, w) in enumerate(self.UNPACKERS)) .get(unpacker, 4)) if (unpacker == 'docker' and reprounzip.find_command('reprozip-jupyter') is not None and reprounzip.is_jupyter(self.directory)): self.run_jupyter_notebook.setEnabled(True) self.run_jupyter_notebook.setChecked(True) else: self.run_widget.setEnabled(False) self.destroy_widget.setEnabled(False) self.files_button.setEnabled(False) self.unpacker = None self.unpacker_widget.setText("-") self.unpacker_options.setCurrentIndex(len(self.UNPACKERS))