Skip to content

Commit 7eb5f69

Browse files
committed
About dialog, updater, migrate to pyinstaller for windows builds
1 parent 2462185 commit 7eb5f69

10 files changed

+302
-55
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ gui/*.py
33
*.swp
44
build/
55
buildreqs/
6+
dist/

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
UI_OBJS = gui/mainwindow.py
1+
UI_OBJS = gui/mainwindow.py gui/about.py
22
RCC_FILES = assets/assets.py
33

44
%.py: %.ui

build.bat

+4-15
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,13 @@ set pythonpath="buildreqs/WinPython-32bit-2.7.13.1Zero/python-2.7.13"
55

66
set python_exe=%pythonpath%\python.exe
77
set iscc_exe=%innopath%\ISCC.exe
8+
set pyinstaller=%pythonpath%\Scripts\pyinstaller.exe
89

910
echo - install requirements
10-
%python_exe% -m pip install cx_freeze
11-
%python_exe% -m pip install -r requirements.txt
11+
%python_exe% -m pip install pyinstaller -r requirements.txt
1212

13-
echo - distutils cx_freeze build
14-
%python_exe% setup.py build || goto :error
15-
16-
echo - cleanup
17-
rd /S /Q build\exe.win32-2.7\PySide\examples
18-
rd /S /Q build\exe.win32-2.7\PySide\translations
19-
rd /S /Q build\exe.win32-2.7\PySide\docs
20-
rd /S /Q build\exe.win32-2.7\PySide\scripts
21-
rd /S /Q build\exe.win32-2.7\PySide\typesystems
22-
del /Q build\exe.win32-2.7\PySide\*.exe
23-
del /Q build\exe.win32-2.7\PySide\QtWebKit*
24-
del /Q build\exe.win32-2.7\PySide\QtDesigner*
25-
del /Q build\exe.win32-2.7\PySide\Qt3Support4*
13+
echo - pyinstaller build
14+
%pyinstaller% --noconfirm chainsign.spec
2615

2716
echo - Inno Setup build
2817
%iscc_exe% "installer.iss" || goto :error

chainsign.py

+35-5
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@
33
import os
44
import logging
55
import traceback
6+
import json
67

78
from PySide import QtGui, QtCore
89

910
# This is needed for SVG assets to be loaded on Windows builds!
1011
from PySide import QtSvg, QtXml # noqa
1112

12-
from gui import mainwindow
13+
from gui import mainwindow, about
1314

1415
from timestamper import rpcurl_from_config
1516
from workers import VerifyThread, TimestampThread
1617
from models import FileListModel
18+
from updater import UpdateCheckerThread
1719

1820

19-
# Disable logging on Windows as it seems to lockup QThreads...?!
20-
if os.name != 'nt':
21-
logging.basicConfig(level=logging.DEBUG)
22-
21+
logging.basicConfig(level=logging.DEBUG)
2322

2423
def qt_excepthook(type, value, tb):
2524
sys.__excepthook__(type, value, tb)
@@ -41,6 +40,34 @@ def walk(directory):
4140
for f in filenames:
4241
yield os.path.join(dirpath, f)
4342

43+
class AboutDialog(QtGui.QDialog, about.Ui_AboutDialog):
44+
def __init__(self, parent=None):
45+
super(AboutDialog, self).__init__(parent)
46+
self.setupUi(self)
47+
th = UpdateCheckerThread(self)
48+
th.response.connect(self.on_updater_response)
49+
th.start()
50+
51+
def on_updater_response(self, resp):
52+
data = json.loads(resp)
53+
54+
if data is None:
55+
self.updaterLabel.setText("Non-public development release")
56+
elif data.get('error'):
57+
self.updaterLabel.setText(
58+
'<i>An error occured during update check:</i><br />'
59+
'%s' % data.get('error'))
60+
elif data.get('binary_url'):
61+
latest = data.get('latest')
62+
self.updaterLabel.setText(
63+
'New update available: <b>%s</b> <i>(%s)</i><br />'
64+
'<a href="%s">Download update</a> &bull; '
65+
'<a href="%s">Release info</a>' % (
66+
latest.get('tag_name'), latest.get('name'),
67+
data.get('binary_url'), latest.get('html_url')))
68+
else:
69+
self.updaterLabel.setText("No update available")
70+
4471
class MainWindow(QtGui.QMainWindow, mainwindow.Ui_MainWindow):
4572
worker = None
4673

@@ -131,6 +158,9 @@ def on_actionQuit_triggered(self):
131158
"""This handles activation of "Exit" menu action"""
132159
self.app.exit()
133160

161+
@QtCore.Slot()
162+
def on_actionAbout_triggered(self):
163+
AboutDialog(self).exec_()
134164

135165
if __name__ == "__main__":
136166
app = QtGui.QApplication(sys.argv)

chainsign.spec

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- mode: python -*-
2+
3+
block_cipher = None
4+
5+
def get_rev():
6+
return open('.git/' + (open('.git/HEAD').read().strip().split(': ')[1])).read()[:7]
7+
8+
with open('build/build_id.txt', 'w') as fd:
9+
fd.write(get_rev())
10+
11+
a = Analysis(['chainsign.py'],
12+
pathex=['.'],
13+
binaries=[],
14+
datas=[('build/build_id.txt', '.')],
15+
hiddenimports=[],
16+
hookspath=[],
17+
runtime_hooks=[],
18+
excludes=[],
19+
win_no_prefer_redirects=False,
20+
win_private_assemblies=False,
21+
cipher=block_cipher)
22+
pyz = PYZ(a.pure, a.zipped_data,
23+
cipher=block_cipher)
24+
exe = EXE(pyz,
25+
a.scripts,
26+
exclude_binaries=True,
27+
name='chainsign',
28+
debug=False,
29+
strip=False,
30+
upx=True,
31+
console=False,
32+
icon='assets/icon.ico')
33+
coll = COLLECT(exe,
34+
a.binaries,
35+
a.zipfiles,
36+
a.datas,
37+
strip=False,
38+
upx=True,
39+
name='chainsign')

gui/about.ui

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AboutDialog</class>
4+
<widget class="QDialog" name="AboutDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>450</width>
10+
<height>280</height>
11+
</rect>
12+
</property>
13+
<property name="minimumSize">
14+
<size>
15+
<width>450</width>
16+
<height>280</height>
17+
</size>
18+
</property>
19+
<property name="windowTitle">
20+
<string>About...</string>
21+
</property>
22+
<property name="windowIcon">
23+
<iconset resource="../assets/assets.qrc">
24+
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
25+
</property>
26+
<layout class="QVBoxLayout" name="verticalLayout_2">
27+
<item>
28+
<layout class="QHBoxLayout" name="horizontalLayout">
29+
<item>
30+
<widget class="QLabel" name="label">
31+
<property name="sizePolicy">
32+
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
33+
<horstretch>0</horstretch>
34+
<verstretch>0</verstretch>
35+
</sizepolicy>
36+
</property>
37+
<property name="text">
38+
<string/>
39+
</property>
40+
<property name="pixmap">
41+
<pixmap resource="../assets/assets.qrc">:/banner.svg</pixmap>
42+
</property>
43+
<property name="scaledContents">
44+
<bool>false</bool>
45+
</property>
46+
<property name="alignment">
47+
<set>Qt::AlignCenter</set>
48+
</property>
49+
</widget>
50+
</item>
51+
<item>
52+
<widget class="QLabel" name="label_2">
53+
<property name="sizePolicy">
54+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
55+
<horstretch>0</horstretch>
56+
<verstretch>0</verstretch>
57+
</sizepolicy>
58+
</property>
59+
<property name="text">
60+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Simple blockchain-based timestamping solution.&lt;br/&gt;Copyright 2017 Quark sp. z o.o&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; vertical-align:sub;&quot;&gt;The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
61+
</property>
62+
<property name="alignment">
63+
<set>Qt::AlignCenter</set>
64+
</property>
65+
<property name="wordWrap">
66+
<bool>true</bool>
67+
</property>
68+
<property name="openExternalLinks">
69+
<bool>false</bool>
70+
</property>
71+
</widget>
72+
</item>
73+
</layout>
74+
</item>
75+
<item>
76+
<layout class="QHBoxLayout" name="horizontalLayout_2">
77+
<item>
78+
<widget class="QLabel" name="updaterLabel">
79+
<property name="sizePolicy">
80+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
81+
<horstretch>0</horstretch>
82+
<verstretch>0</verstretch>
83+
</sizepolicy>
84+
</property>
85+
<property name="text">
86+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Checking updates...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
87+
</property>
88+
<property name="textFormat">
89+
<enum>Qt::RichText</enum>
90+
</property>
91+
<property name="scaledContents">
92+
<bool>false</bool>
93+
</property>
94+
<property name="alignment">
95+
<set>Qt::AlignCenter</set>
96+
</property>
97+
<property name="openExternalLinks">
98+
<bool>true</bool>
99+
</property>
100+
</widget>
101+
</item>
102+
</layout>
103+
</item>
104+
<item>
105+
<widget class="QDialogButtonBox" name="buttonBox">
106+
<property name="orientation">
107+
<enum>Qt::Horizontal</enum>
108+
</property>
109+
<property name="standardButtons">
110+
<set>QDialogButtonBox::Ok</set>
111+
</property>
112+
<property name="centerButtons">
113+
<bool>true</bool>
114+
</property>
115+
</widget>
116+
</item>
117+
</layout>
118+
</widget>
119+
<resources>
120+
<include location="../assets/assets.qrc"/>
121+
</resources>
122+
<connections>
123+
<connection>
124+
<sender>buttonBox</sender>
125+
<signal>accepted()</signal>
126+
<receiver>AboutDialog</receiver>
127+
<slot>accept()</slot>
128+
<hints>
129+
<hint type="sourcelabel">
130+
<x>248</x>
131+
<y>254</y>
132+
</hint>
133+
<hint type="destinationlabel">
134+
<x>157</x>
135+
<y>274</y>
136+
</hint>
137+
</hints>
138+
</connection>
139+
<connection>
140+
<sender>buttonBox</sender>
141+
<signal>rejected()</signal>
142+
<receiver>AboutDialog</receiver>
143+
<slot>reject()</slot>
144+
<hints>
145+
<hint type="sourcelabel">
146+
<x>316</x>
147+
<y>260</y>
148+
</hint>
149+
<hint type="destinationlabel">
150+
<x>286</x>
151+
<y>274</y>
152+
</hint>
153+
</hints>
154+
</connection>
155+
</connections>
156+
</ui>

installer.iss

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AppVersion={#MyAppVersion}
1818
AppPublisher={#MyAppPublisher}
1919
DefaultDirName={pf}\{#MyAppName}
2020
DisableProgramGroupPage=yes
21-
OutputDir=build
21+
OutputDir=dist
2222
OutputBaseFilename=ChainSign_setup
2323
SetupIconFile=assets/icon.ico
2424
UninstallDisplayIcon={app}\chainsign.exe
@@ -36,9 +36,9 @@ Name: "installnamecoind"; Description: "Install Namecoin client"
3636
Name: "setupnamecoind"; Description: "Configure Namecoin client to allow RPC"
3737

3838
[Files]
39-
Source: "build\exe.win32-2.7\chainsign.exe"; DestDir: "{app}"; Flags: ignoreversion
40-
Source: "build\exe.win32-2.7\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
41-
Source: "build\{#NamecoinExeName}"; DestDir: "{app}"; Tasks: installnamecoind; Flags: ignoreversion
39+
Source: "dist\chainsign\chainsign.exe"; DestDir: "{app}"; Flags: ignoreversion
40+
Source: "dist\chainsign\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
41+
Source: "dist\{#NamecoinExeName}"; DestDir: "{app}"; Tasks: installnamecoind; Flags: ignoreversion
4242
Source: "namecoin.conf"; DestDir: "{userappdata}\Namecoin"; Tasks: setupnamecoind; Flags: uninsneveruninstall onlyifdoesntexist
4343

4444
[Icons]

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PySide>=1.2
22
python-bitcoinrpc==1.0
3+
requests==2.13.0

setup.py

-30
This file was deleted.

0 commit comments

Comments
 (0)