Skip to content

Commit

Permalink
implemented update check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kummer committed Aug 28, 2017
1 parent a6d6d2e commit f37ccd8
Show file tree
Hide file tree
Showing 6 changed files with 868 additions and 640 deletions.
21 changes: 19 additions & 2 deletions BlenderUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
from distutils.dir_util import copy_tree
import sys
import platform
from distutils.version import StrictVersion
import json


app = QtWidgets.QApplication(sys.argv)
appversion = '1.1'
appversion = '1.0'
dir_ = ''
config = configparser.ConfigParser()
btn = {}
Expand Down Expand Up @@ -112,13 +115,15 @@ def __init__(self, parent=None):
self.btn_oneclick.hide()
self.lbl_quick.hide()
self.lbl_caution.hide()
self.btn_newVersion.hide()
self.lbl_caution.setStyleSheet('background: rgb(255, 155, 8);\n'
'color: white')
global lastversion
global dir_
global config
global installedversion
global flavor
global appversion
if os.path.isfile('./config.ini'):
config_exist = True
config.read('config.ini')
Expand Down Expand Up @@ -173,6 +178,17 @@ def __init__(self, parent=None):
QtWidgets.QMessageBox.critical(
self, "Error", "Please check your internet connection")
sys.exit()
# Check for new version on github
Appupdate = urllib.request.urlopen('https://api.github.com/repos/tobkum/BlenderUpdater/releases/latest')
UpdateData = json.load(Appupdate)
applatestversion = UpdateData['tag_name']
print(UpdateData['tag_name'])
if StrictVersion(applatestversion) > StrictVersion(appversion):
self.btn_newVersion.show()
print(applatestversion)




def select_path(self):
global dir_
Expand Down Expand Up @@ -243,7 +259,8 @@ def check(self):
self.frm_start.show()
soup = BeautifulSoup(req.read(), "html.parser")
"""iterate through the found versions"""
table = soup.find(class_='table')
table = soup.find("table")
print(len(table))
results = []
for col in table.find_all('tr', recursive=False)[0:]:
results.append([data.string for data in col])
Expand Down
Binary file added images/software-update-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.8.1
# Created by: PyQt5 UI code generator 5.9
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -197,6 +197,15 @@ def setupUi(self, MainWindow):
self.lbl_caution.setAutoFillBackground(True)
self.lbl_caution.setAlignment(QtCore.Qt.AlignCenter)
self.lbl_caution.setObjectName("lbl_caution")
self.btn_newVersion = QtWidgets.QPushButton(self.centralwidget)
self.btn_newVersion.setGeometry(QtCore.QRect(500, 10, 151, 35))
icon10 = QtGui.QIcon()
icon10.addPixmap(QtGui.QPixmap(":/newPrefix/images/software-update-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.btn_newVersion.setIcon(icon10)
self.btn_newVersion.setIconSize(QtCore.QSize(24, 24))
self.btn_newVersion.setCheckable(False)
self.btn_newVersion.setChecked(False)
self.btn_newVersion.setObjectName("btn_newVersion")
self.btngrp_filter.raise_()
self.frm_start.raise_()
self.btn_Quit.raise_()
Expand All @@ -210,6 +219,7 @@ def setupUi(self, MainWindow):
self.btn_oneclick.raise_()
self.lbl_quick.raise_()
self.lbl_caution.raise_()
self.btn_newVersion.raise_()
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
Expand Down Expand Up @@ -242,5 +252,7 @@ def retranslateUi(self, MainWindow):
self.btn_oneclick.setText(_translate("MainWindow", "PushButton"))
self.lbl_quick.setText(_translate("MainWindow", "Quick Update"))
self.lbl_caution.setText(_translate("MainWindow", " These builds are not as stable as releases, use at your own risk."))
self.btn_newVersion.setToolTip(_translate("MainWindow", "New version available"))
self.btn_newVersion.setText(_translate("MainWindow", "New version available"))

import res_rc
33 changes: 33 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,38 @@
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="btn_newVersion">
<property name="geometry">
<rect>
<x>500</x>
<y>10</y>
<width>151</width>
<height>35</height>
</rect>
</property>
<property name="toolTip">
<string>New version available</string>
</property>
<property name="text">
<string>New version available</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/newPrefix/images/software-update-icon.png</normaloff>:/newPrefix/images/software-update-icon.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<zorder>btngrp_filter</zorder>
<zorder>frm_start</zorder>
<zorder>btn_Quit</zorder>
Expand All @@ -606,6 +638,7 @@
<zorder>btn_oneclick</zorder>
<zorder>lbl_quick</zorder>
<zorder>lbl_caution</zorder>
<zorder>btn_newVersion</zorder>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
Expand Down
1 change: 1 addition & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<file>images/Open-folder-icon.png</file>
<file>images/Refresh-icon.png</file>
<file>images/Application-exit-icon.png</file>
<file>images/software-update-icon.png</file>
</qresource>
</RCC>
Loading

0 comments on commit f37ccd8

Please sign in to comment.