From ffb64f4a86efbfebf194e2f8648a1579aa8544d0 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 2 Mar 2015 20:17:39 +0200 Subject: [PATCH 1/3] Fix CI script. Requires jenkins-webapi>=0.4.1 --- scripts/jenkins_script.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 10d5efed6..c3727e3eb 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -42,7 +42,7 @@ import time from jenkins import Jenkins -JENKINS_URL = 'http://ci.openlp.org/' +JENKINS_URL = 'https://ci.openlp.io/' REPO_REGEX = r'(.*/+)(~.*)' # Allows us to black list token. So when we change the token, we can display a proper message to the user. OLD_TOKENS = [] @@ -75,15 +75,19 @@ class Colour(object): class JenkinsTrigger(object): + """ + A class to trigger builds on Jenkins and print the results. + + :param token: The token we need to trigger the build. If you do not have this token, ask in IRC. + """ + 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) + self.jenkins_instance = Jenkins(JENKINS_URL, verify=False) def trigger_build(self): """ From 38ff1b56b777492dcde4a3556a50d660b92c14e8 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 2 Mar 2015 21:18:14 +0200 Subject: [PATCH 2/3] Silencio! --- scripts/jenkins_script.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index c3727e3eb..98c908fc9 100755 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -32,13 +32,14 @@ You probably want to create an alias. Add this to your ~/.bashrc file and then l You can look up the token in the Branch-01-Pull job configuration or ask in IRC. """ -from optparse import OptionParser import re -from requests.exceptions import HTTPError -from subprocess import Popen, PIPE import sys import time +from optparse import OptionParser +from subprocess import Popen, PIPE +import warnings +from requests.exceptions import HTTPError from jenkins import Jenkins @@ -47,6 +48,9 @@ REPO_REGEX = r'(.*/+)(~.*)' # Allows us to black list token. So when we change the token, we can display a proper message to the user. OLD_TOKENS = [] +# Disable the InsecureRequestWarning we get from urllib3, because we're not verifying our own self-signed certificate +warnings.simplefilter('ignore') + class OpenLPJobs(object): """ @@ -98,8 +102,8 @@ class JenkinsTrigger(object): # We just want the name (not the email). name = ' '.join(raw_output.decode().split()[:-1]) cause = 'Build triggered by %s (%s)' % (name, self.repo_name) - self.jenkins_instance.job(OpenLPJobs.Branch_Pull).build( - {'BRANCH_NAME': self.repo_name, 'cause': cause}, token=self.token) + self.jenkins_instance.job(OpenLPJobs.Branch_Pull).build({'BRANCH_NAME': self.repo_name, 'cause': cause}, + token=self.token) def print_output(self): """ From 88ceae517adc758acdbd759d13060e8cd5364080 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 2 Mar 2015 21:21:41 +0200 Subject: [PATCH 3/3] Fix code analysis --- .../openlp_plugins/songs/test_editsongform.py | 21 ++++++++++++++ .../songs/test_editverseform.py | 29 ++++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_editsongform.py b/tests/functional/openlp_plugins/songs/test_editsongform.py index 48cd127bf..d386a7fd3 100644 --- a/tests/functional/openlp_plugins/songs/test_editsongform.py +++ b/tests/functional/openlp_plugins/songs/test_editsongform.py @@ -1,3 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2015 OpenLP Developers # +# --------------------------------------------------------------------------- # +# 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 module contains tests for the lib submodule of the Songs plugin. """ diff --git a/tests/functional/openlp_plugins/songs/test_editverseform.py b/tests/functional/openlp_plugins/songs/test_editverseform.py index 0ee75e4cb..4c89b4f89 100644 --- a/tests/functional/openlp_plugins/songs/test_editverseform.py +++ b/tests/functional/openlp_plugins/songs/test_editverseform.py @@ -1,3 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2015 OpenLP Developers # +# --------------------------------------------------------------------------- # +# 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 module contains tests for the editverseform of the Songs plugin. """ @@ -38,12 +59,12 @@ class TestEditVerseForm(TestCase, TestMixin): """ # GIVEN some input values self.edit_verse_form.has_single_verse = True - self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value = 0) - self.edit_verse_form.verse_text_edit.toPlainText = MagicMock(return_value = 'Text') + self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=0) + self.edit_verse_form.verse_text_edit.toPlainText = MagicMock(return_value='Text') self.edit_verse_form.verse_number_box.setValue(3) - + # WHEN the method is called self.edit_verse_form.update_suggested_verse_number() - + # THEN the verse number must not be changed self.assertEqual(3, self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3')