コード例 #1
0
 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
コード例 #2
0
 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)
コード例 #3
0
 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()
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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()
コード例 #10
0
 def launch_alert_log(self, msg):
     log.warning(msg)
     popuplauncher.launch_alert_box_popup(self.root, msg)
コード例 #11
0
 def launch_alert_log(self, msg):
     popuplauncher.launch_alert_box_popup(self.root_params.root, msg)
コード例 #12
0
 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)
コード例 #13
0
 def launch_user_alert(self, msg):
     popuplauncher.launch_alert_box_popup(self.root, msg)
コード例 #14
0
 def preferences_menu_command(self):
     result = popuplauncher.launch_alert_box_popup(self.root,
                                                   "This is a popup")