def get_selected_key(self): result = self.view.console_key_option_var.get() target_keyid = result.split()[-1] if target_keyid == 'Keys': msg = 'Must select key from dropdown menu.' popuplauncher.launch_alert_box_popup(self.root, msg) return None else: return target_keyid
def run_verify(self): message = self.get_console_text() result = self.gpg_client.verify(message) if result.valid: msg = "Success! Signature is valid.\nUser: {}\nFingerprint: {}\n\n".format( result.username, result.fingerprint) else: msg = result.stderr popuplauncher.launch_alert_box_popup(self.root, msg)
def run_import(self): pub_key = self.get_console_text() result = self.gpg_client.import_key(pub_key) if result.imported == 0: popuplauncher.launch_alert_box_popup(self.root, result.stderr) else: msg = "Success! Key imported.\n\n" msg += result.stderr popuplauncher.launch_alert_box_popup(self.root, msg) self.gpg_data_context.set_key_list()
def run_export(self): selected_key_id = self.get_selected_key() if selected_key_id is None: return None result = self.gpg_client.export_key(selected_key_id) if result == '': msg = 'Export error with key: {}'.format(selected_key_id) popuplauncher.launch_alert_box_popup(self.root, msg) return None else: self.print_to_console(result)
def run_decrypt(self): passphrase = popuplauncher.launch_get_passphrase_popup(self.root) if passphrase is None: msg = 'Decrypt cancelled.' popuplauncher.launch_alert_box_popup(self.root, msg) return None ciphertext = self.get_console_text() result = self.gpg_client.decrypt(ciphertext, passphrase) if result.ok: self.print_to_console(result) else: popuplauncher.launch_alert_box_popup(self.root, result.stderr)
def run_encrypt(self): selected_key_id = self.get_selected_key() if selected_key_id is None: return None plaintext = self.get_console_text() result = self.gpg_client.encrypt(plaintext, selected_key_id) if result is None: msg = 'Error: no such key in keyring.' popuplauncher.launch_alert_box_popup(self.root, msg) elif result.ok: self.print_to_console(result) else: popuplauncher.launch_alert_box_popup(self.root, result.stderr)
def run_sign(self): selected_key_id = self.get_selected_key() if selected_key_id is None: return None passphrase = popuplauncher.launch_get_passphrase_popup(self.root) if passphrase is None: msg = 'Sign cancelled.' popuplauncher.launch_alert_box_popup(self.root, msg) return None text = self.get_console_text() result = self.gpg_client.sign(text, selected_key_id, passphrase) if result.fingerprint is None: popuplauncher.launch_alert_box_popup(self.root, result.stderr) else: self.print_to_console(result)
def test_launch_alert_box_calls_show(self, mocked): one = MagicMock() two = MagicMock() val = MagicMock() val.return_value = 'xxx' mocked.return_value = val result = popuplauncher.launch_alert_box_popup(one, two) mocked.return_value.show.assert_called_with() self.assertEqual(result, mocked.return_value.show.return_value)
def run_button_clicked(self, event): selected_function = self.get_selected_function() if self.running_job: msg = 'Job already running. Please wait.' popuplauncher.launch_alert_box_popup(self.root, msg) elif selected_function not in self.func_list: msg = 'You must select a function from the dropdown menu.' popuplauncher.launch_alert_box_popup(self.root, msg) elif selected_function == 'Encrypt': self.run_encrypt() elif selected_function == 'Decrypt': self.run_decrypt() elif selected_function == 'Export': self.run_export() elif selected_function == 'Import': self.run_import() elif selected_function == 'Sign': self.run_sign() elif selected_function == 'Verify': self.run_verify()
def launch_alert_log(self, msg): log.warning(msg) popuplauncher.launch_alert_box_popup(self.root, msg)
def launch_alert_log(self, msg): popuplauncher.launch_alert_box_popup(self.root_params.root, msg)
def test_launch_alert_box_takes_two_args(self, mocked): one = MagicMock() two = MagicMock() result = popuplauncher.launch_alert_box_popup(one, two) mocked.assert_called_with(one, two)
def launch_user_alert(self, msg): popuplauncher.launch_alert_box_popup(self.root, msg)
def preferences_menu_command(self): result = popuplauncher.launch_alert_box_popup(self.root, "This is a popup")