From baebfbb585d0bd557bd37a2f52bbdd3e243ceba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 23 Nov 2012 11:31:30 +0100 Subject: [PATCH 1/8] Fix get_version, insert and use get_git_commit_id. --- openslides/__init__.py | 41 +++++++++++++++++++++----------------- openslides/config/views.py | 12 ++++++++--- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/openslides/__init__.py b/openslides/__init__.py index a9fc81a12..80ed9bb5e 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -5,7 +5,8 @@ :license: GNU GPL, see LICENSE for more details. """ -VERSION = (1, 3, 0, 'beta', 2) +VERSION = (1, 3, 0, 'final', 0) # During development it is the next release +RELEASE = False def get_version(version=None): @@ -16,29 +17,33 @@ def get_version(version=None): if version is None: version = VERSION assert len(version) == 5 - assert version[3] in ('dev', 'alpha', 'beta', 'rc', 'final') - + assert version[3] in ('alpha', 'beta', 'rc', 'final') # Now build the two parts of the version number: # main = X.Y[.Z] # sub = {a|b|c}N for alpha, beta and rc releases - # git's commit id is added - + # Add '-dev', if it is not a release commit main_parts = 2 if version[2] == 0 else 3 main = '.'.join(str(x) for x in version[:main_parts]) - if version[3] != 'final': - if version[3] == 'dev': - try: - git_head_path = '.git/' + open('.git/HEAD', 'r').read()[5:].rstrip() - except IOError: - git_commit_id = 'unknown' - else: - import os - git_commit_id = open(os.path.abspath(git_head_path), 'r').read().rstrip() - sub = '-%s%s' % (version[3], git_commit_id) - else: - sub = '-' + version[3] + str(version[4]) + mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'} + sub = mapping[version[3]] + str(version[4]) else: sub = '' - + if not RELEASE: + sub += '-dev' return main + sub + + +def get_git_commit_id(): + """ + Catches the commit id of the git head. + """ + try: + git_head = open('.git/HEAD', 'r').read().rstrip() + if True: #starts with 'ref: ' + git_commit_id = open('.git/%s' % git_head[5:], 'r').read().rstrip() + else: + git_commit_id = git_head + except IOError: + git_commit_id = 'unknown' + return str(git_commit_id) diff --git a/openslides/config/views.py b/openslides/config/views.py index e93e08f18..a84567c43 100644 --- a/openslides/config/views.py +++ b/openslides/config/views.py @@ -17,7 +17,7 @@ from django.core.urlresolvers import reverse from django.utils.importlib import import_module from django.utils.translation import ugettext as _ -from openslides import get_version +from openslides import get_version, get_git_commit_id, RELEASE from openslides.utils.template import Tab from openslides.utils.views import FormView, TemplateView @@ -94,7 +94,14 @@ class VersionConfig(TemplateView): def get_context_data(self, **kwargs): context = super(VersionConfig, self).get_context_data(**kwargs) - context['versions'] = [('OpenSlides', get_version())] + + # OpenSlides version. During development the git commit id is added. + openslides_version_string = get_version() + if not RELEASE: + openslides_version_string += ' Commit: %s' % get_git_commit_id() + context['versions'] = [('OpenSlides', openslides_version_string)] + + # Version of plugins. for plugin in settings.INSTALLED_PLUGINS: try: mod = import_module(plugin) @@ -105,7 +112,6 @@ class VersionConfig(TemplateView): plugin_name = mod.NAME except AttributeError: plugin_name = mod.__name__.split('.')[0] - context['versions'].append((plugin_name, plugin_version)) return context From 4c9729159835bb796a30ff39042c5bd8c69ae6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 23 Nov 2012 11:33:34 +0100 Subject: [PATCH 2/8] Remove non-used revision template var. --- openslides/global_settings.py | 1 - openslides/utils/utils.py | 6 ------ 2 files changed, 7 deletions(-) diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 0186a3219..24d40aefa 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -132,7 +132,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.request', 'django.core.context_processors.i18n', 'django.core.context_processors.static', - 'openslides.utils.utils.revision', 'openslides.utils.auth.anonymous_context_additions', ) diff --git a/openslides/utils/utils.py b/openslides/utils/utils.py index 41aaf7544..d2ed32e5f 100644 --- a/openslides/utils/utils.py +++ b/openslides/utils/utils.py @@ -28,12 +28,6 @@ from django.utils.translation import ugettext as _, ugettext_lazy from openslides.utils.signals import template_manipulation -from openslides import get_version - - -def revision(request): - return {'openslides_version': get_version()} - def gen_confirm_form(request, message, url): """ From d53017eea8cad572b470d50433eb3115040c68e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 28 Nov 2012 18:02:33 +0100 Subject: [PATCH 3/8] Get git commit id also in detached head mode. --- openslides/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openslides/__init__.py b/openslides/__init__.py index 80ed9bb5e..b4ae8af8c 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -40,7 +40,7 @@ def get_git_commit_id(): """ try: git_head = open('.git/HEAD', 'r').read().rstrip() - if True: #starts with 'ref: ' + if git_head[:5] == 'ref: ': git_commit_id = open('.git/%s' % git_head[5:], 'r').read().rstrip() else: git_commit_id = git_head From 638c729dce1a37555b74b61b56ff64eb66dac438 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 28 Nov 2012 19:20:43 +0100 Subject: [PATCH 4/8] fixed manage.py for windows --- manage.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manage.py b/manage.py index 5ddfd35aa..af82b6f37 100644 --- a/manage.py +++ b/manage.py @@ -8,9 +8,10 @@ """ import os, sys +from django.core.management import execute_from_command_line +from openslides.main import get_user_config_path, setup_django_environment if __name__ == "__main__": - sys.path.append(os.path.join(os.path.expanduser('~'), '.config', 'openslides')) - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - from django.core.management import execute_from_command_line + setup_django_environment( + get_user_config_path('openslides', 'settings.py')) execute_from_command_line(sys.argv) From b9ab6502c1a74a252c3e82fb8129d9f7d5fe5a0b Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Thu, 29 Nov 2012 16:39:51 +0100 Subject: [PATCH 5/8] Updated the INSTALL.txt for windows with pypi --- INSTALL.txt | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/INSTALL.txt b/INSTALL.txt index 8a4cdad95..f8bbc6f3d 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -129,24 +129,20 @@ II. Installation on GNU/Linux and MacOSX using the sources virtual environment (see 4.) before starting the server (see 6.). -III. Installation on Windows (32/64bit) ---------------------------------------- +III. Installation on Windows (32bit) using the Python Package Index (PyPI) +----------------------------------------------------------------------------- -NOTE: There is a portable version of OpenSlides for Windows which does not -required any install steps! If there is a reason that you can not use the +NOTE: There is a portable version of OpenSlides for Windows which does not +required any install steps! If there is a reason that you can not use the portable version you should run the following install steps. 1. Install requirements: - OpenSlides requires following programs, which should be + The OpenSlides install requires following programs, which should be installed first: + Python Programming Language 2 (>= 2.5), + Setuptools - + ReportLab Toolkit - + Python Imaging Library (PIL) - + Django - + django-mptt a) Download and run 32bit MSI installer from http://www.python.org/: @@ -163,33 +159,18 @@ portable version you should run the following install steps. http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe - d) Install ReportLab Toolkit, Python Imaging Library (PIL), Django - and django-mptt: + + 2. Install OpenSlides: Open command line (cmd) and run: - easy_install django django-mptt reportlab pil - - If you use a 64bit version of Python, you have to install reportlab - and PIL manually - without using easy_install. - - 2. Get OpenSlides: - - a) Download latest OpenSlides release from http://openslides.org. - - OR - - b) Clone development version from OpenSlides' github repository - https://github.com/OpenSlides/OpenSlides. This requires Git, - see http://git-scm.com/. - - Open command line (cmd) and run: - - git clone git://github.com/OpenSlides/OpenSlides.git + easy_install openslides 3. Start OpenSlides server and open URL in your default browser: - python start.py + Open command line (cmd) and run: + + openslides If you run this script the first time a new database and the admin account are created. Please change the password after @@ -198,4 +179,4 @@ portable version you should run the following install steps. Username: admin Password: admin - Use 'python start.py --help' to show all start options. + Use 'openslides --help' to show all start options. From 4410e454c8442718cce5a7f34a756d7a0c223f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 1 Dec 2012 13:39:29 +0100 Subject: [PATCH 6/8] Update test for version string. --- openslides/__init__.py | 6 ++++-- tests/test_init.py | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/openslides/__init__.py b/openslides/__init__.py index b4ae8af8c..fd88160f2 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -9,13 +9,15 @@ VERSION = (1, 3, 0, 'final', 0) # During development it is the next release RELEASE = False -def get_version(version=None): +def get_version(version=None, release=None): """ Derives a PEP386-compliant version number from VERSION. Adds id of the current git commit. """ if version is None: version = VERSION + if release is None: + release = RELEASE assert len(version) == 5 assert version[3] in ('alpha', 'beta', 'rc', 'final') # Now build the two parts of the version number: @@ -29,7 +31,7 @@ def get_version(version=None): sub = mapping[version[3]] + str(version[4]) else: sub = '' - if not RELEASE: + if not release: sub += '-dev' return main + sub diff --git a/tests/test_init.py b/tests/test_init.py index 6155716f1..411860d79 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -9,15 +9,25 @@ from django.test import TestCase -from openslides import get_version +from openslides import get_version, get_git_commit_id class InitTest(TestCase): def test_get_version(self): - self.assertEqual(get_version((1, 3, 0, 'beta', 2)), '1.3-beta2') - self.assertEqual(get_version((1, 0, 0, 'final', 0)), '1.0') - self.assertEqual(get_version((2, 5, 3, 'alpha', 0)), '2.5.3-alpha0') - git_version = get_version((2, 5, 0, 'dev', 0)) - if 'unknown' in git_version: - self.assertEqual(len(git_version), 14) - else: - self.assertEqual(len(git_version), 47) + """ + Tests the method during development process and for releases. + """ + self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=False), '1.3b2-dev') + self.assertEqual(get_version(version=(1, 0, 0, 'final', 0), release=False), '1.0-dev') + self.assertEqual(get_version(version=(2, 5, 3, 'alpha', 0), release=False), '2.5.3a0-dev') + self.assertEqual(get_version(version=(1, 3, 0, 'beta', 2), release=True), '1.3b2') + self.assertEqual(get_version(version=(1, 0, 0, 'final', 0), release=True), '1.0') + self.assertEqual(get_version(version=(2, 5, 3, 'alpha', 0), release=True), '2.5.3a0') + self.assertEqual(get_version(version=(2, 5, 3, 'final', 0), release=True), '2.5.3') + + def test_get_git_commit_id(self): + """ + Tests the lenght of the git commit id. + """ + git_commit_id = get_git_commit_id() + if not git_commit_id == 'unknown': + self.assertEqual(len(git_commit_id), 40) From c9956f6380ea6ae34072dc19a0c550ef8979761c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 1 Dec 2012 13:51:00 +0100 Subject: [PATCH 7/8] Clean up INSTALL --- INSTALL.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/INSTALL.txt b/INSTALL.txt index f8bbc6f3d..076e088c0 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -6,7 +6,7 @@ Content I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI) II. Installation on GNU/Linux and MacOSX using the sources -III. Installation on Windows (32/64bit) +III. Installation on Windows (32bit) using the Python Package Index (PyPI) If you need help ask on OpenSlides users mailing list. See http://openslides.org for more information. @@ -17,14 +17,15 @@ I. Installation on GNU/Linux and MacOSX using the Python Package Index (PyPI) 1. Check requirements: - Make sure that you have installed Python (>= 2.5) on your system. + Make sure that you have installed Python Programming Language 2 + (>= 2.5) on your system. - 2. Set up virtual environment with virtualenv (optional): + 2. Setup a virtual environment with virtualenv (optional): You can setup a virtual environment to install OpenSlides as non-root user. - E. g. for ubuntu run: + E. g. for Ubuntu run: $ sudo apt-get install python-virtualenv To setup and activate the virtual environment, create your @@ -69,7 +70,7 @@ II. Installation on GNU/Linux and MacOSX using the sources + ReportLab Toolkit + Python Imaging Library (PIL) - E. g. for ubuntu run: + E. g. for Ubuntu run: $ sudo apt-get install python python-virtualenv python-reportlab python-imaging 2. Get OpenSlides: @@ -82,11 +83,11 @@ II. Installation on GNU/Linux and MacOSX using the sources https://github.com/OpenSlides/OpenSlides. This requires Git, see http://git-scm.com/. - E. g. for ubuntu run: + E. g. for Ubuntu run: $ sudo apt-get install git $ git clone git://github.com/OpenSlides/OpenSlides.git OpenSlides - 3. Setup your virtual environment with virtualenv: + 3. Setup a virtual environment with virtualenv: Go to the (extracted/cloned) root directory of OpenSlides and create virtualenv environment: @@ -130,18 +131,17 @@ II. Installation on GNU/Linux and MacOSX using the sources III. Installation on Windows (32bit) using the Python Package Index (PyPI) ------------------------------------------------------------------------------ +-------------------------------------------------------------------------- NOTE: There is a portable version of OpenSlides for Windows which does not required any install steps! If there is a reason that you can not use the portable version you should run the following install steps. - 1. Install requirements: The OpenSlides install requires following programs, which should be installed first: - + Python Programming Language 2 (>= 2.5), + + Python Programming Language 2 (>= 2.5) + Setuptools a) Download and run 32bit MSI installer from http://www.python.org/: @@ -159,7 +159,6 @@ portable version you should run the following install steps. http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe - 2. Install OpenSlides: Open command line (cmd) and run: From a5022a3f001436322d7a08fd596bc7df9067211e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 1 Dec 2012 14:05:19 +0100 Subject: [PATCH 8/8] Fix pep8 in openslides/__init__.py --- openslides/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openslides/__init__.py b/openslides/__init__.py index fd88160f2..f32ad47e6 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -5,7 +5,7 @@ :license: GNU GPL, see LICENSE for more details. """ -VERSION = (1, 3, 0, 'final', 0) # During development it is the next release +VERSION = (1, 3, 0, 'final', 0) # During development it is the next release RELEASE = False