diff options
author | Papoteur <papoteur@mageialinux-online.org> | 2016-05-24 21:41:59 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageialinux-online.org> | 2016-05-24 21:41:59 +0200 |
commit | 1d2dc97ffac110ee8dca2d3a83deb6953bcfee01 (patch) | |
tree | cfaa9fbebddc34bc9fbf89c6314af05d0a9e332b /mageiaSync | |
parent | d4199bcbe8297c00d70cc1c612a41c07e0a88fc9 (diff) | |
download | MageiaSync-1d2dc97ffac110ee8dca2d3a83deb6953bcfee01.tar MageiaSync-1d2dc97ffac110ee8dca2d3a83deb6953bcfee01.tar.gz MageiaSync-1d2dc97ffac110ee8dca2d3a83deb6953bcfee01.tar.bz2 MageiaSync-1d2dc97ffac110ee8dca2d3a83deb6953bcfee01.tar.xz MageiaSync-1d2dc97ffac110ee8dca2d3a83deb6953bcfee01.zip |
After signature checking, show an icon, nothing if not OK
Diffstat (limited to 'mageiaSync')
-rw-r--r-- | mageiaSync/mageiaSyncExt.py | 19 | ||||
-rw-r--r-- | mageiaSync/mageiasync.py | 16 |
2 files changed, 24 insertions, 11 deletions
diff --git a/mageiaSync/mageiaSyncExt.py b/mageiaSync/mageiaSyncExt.py index 5c7f053..f2240fd 100644 --- a/mageiaSync/mageiaSyncExt.py +++ b/mageiaSync/mageiaSyncExt.py @@ -22,6 +22,7 @@ class checkThread(QThread): def processSum(self,sumType): import hashlib + checkvalue=0 if sumType=='sha512': hashfunc = hashlib.sha512() if sumType=='md5': @@ -34,12 +35,10 @@ class checkThread(QThread): try: with open(sig_file, 'rb') as g: verified = gpg.verify_file(g) - if not verified.valid: - print('Signature not OK') - return False + if verified.valid: + checkvalue=64 except: print('Signature file %s not found'%sig_file) - return False try: with open(self.destination+'/'+self.path+'/'+self.name, 'rb') as f: while True: @@ -48,16 +47,16 @@ class checkThread(QThread): hashfunc.update(block) sumcalc=hashfunc.hexdigest() except: - return False + return checkvalue try: fs=open(self.destination+'/'+self.path+'/'+self.name+'.'+sumType,'r') except: # reference file not found - return False + return checkvalue sumcheck=(fs.readline()).split()[0] if sumcalc==sumcheck: - return True - return False + checkvalue += 128 + return checkvalue def processDate(self): import datetime as datetime @@ -96,11 +95,11 @@ class checkThread(QThread): signal=400+self.isoIndex self.checkStartSignal.emit(signal) checkMd5=self.processSum('md5') - self.md5Signal.emit(self.isoIndex+128*checkMd5) + self.md5Signal.emit(self.isoIndex+checkMd5) signal=300+self.isoIndex self.checkStartSignal.emit(signal) checkSha=self.processSum('sha512') - self.sha1Signal.emit(self.isoIndex+128*checkSha) + self.sha1Signal.emit(self.isoIndex+checkSha) self.quit() diff --git a/mageiaSync/mageiasync.py b/mageiaSync/mageiasync.py index cc060d9..b67ea52 100644 --- a/mageiaSync/mageiasync.py +++ b/mageiaSync/mageiasync.py @@ -2,7 +2,7 @@ from PyQt5.QtWidgets import ( QProgressDialog, QMainWindow, QDialog, QFileDialog, QApplication) -from PyQt5.QtGui import ( QStandardItemModel,QStandardItem, QDesktopServices, ) +from PyQt5.QtGui import ( QStandardItemModel,QStandardItem, QDesktopServices, QIcon, ) from PyQt5.QtCore import ( QLibraryInfo, QUrl, QItemSelectionModel ) from PyQt5 import QtCore # , Qt, QThread, QObject, pyqtSignal) import sys @@ -259,21 +259,35 @@ class IsosViewer(QMainWindow, mageiaSyncUI.Ui_mainWindow): self.model.setData(self.model.index(row, col, QtCore.QModelIndex()), self.tr("Checking")) def md5Check(self,check): + verified=False if check>=128: val=self.tr("OK") row=check-128 + if row >= 64: + verified=True + row -= 64 else: val=self.tr("Failed") row=check + if verified: + # we add an icon for the GPG key + self.model.setData(self.model.index(row, 4, QtCore.QModelIndex()),QIcon("preflight-verifier"),1) self.model.setData(self.model.index(row, 4, QtCore.QModelIndex()), val) def sha1Check(self,check): + verified=False if check>=128: val=self.tr("OK") row=check-128 + if row >= 64: + verified=True + row -= 64 else: val=self.tr("Failed") row=check + if verified: + # we add an icon for the GPG key + self.model.setData(self.model.index(row, 4, QtCore.QModelIndex()),QIcon("preflight-verifier"),1) self.model.setData(self.model.index(row, 3, QtCore.QModelIndex()), val) def dateCheck(self,check): |