From 280095b08f68143d5ca7e3fb836a1a7ade87f63d Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 5 Nov 2019 18:59:50 +0200 Subject: [PATCH] Moved state.openKeysFile() into bitmessageqt where it's used --- src/bitmessageqt/__init__.py | 13 +++++++++++-- src/shared.py | 8 -------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 88d41b7f..bf391882 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -7,6 +7,7 @@ import locale import os import random import string +import subprocess import sys import textwrap import threading @@ -48,7 +49,6 @@ import paths from proofofwork import getPowType import queues import shutdown -import state from statusbar import BMStatusBar import sound # This is needed for tray icon @@ -73,6 +73,15 @@ def powQueueSize(): return queue_len +def openKeysFile(): + """Open keys file with an external editor""" + keysfile = os.path.join(state.appdata, 'keys.dat') + if 'linux' in sys.platform: + subprocess.call(["xdg-open", keysfile]) + elif sys.platform.startswith('win'): + os.startfile(keysfile) # pylint: disable=no-member + + class MyForm(settingsmixin.SMainWindow): # the maximum frequency of message sounds in seconds @@ -1544,7 +1553,7 @@ class MyForm(settingsmixin.SMainWindow): reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate( "MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(state.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: - shared.openKeysFile() + openKeysFile() # menu button 'delete all treshed messages' def click_actionDeleteAllTrashedMessages(self): diff --git a/src/shared.py b/src/shared.py index 072d04c0..3a6fbc31 100644 --- a/src/shared.py +++ b/src/shared.py @@ -253,11 +253,3 @@ def fixSensitiveFilePermissions(filename, hasEnabledKeys): except Exception: logger.exception('Keyfile permissions could not be fixed.') raise - - -def openKeysFile(): - """Open keys file with an external editor""" - if 'linux' in sys.platform: - subprocess.call(["xdg-open", state.appdata + 'keys.dat']) - else: - os.startfile(state.appdata + 'keys.dat')