revealer: fix path madness
don't use translated strings in file system paths!
This commit is contained in:
@@ -34,7 +34,7 @@ class Plugin(BasePlugin):
|
|||||||
|
|
||||||
def __init__(self, parent, config, name):
|
def __init__(self, parent, config, name):
|
||||||
BasePlugin.__init__(self, parent, config, name)
|
BasePlugin.__init__(self, parent, config, name)
|
||||||
self.base_dir = config.electrum_path()+'/revealer/'
|
self.base_dir = os.path.join(config.electrum_path(), 'revealer')
|
||||||
|
|
||||||
if self.config.get('calibration_h') is None:
|
if self.config.get('calibration_h') is None:
|
||||||
self.config.set_key('calibration_h', 0)
|
self.config.set_key('calibration_h', 0)
|
||||||
@@ -184,11 +184,20 @@ class Plugin(BasePlugin):
|
|||||||
self.bdone(dialog)
|
self.bdone(dialog)
|
||||||
self.d.close()
|
self.d.close()
|
||||||
|
|
||||||
|
def get_path_to_revealer_file(self, ext: str= '') -> str:
|
||||||
|
filename = self.filename_prefix + self.version + "_" + self.code_id + ext
|
||||||
|
path = os.path.join(self.base_dir, filename)
|
||||||
|
return os.path.normcase(os.path.abspath(path))
|
||||||
|
|
||||||
|
def get_path_to_calibration_file(self):
|
||||||
|
path = os.path.join(self.base_dir, 'calibration.pdf')
|
||||||
|
return os.path.normcase(os.path.abspath(path))
|
||||||
|
|
||||||
def bcrypt(self, dialog):
|
def bcrypt(self, dialog):
|
||||||
self.rawnoise = False
|
self.rawnoise = False
|
||||||
dialog.show_message(''.join([_("{} encrypted for Revealer {}_{} saved as PNG and PDF at: ").format(self.was, self.version, self.code_id),
|
dialog.show_message(''.join([_("{} encrypted for Revealer {}_{} saved as PNG and PDF at: ").format(self.was, self.version, self.code_id),
|
||||||
"<b>", self.base_dir+ self.filename+self.version+"_"+self.code_id,"</b>", "<br/>",
|
"<b>", self.get_path_to_revealer_file(), "</b>", "<br/>",
|
||||||
"<br/>", "<b>", _("Always check you backups.") ]))
|
"<br/>", "<b>", _("Always check you backups.")]))
|
||||||
dialog.close()
|
dialog.close()
|
||||||
|
|
||||||
def ext_warning(self, dialog):
|
def ext_warning(self, dialog):
|
||||||
@@ -198,7 +207,7 @@ class Plugin(BasePlugin):
|
|||||||
|
|
||||||
def bdone(self, dialog):
|
def bdone(self, dialog):
|
||||||
dialog.show_message(''.join([_("Digital Revealer ({}_{}) saved as PNG and PDF at:").format(self.version, self.code_id),
|
dialog.show_message(''.join([_("Digital Revealer ({}_{}) saved as PNG and PDF at:").format(self.version, self.code_id),
|
||||||
"<br/>","<b>", self.base_dir + 'revealer_' +self.version + '_'+ self.code_id, '</b>']))
|
"<br/>","<b>", self.get_path_to_revealer_file(), '</b>']))
|
||||||
|
|
||||||
|
|
||||||
def customtxt_limits(self):
|
def customtxt_limits(self):
|
||||||
@@ -265,10 +274,8 @@ class Plugin(BasePlugin):
|
|||||||
self.vbox.addLayout(Buttons(CloseButton(d)))
|
self.vbox.addLayout(Buttons(CloseButton(d)))
|
||||||
return bool(d.exec_())
|
return bool(d.exec_())
|
||||||
|
|
||||||
|
def update_wallet_name(self, name):
|
||||||
def update_wallet_name (self, name):
|
|
||||||
self.wallet_name = str(name)
|
self.wallet_name = str(name)
|
||||||
self.base_name = self.base_dir + self.wallet_name
|
|
||||||
|
|
||||||
def seed_img(self, is_seed = True):
|
def seed_img(self, is_seed = True):
|
||||||
|
|
||||||
@@ -380,10 +387,10 @@ class Plugin(BasePlugin):
|
|||||||
revealer = revealer.scaled(self.f_size, Qt.KeepAspectRatio)
|
revealer = revealer.scaled(self.f_size, Qt.KeepAspectRatio)
|
||||||
revealer = self.overlay_marks(revealer)
|
revealer = self.overlay_marks(revealer)
|
||||||
|
|
||||||
self.filename = 'Revealer - '
|
self.filename_prefix = 'revealer_'
|
||||||
revealer.save(self.base_dir + self.filename + self.version+'_'+self.code_id + '.png')
|
revealer.save(self.get_path_to_revealer_file('.png'))
|
||||||
self.toPdf(QImage(revealer))
|
self.toPdf(QImage(revealer))
|
||||||
QDesktopServices.openUrl(QUrl.fromLocalFile(os.path.abspath(self.base_dir + self.filename + self.version+'_'+ self.code_id + '.pdf')))
|
QDesktopServices.openUrl(QUrl.fromLocalFile(self.get_path_to_revealer_file('.pdf')))
|
||||||
|
|
||||||
def make_cypherseed(self, img, rawnoise, calibration=False, is_seed = True):
|
def make_cypherseed(self, img, rawnoise, calibration=False, is_seed = True):
|
||||||
img = img.convertToFormat(QImage.Format_Mono)
|
img = img.convertToFormat(QImage.Format_Mono)
|
||||||
@@ -398,19 +405,19 @@ class Plugin(BasePlugin):
|
|||||||
cypherseed = self.overlay_marks(cypherseed, True, calibration)
|
cypherseed = self.overlay_marks(cypherseed, True, calibration)
|
||||||
|
|
||||||
if not is_seed:
|
if not is_seed:
|
||||||
self.filename = _('custom_secret')+'_'
|
self.filename_prefix = 'custom_secret_'
|
||||||
self.was = _('Custom secret')
|
self.was = _('Custom secret')
|
||||||
else:
|
else:
|
||||||
self.filename = self.wallet_name+'_'+ _('seed')+'_'
|
self.filename_prefix = self.wallet_name + '_seed_'
|
||||||
self.was = self.wallet_name +' ' + _('seed')
|
self.was = self.wallet_name + ' ' + _('seed')
|
||||||
if self.extension:
|
if self.extension:
|
||||||
self.ext_warning(self.c_dialog)
|
self.ext_warning(self.c_dialog)
|
||||||
|
|
||||||
|
|
||||||
if not calibration:
|
if not calibration:
|
||||||
self.toPdf(QImage(cypherseed))
|
self.toPdf(QImage(cypherseed))
|
||||||
QDesktopServices.openUrl (QUrl.fromLocalFile(os.path.abspath(self.base_dir+self.filename+self.version+'_'+self.code_id+'.pdf')))
|
QDesktopServices.openUrl(QUrl.fromLocalFile(self.get_path_to_revealer_file('.pdf')))
|
||||||
cypherseed.save(self.base_dir + self.filename +self.version + '_'+ self.code_id + '.png')
|
cypherseed.save(self.get_path_to_revealer_file('.png'))
|
||||||
self.bcrypt(self.c_dialog)
|
self.bcrypt(self.c_dialog)
|
||||||
return cypherseed
|
return cypherseed
|
||||||
|
|
||||||
@@ -421,7 +428,7 @@ class Plugin(BasePlugin):
|
|||||||
self.make_calnoise()
|
self.make_calnoise()
|
||||||
img = self.overlay_marks(self.calnoise.scaledToHeight(self.f_size.height()), False, True)
|
img = self.overlay_marks(self.calnoise.scaledToHeight(self.f_size.height()), False, True)
|
||||||
self.calibration_pdf(img)
|
self.calibration_pdf(img)
|
||||||
QDesktopServices.openUrl (QUrl.fromLocalFile(os.path.abspath(self.base_dir+_('calibration')+'.pdf')))
|
QDesktopServices.openUrl(QUrl.fromLocalFile(self.get_path_to_calibration_file()))
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def toPdf(self, image):
|
def toPdf(self, image):
|
||||||
@@ -429,7 +436,7 @@ class Plugin(BasePlugin):
|
|||||||
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
|
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
|
||||||
printer.setResolution(600)
|
printer.setResolution(600)
|
||||||
printer.setOutputFormat(QPrinter.PdfFormat)
|
printer.setOutputFormat(QPrinter.PdfFormat)
|
||||||
printer.setOutputFileName(self.base_dir+self.filename+self.version + '_'+self.code_id+'.pdf')
|
printer.setOutputFileName(self.get_path_to_revealer_file('.pdf'))
|
||||||
printer.setPageMargins(0,0,0,0,6)
|
printer.setPageMargins(0,0,0,0,6)
|
||||||
painter = QPainter()
|
painter = QPainter()
|
||||||
painter.begin(printer)
|
painter.begin(printer)
|
||||||
@@ -454,7 +461,7 @@ class Plugin(BasePlugin):
|
|||||||
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
|
printer.setPaperSize(QSizeF(210, 297), QPrinter.Millimeter)
|
||||||
printer.setResolution(600)
|
printer.setResolution(600)
|
||||||
printer.setOutputFormat(QPrinter.PdfFormat)
|
printer.setOutputFormat(QPrinter.PdfFormat)
|
||||||
printer.setOutputFileName(self.base_dir+_('calibration')+'.pdf')
|
printer.setOutputFileName(self.get_path_to_calibration_file())
|
||||||
printer.setPageMargins(0,0,0,0,6)
|
printer.setPageMargins(0,0,0,0,6)
|
||||||
|
|
||||||
painter = QPainter()
|
painter = QPainter()
|
||||||
|
|||||||
Reference in New Issue
Block a user