From 80284f6f8d7f6e69b9e80fa6cc4c63380a1682d9 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 31 Mar 2014 10:08:07 +0200 Subject: [PATCH 01/13] =?UTF-8?q?Added=20'Neue=20evangelistische=20=C3=9Cb?= =?UTF-8?q?ersetzung'=20to=20the=20list=20of=20Online=20bible=20translatio?= =?UTF-8?q?ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bibles/resources/bibles_resources.sqlite | Bin 104448 -> 104448 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index c0fa931d1bb88b6e6c0224feff9cbc5aa61c7312..8f1777124032ee11b547fd6e1897f7e9b8b717a9 100644 GIT binary patch delta 140 zcmZqJz}B#VZGtr8lZi6UtWOwppD}GrvEyc2pv27V$vF9Sk=*8E+;$J-cp0@sn0GQy zV$NjtVEV;$nrRkOJQF+PE5_Z7HH=yt8#x#a{Tmh785(&d85#W;QW;8tSOJL37!n!s n7}9~P9EMDWVulhhnaq&EkUIIpOKG-LhC2)z%$sZ8wyXjGKRhSf delta 78 zcmV-U0I~moum*sz29O&8*oM;vcbOJ_`n)A_D_S0h8-;9<#;^KHwY-0eln# kxdV~|X#+?C`U1-WngU+}2Lb8 Date: Mon, 31 Mar 2014 18:08:42 +0200 Subject: [PATCH 02/13] added jenkins script --- tests/utils/jenkins-script.py | 188 ++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 tests/utils/jenkins-script.py diff --git a/tests/utils/jenkins-script.py b/tests/utils/jenkins-script.py new file mode 100644 index 000000000..3a6f34a13 --- /dev/null +++ b/tests/utils/jenkins-script.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +This script helps to trigger builds of branches. To use it you have to install the jenkins-webapi package: + + pip3 isntall jenkins-webapi + +You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login: + + alias ci="python PATH-TO-THIS-SCRIPT TOKEN" + +If you do not know/have the token, then please ask for it (e. g. IRC). +""" + +from optparse import OptionParser +from subprocess import Popen, PIPE +import sys +import time + +from jenkins import Jenkins +from PyQt4 import QtCore, QtGui + + +JENKINS_URL = 'http://ci.openlp.org/' + + +class OpenLPJobs(object): + """ + This class holds any jobs we have on jenkins and we actually need in this script. + """ + Branch_Pull = 'Branch-01-Pull' + Branch_Functional = 'Branch-02-Functional-Tests' + Branch_Interface = 'Branch-03-Interface-Tests' + Branch_Windows = 'Branch-04-Windows_Tests' + + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows] + + +class JenkinsTrigger(object): + def __init__(self, token): + """ + Create the JenkinsTrigger instance. + + :param token: The token we need to trigger the build. If you do not have this token, ask in IRC. + """ + self.token = token + self.repo_name = get_repo_name() + self.jenkins_instance = Jenkins(JENKINS_URL) + + def trigger_build(self): + """ + Ask our jenkins server to build the "Branch-01-Pull" job. + """ + self.jenkins_instance.job(OpenLPJobs.Branch_Pull).build({'BRANCH_NAME': self.repo_name}, token=self.token) + + def print_output(self): + """ + Print the status information of the build tirggered. + """ + print("Add this to your merge proposal:") + print("--------------------------------") + for job in OpenLPJobs.Jobs: + self.__print_build_info(job) + + def open_browser(self): + """ + Opens the browser. + """ + url = self.jenkins_instance.job(OpenLPJobs.Branch_Pull).info['url'] + # Open the url + Popen(('xdg-open', url), stderr=PIPE) + + def __print_build_info(self, job_name): + """ + This helper method prints the job information of the given ``job_name`` + + :param job_name: The name of the job we want the information from. For example *Branch-01-Pull*. Use the class + variables from the :class:`OpenLPJobs` class. + """ + job = self.jenkins_instance.job(job_name) + while job.info['inQueue']: + # Give other processes the possibility to take over. Like Thread.yield(). + time.sleep(0) + build = job.last_build + build.wait() + result_string = build.info['result'] + url = build.info['url'] + print('[%s] %s' % (result_string, url)) + # On failure open the browser. + if result_string == "FAILURE": + url += 'console' + Popen(('xdg-open', url), stderr=PIPE) + + +def get_repo_name(): + """ + This returns the name of branch of the wokring directory. For example it returns *lp:~googol/openlp/render*. + """ + # Run the bzr command. + bzr = Popen(('bzr', 'info'), stdout=PIPE, stderr=PIPE) + raw_output, error = bzr.communicate() + # Detect any errors + if error: + print('This is not a branch.') + return + # Clean the output. + raw_output = raw_output.decode() + output_list = list(map(str.strip, raw_output.split('\n'))) + # Determine the branch's name + repo_name = '' + for line in output_list: + # Check if it is remote branch. + if 'push branch' in line: + repo_name = line.replace('push branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') + break + # Check if trunk. Note, bzr info can return both 'push branch' as well as 'checkout of branch'. The later can + # occur before the first. So we do not want to break here to make sure we find any orrucances of + elif 'checkout of branch' in line: + repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/+branch/', 'lp:') + repo_name = repo_name.strip('/') + + # Did we find the branch name? + if not repo_name: + for line in output_list: + # Check if the branch was pushed. + if 'Shared repository with trees (format: 2a)' in line: + print('Not a branch. cd to a branch.') + return + print('Not a branch. Have you pushed it to launchpad?') + return + return repo_name + + +def main(): + usage = 'Usage: python %prog TOKEN [options]' + + parser = OptionParser(usage=usage) + parser.add_option('-d', '--disable-output', dest='enable_output', action="store_false", default=True, + help='Print output for the merge request.') + parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, + help='Opens the jenkins page in your browser.') + #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, + # help='Opens the jenkins page in your browser in case a test fails.') + options, args = parser.parse_args(sys.argv) + + if len(args) == 2: + if not get_repo_name(): + return + token = args[-1] + jenkins_trigger = JenkinsTrigger(token) + jenkins_trigger.trigger_build() + # Open the browser before printing the output. + if options.open_browser: + jenkins_trigger.open_browser() + if options.enable_output: + jenkins_trigger.print_output() + else: + raise Exception() + +if __name__ == '__main__': + main() From 5f0b40fe3017a41222f85056d6be65d8c2c07b5a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:27:26 +0200 Subject: [PATCH 03/13] Moved script --- tests/utils/jenkins-script.py => scripts/jenkins_script.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/utils/jenkins-script.py => scripts/jenkins_script.py (100%) diff --git a/tests/utils/jenkins-script.py b/scripts/jenkins_script.py similarity index 100% rename from tests/utils/jenkins-script.py rename to scripts/jenkins_script.py From 4bed39869a7846720cf60d564f44585e8d9ca6e0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:30:07 +0200 Subject: [PATCH 04/13] updated check_dependencies.py sciprt --- scripts/check_dependencies.py | 1 + scripts/jenkins_script.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index adb6a47f2..bab1c6419 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -94,6 +94,7 @@ OPTIONAL_MODULES = [ ('psycopg2', '(PostgreSQL support)', True), ('nose', '(testing framework)', True), ('mock', '(testing module)', sys.version_info[1] < 3), + ('jenkins', '(access jenkins api - package name: enkins-webapi)', True), ] w = sys.stdout.write diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 3a6f34a13..eefe74150 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -45,7 +45,6 @@ import sys import time from jenkins import Jenkins -from PyQt4 import QtCore, QtGui JENKINS_URL = 'http://ci.openlp.org/' From 716a79bcc576547512982d7dc24cd5e5dc9fd894 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:37:43 +0200 Subject: [PATCH 05/13] cleaned doc --- scripts/jenkins_script.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index eefe74150..d275463c3 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -40,6 +40,7 @@ If you do not know/have the token, then please ask for it (e. g. IRC). """ from optparse import OptionParser +from requests.exceptions import HTTPError from subprocess import Popen, PIPE import sys import time @@ -58,8 +59,9 @@ class OpenLPJobs(object): Branch_Functional = 'Branch-02-Functional-Tests' Branch_Interface = 'Branch-03-Interface-Tests' Branch_Windows = 'Branch-04-Windows_Tests' + Branch_PEP = 'Branch-05-Code-Analysis' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows, Branch_PEP] class JenkinsTrigger(object): @@ -113,9 +115,9 @@ class JenkinsTrigger(object): url = build.info['url'] print('[%s] %s' % (result_string, url)) # On failure open the browser. - if result_string == "FAILURE": - url += 'console' - Popen(('xdg-open', url), stderr=PIPE) + #if result_string == "FAILURE": + # url += 'console' + # Popen(('xdg-open', url), stderr=PIPE) def get_repo_name(): @@ -162,7 +164,7 @@ def main(): parser = OptionParser(usage=usage) parser.add_option('-d', '--disable-output', dest='enable_output', action="store_false", default=True, - help='Print output for the merge request.') + help='Disable output.') parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, help='Opens the jenkins page in your browser.') #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, @@ -174,14 +176,18 @@ def main(): return token = args[-1] jenkins_trigger = JenkinsTrigger(token) - jenkins_trigger.trigger_build() + try: + jenkins_trigger.trigger_build() + except HTTPError as e: + print("Wrong token.") + return # Open the browser before printing the output. if options.open_browser: jenkins_trigger.open_browser() if options.enable_output: jenkins_trigger.print_output() else: - raise Exception() + parser.print_help() if __name__ == '__main__': main() From 6204454bfbe70fffbe51eb531ebc60c48c09554c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:40:36 +0200 Subject: [PATCH 06/13] updated doc --- scripts/jenkins_script.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index d275463c3..1a655799b 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -32,11 +32,11 @@ This script helps to trigger builds of branches. To use it you have to install t pip3 isntall jenkins-webapi -You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login: +You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): - alias ci="python PATH-TO-THIS-SCRIPT TOKEN" + alias ci="python3 ~/Projects/OpenLP/trunk/script/jenkins_script.py TOKEN" -If you do not know/have the token, then please ask for it (e. g. IRC). +You can look up the token in the Branch-01-Pull job configuration or ask in IRC. """ from optparse import OptionParser From c451a8eafa71d7c3ed67b393551f7e20159188f8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:01:09 +0200 Subject: [PATCH 07/13] added test --- openlp/core/common/registry.py | 1 + scripts/jenkins_script.py | 2 +- .../functional/openlp_core_common/test_registry.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 014a534f7..33eb64880 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -151,6 +151,7 @@ class Registry(object): if result: results.append(result) except TypeError: + print("sdf") # Who has called me can help in debugging trace_error_handler(log) log.exception('Exception for function %s', function) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 1a655799b..0e29271a2 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -30,7 +30,7 @@ """ This script helps to trigger builds of branches. To use it you have to install the jenkins-webapi package: - pip3 isntall jenkins-webapi + pip3 install jenkins-webapi You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): diff --git a/tests/functional/openlp_core_common/test_registry.py b/tests/functional/openlp_core_common/test_registry.py index a57d7ea85..e27b69d10 100644 --- a/tests/functional/openlp_core_common/test_registry.py +++ b/tests/functional/openlp_core_common/test_registry.py @@ -100,6 +100,20 @@ class TestRegistry(TestCase): # THEN: I expect then function to have been called and a return given self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches') + def remove_function_test(self): + """ + Test the remove_function() method + """ + # GIVEN: An existing registry register a function + Registry.create() + Registry().register_function('test1', self.dummy_function_1) + + # WHEN: Remove the function. + Registry().remove_function('test1', self.dummy_function_1) + + # THEN: The method should not be available. + assert not Registry().functions_list['test1'], 'The function should not be in the dict anymore.' + def dummy_function_1(self): return "function_1" From 52279248462f191b9aeb0f103c39c0803db2b25c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:29:14 +0200 Subject: [PATCH 08/13] fix: removed stray print --- openlp/core/common/registry.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 33eb64880..014a534f7 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -151,7 +151,6 @@ class Registry(object): if result: results.append(result) except TypeError: - print("sdf") # Who has called me can help in debugging trace_error_handler(log) log.exception('Exception for function %s', function) From 20e7517b033c82f8b9ebcee157fd86e9cf969737 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:30:14 +0200 Subject: [PATCH 09/13] doc: shortened path --- scripts/jenkins_script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 0e29271a2..cd75bbc6e 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -34,7 +34,7 @@ This script helps to trigger builds of branches. To use it you have to install t You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): - alias ci="python3 ~/Projects/OpenLP/trunk/script/jenkins_script.py TOKEN" + alias ci="python3 ./scripts/jenkins_script.py TOKEN" You can look up the token in the Branch-01-Pull job configuration or ask in IRC. """ From 3db984a846290345b589b294a18d9dfc13cee05e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:32:49 +0200 Subject: [PATCH 10/13] clean up: simplify code --- openlp/core/common/registry.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 014a534f7..218325823 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -62,11 +62,9 @@ class Registry(object): registry = cls() registry.service_list = {} registry.functions_list = {} - registry.running_under_test = False - registry.initialising = True # Allow the tests to remove Registry entries but not the live system - if 'nose' in sys.argv[0]: - registry.running_under_test = True + registry.running_under_test = 'nose' in sys.argv[0] + registry.initialising = True return registry def get(self, key): @@ -128,7 +126,7 @@ class Registry(object): :param event: The function description.. :param function: The function to be called when the event happens. """ - if self.running_under_test is False: + if not self.running_under_test: trace_error_handler(log) log.error('Invalid Method call for key %s' % event) raise KeyError('Invalid Method call for key %s' % event) From 6235fa19a912e57e4a64c0b3841670bc91af77ca Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:52:49 +0200 Subject: [PATCH 11/13] long line --- scripts/jenkins_script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index cd75bbc6e..75d4f6376 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -167,8 +167,8 @@ def main(): help='Disable output.') parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, help='Opens the jenkins page in your browser.') - #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, - # help='Opens the jenkins page in your browser in case a test fails.') + #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", + # default=False, help='Opens the jenkins page in your browser in case a test fails.') options, args = parser.parse_args(sys.argv) if len(args) == 2: From ab4cbfd85ee86295a3bf65508b27a98735fdab49 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:57:15 +0200 Subject: [PATCH 12/13] fix: spelling mistake --- scripts/check_dependencies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index bab1c6419..5298139be 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -94,7 +94,7 @@ OPTIONAL_MODULES = [ ('psycopg2', '(PostgreSQL support)', True), ('nose', '(testing framework)', True), ('mock', '(testing module)', sys.version_info[1] < 3), - ('jenkins', '(access jenkins api - package name: enkins-webapi)', True), + ('jenkins', '(access jenkins api - package name: jenkins-webapi)', True), ] w = sys.stdout.write From 9d9a8145f64fc59ac98c3dc8637f4c04cb5ed4ce Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 20:10:14 +0200 Subject: [PATCH 13/13] fixed dectection --- scripts/jenkins_script.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 75d4f6376..386ab69ef 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -141,10 +141,9 @@ def get_repo_name(): if 'push branch' in line: repo_name = line.replace('push branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') break - # Check if trunk. Note, bzr info can return both 'push branch' as well as 'checkout of branch'. The later can - # occur before the first. So we do not want to break here to make sure we find any orrucances of elif 'checkout of branch' in line: - repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/+branch/', 'lp:') + repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') + break repo_name = repo_name.strip('/') # Did we find the branch name?