openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01615
[Merge] lp:~raoul-snyman/openlp/version-check into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/version-check into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Make the version checking more intelligent.
--
https://code.launchpad.net/~raoul-snyman/openlp/version-check/+merge/25980
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/version-check into lp:openlp.
=== modified file 'OpenLP.spec'
--- OpenLP.spec 2010-05-23 15:49:34 +0000
+++ OpenLP.spec 2010-05-25 17:08:28 +0000
@@ -1,6 +1,6 @@
# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'openlp.pyw'],
- pathex=['C:\\Documents and Settings\\raoul\\My Documents\\My Projects\\openlp\\trunk'])
+ pathex=[os.path.abspath('.')])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2010-05-17 18:39:28 +0000
+++ openlp/core/ui/mainwindow.py 2010-05-25 17:08:28 +0000
@@ -25,6 +25,7 @@
import logging
import time
+import re
from PyQt4 import QtCore, QtGui
@@ -60,6 +61,7 @@
QtCore.QThread.__init__(self, parent)
self.parent = parent
self.app_version = app_version
+ self.version_splitter = re.compile(r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))')
def run(self):
"""
@@ -68,8 +70,29 @@
time.sleep(1)
Receiver.send_message(u'maindisplay_blank_check')
version = check_latest_version(self.app_version)
- #new version has arrived
- if version != self.app_version[u'full']:
+ remote_version = {}
+ local_version = {}
+ match = self.version_splitter.match(version)
+ if match:
+ remote_version[u'major'] = int(match.group(1))
+ remote_version[u'minor'] = int(match.group(2))
+ remote_version[u'release'] = int(match.group(3))
+ if len(match.groups()) > 3:
+ remote_version[u'revision'] = int(match.group(4))
+ match = self.version_splitter.match(self.app_version[u'full'])
+ if match:
+ local_version[u'major'] = int(match.group(1))
+ local_version[u'minor'] = int(match.group(2))
+ local_version[u'release'] = int(match.group(3))
+ if len(match.groups()) > 3:
+ local_version[u'revision'] = int(match.group(4))
+ if remote_version[u'major'] > local_version[u'major'] or \
+ remote_version[u'minor'] > local_version[u'minor'] or \
+ remote_version[u'release'] > local_version[u'release']:
+ Receiver.send_message(u'openlp_version_check', u'%s' % version)
+ elif remote_version.get(u'revision') and \
+ local_version.get(u'revision') and \
+ remote_version[u'revision'] > local_version[u'revision']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
class Ui_MainWindow(object):
=== added file 'resources/pyinstaller/windows-builder.py'
--- resources/pyinstaller/windows-builder.py 1970-01-01 00:00:00 +0000
+++ resources/pyinstaller/windows-builder.py 2010-05-25 17:08:28 +0000
@@ -0,0 +1,130 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
+# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
+# Thompson, Jon Tibble, Carsten Tinggaard #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+
+"""
+Windows Build Script
+--------------------
+
+This script is used to build the Windows binary and the accompanying installer.
+
+For this script to work out of the box, it depends on being inside the
+"resources/pyinstaller" directory in the OpenLP source tree, it depends on
+OpenLP having it's own project directory which all the branches live in, and it
+depends on PyInstaller being
+"""
+
+import os
+from shutil import copy
+from subprocess import Popen, PIPE
+
+script_path = os.path.split(os.path.abspath(__file__))[0]
+pyinstaller_path = os.path.abspath(os.path.join(script_path, u'..', u'..', u'..', u'..', u'pyinstaller'))
+innosetup_path = os.path.join(os.getenv(u'PROGRAMFILES'), 'Inno Setup 5')
+iss_path = os.path.abspath(os.path.join(script_path, u'..', u'innosetup'))
+branch_path = os.path.abspath(os.path.join(script_path, u'..', u'..'))
+source_path = os.path.join(branch_path, u'openlp')
+dist_path = os.path.join(branch_path, u'dist', u'OpenLP')
+
+
+def run_pyinstaller():
+ print u'Running PyInstaller...'
+ os.chdir(branch_path)
+ pyinstaller = Popen((u'python', os.path.join(pyinstaller_path, u'Build.py'),
+ u'OpenLP.spec'))
+ code = pyinstaller.wait()
+ if code != 0:
+ raise Exception(u'Error running PyInstaller Build.py')
+
+def write_version_file():
+ print u'Writing version file...'
+ os.chdir(branch_path)
+ bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
+ output, error = bzr.communicate()
+ code = bzr.wait()
+ if code != 0:
+ raise Exception(u'Error running bzr tags')
+ lines = output.splitlines()
+ if len(lines) == 0:
+ tag = u'0.0.0'
+ revision = u'0'
+ else:
+ tag, revision = lines[-1].split()
+ bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE)
+ output, error = bzr.communicate()
+ code = bzr.wait()
+ if code != 0:
+ raise Exception(u'Error running bzr log')
+ latest = output.split(u':')[0]
+ versionstring = latest == revision and tag or u'%s-bzr%s' % (tag, latest)
+ f = open(os.path.join(dist_path, u'.version'), u'w')
+ f.write(versionstring)
+ f.close()
+
+def copy_plugins():
+ print u'Copying plugins...'
+ source = os.path.join(source_path, u'plugins')
+ dest = os.path.join(dist_path, u'plugins')
+ for root, dirs, files in os.walk(source):
+ for filename in files:
+ if not filename.endswith(u'.pyc'):
+ dest_path = os.path.join(dest, root[len(source)+1:])
+ if not os.path.exists(dest_path):
+ os.makedirs(dest_path)
+ copy(os.path.join(root, filename),
+ os.path.join(dest_path, filename))
+
+def copy_windows_files():
+ print u'Copying extra files for Windows...'
+ copy(os.path.join(iss_path, u'OpenLP.ico'), os.path.join(dist_path, u'OpenLP.ico'))
+ copy(os.path.join(iss_path, u'LICENSE.txt'), os.path.join(dist_path, u'LICENSE.txt'))
+
+def run_innosetup():
+ print u'Running Inno Setup...'
+ os.chdir(iss_path)
+ run_command = u'"%s" "%s"' % (os.path.join(innosetup_path, u'ISCC.exe'),
+ os.path.join(iss_path, u'OpenLP-2.0.iss'))
+ print run_command
+ innosetup = Popen(run_command)
+ code = innosetup.wait()
+ if code != 0:
+ raise Exception(u'Error running Inno Setup')
+
+def main():
+ print "Script path:", script_path
+ print "PyInstaller path:", pyinstaller_path
+ print "Inno Setup path:", innosetup_path
+ print "ISS file path:", iss_path
+ print "Branch path:", branch_path
+ print "Source path:", source_path
+ print "\"dist\" path:", dist_path
+ run_pyinstaller()
+ write_version_file()
+ copy_plugins()
+ copy_windows_files()
+ run_innosetup()
+ print "Done."
+
+if __name__ == u'__main__':
+ main()