Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switched from qt4 to qt5 #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Esp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@
CHIP_ERASE_TIMEOUT = 120 # timeout for full chip erase
SYNC_TIMEOUT = 0.1 # timeout for syncing with bootloader

from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt5.QtCore import *

class ESPTool(QObject):
percentchange = pyqtSignal(int)
eraseStartSig = pyqtSignal()

def __init__(self,parent=None):
super(ESPTool,self).__init__(parent)
def updatePer(self,per):
self.emit(SIGNAL("percentchange"),per)
self.percentchange.emit(per)
def eraseStart(self):
self.emit(SIGNAL("eraseStart"))
self.eraseStartSig.emit()

esptool=None
updateOkReset=None
Expand Down Expand Up @@ -2438,6 +2441,7 @@ def __call__(self, parser, namespace, value, option_string=None):
clk,q,d,hd,cs = values
value = (hd << 24) | (cs << 18) | (d << 12) | (q << 6) | clk
else:
# FIXME
raise argparse.ArgumentError(self, '%s is not a valid spi-connection value. ' +
'Values are SPI, HSPI, or a sequence of 5 pin numbers CLK,Q,D,HD,CS).' % values)
setattr(namespace, self.dest, value)
Expand Down
46 changes: 29 additions & 17 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@
import zipfile


from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

nowIDEVersion ="1.1"
nowExamplesVersion="v0.0"
rootDirectoryPath =os.path.expanduser("~")
rootDirectoryPath =rootDirectoryPath.replace("\\","/")

class checkVersionExampleFire(QThread):
updateThing = pyqtSignal(str, str)
updatePer = pyqtSignal(int)
reflushExamples = pyqtSignal()
changeUpdateFirmwareList = pyqtSignal(dict)
changeIsCheckFirmware = pyqtSignal(bool)

def __init__(self,parent):
super(checkVersionExampleFire,self).__init__(parent)
self.ui=parent
Expand All @@ -35,7 +42,7 @@ def __init__(self,parent):
self.downloadOk=False
self.status=404

self.connect(self.ui,SIGNAL("exitCheckThread"),self.exitCheckThread)
self.ui.exitCheckThread.connect(self.exitCheckThread)

def run(self):
global nowExamplesVersion
Expand Down Expand Up @@ -77,8 +84,7 @@ def run(self):
myfile.write(page)
myfile.close()

self.emit(SIGNAL("changeIsCheckFirmware"),True)

self.changeIsCheckFirmware.emit(True)
self.system = platform.system()#system check

print(self.system)
Expand All @@ -94,21 +100,25 @@ def run(self):
self.firmwareList = jsonmsg['firmware']
self.examplesList = jsonmsg['examples']

self.emit(SIGNAL("changeUpdateFirmwareList"),self.firmwareList)
self.changeUpdateFirmwareList.emit(self.firmwareList)

self.connect(self.ui,SIGNAL("confirmUpdata"),self.confirmUpdata)
self.ui.confirmUpdata.connect(self.confirmUpdata)

#IDE
if self.ideList[0]["version"]>nowIDEVersion:
print("ide has new version")
self.isDownload=True
self.emit(SIGNAL("updateThing"),"update uPyCraft IDE","There is a new version available for uPyCraft, would you like to upgrade now?")
self.updateThing.emit("update uPyCraft IDE",
"There is a new version available for uPyCraft, would you like to upgrade now?")
else:
#examples
if self.examplesList[0]["version"]>nowExamplesVersion:
print("examples has new version")
self.isDownload=True
self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?")
self.updateThing.emit("update uPyCraft Examples",
"There is a new version available for EXAMPLES, would you like to upgrade now?"
)

while 1:
if self.isDownload==True:
if self.nowDownload=="":
Expand All @@ -125,7 +135,8 @@ def run(self):

if self.examplesList[0]["version"]>nowExamplesVersion:
print("examples has new version")
self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?")
self.updateThing.emit("update uPyCraft Examples",
"There is a new version available for EXAMPLES, would you like to upgrade now?")
else:
self.isDownload=False
elif self.nowDownload == "Examples":
Expand All @@ -140,7 +151,7 @@ def run(self):
for afile in f.namelist():
f.extract(afile,"%s/AppData/Local/uPyCraft"%rootDirectoryPath)
f.close()
self.emit(SIGNAL("reflushExamples"))
self.reflushExamples.emit()
self.isDownload=False
else:
break
Expand All @@ -152,7 +163,7 @@ def exitCheckThread(self):
def reDownload(self):
if self.reDownloadNum==3:
self.downloadOk=False
self.emit(SIGNAL("updatePer"),-1)
self.updatePer.emit(-1)
return
try:
socket.setdefaulttimeout(3)
Expand All @@ -175,7 +186,8 @@ def confirmUpdata(self,gotoUpdata):
elif gotoUpdata=="IDEcancel":
if self.examplesList[0]["version"]>nowExamplesVersion:
print("examples has new version")
self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?")
self.updateThing.emit("update uPyCraft Examples",
"There is a new version available for EXAMPLES, would you like to upgrade now?")
else:
self.isDownload=False
elif gotoUpdata=="Examples":
Expand All @@ -192,10 +204,10 @@ def cbkUpdate(self,blocknum,blocksize,totalsize):
self.per=100.0*blocknum*blocksize/self.updateSize
if self.per>=100:
self.per=100
self.emit(SIGNAL("updatePer"),self.per)
self.updatePer.emit(self.per)
return

self.emit(SIGNAL("updatePer"),self.per)
self.updatePer.emit(self.per)

class attentionUpdata(QDialog):
def __init__(self,title,labelmsg,parent=None):
Expand All @@ -220,8 +232,8 @@ def __init__(self,title,labelmsg,parent=None):

self.setLayout(layout)
self.setFixedSize(500, 100)
self.connect(self.okButton,SIGNAL("clicked()"),self.chooseOk)
self.connect(self.cancelButton,SIGNAL("clicked()"),self.chooseCancel)
self.okButton.clicked.connect(self.chooseOk)
self.cancelButton.clicked.connect(self.chooseCancel)

def chooseOk(self):
self.close()
Expand Down
Loading