Moved state.openKeysFile() into bitmessageqt where it's used

This commit is contained in:
Dmitri Bogomolov 2019-11-05 18:59:50 +02:00
parent 185ad66ea5
commit 280095b08f
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 11 additions and 10 deletions

View File

@ -7,6 +7,7 @@ import locale
import os import os
import random import random
import string import string
import subprocess
import sys import sys
import textwrap import textwrap
import threading import threading
@ -48,7 +49,6 @@ import paths
from proofofwork import getPowType from proofofwork import getPowType
import queues import queues
import shutdown import shutdown
import state
from statusbar import BMStatusBar from statusbar import BMStatusBar
import sound import sound
# This is needed for tray icon # This is needed for tray icon
@ -73,6 +73,15 @@ def powQueueSize():
return queue_len 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): class MyForm(settingsmixin.SMainWindow):
# the maximum frequency of message sounds in seconds # 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( 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) "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: if reply == QtGui.QMessageBox.Yes:
shared.openKeysFile() openKeysFile()
# menu button 'delete all treshed messages' # menu button 'delete all treshed messages'
def click_actionDeleteAllTrashedMessages(self): def click_actionDeleteAllTrashedMessages(self):

View File

@ -253,11 +253,3 @@ def fixSensitiveFilePermissions(filename, hasEnabledKeys):
except Exception: except Exception:
logger.exception('Keyfile permissions could not be fixed.') logger.exception('Keyfile permissions could not be fixed.')
raise 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')