From 00ca2acc1425075f187f9c4f4a219448d9d1309f Mon Sep 17 00:00:00 2001 From: kakwa Date: Sun, 19 Jul 2015 23:43:36 +0200 Subject: [PATCH 1/7] cleaner setup.py * cleaner SYSCONFIG and DATAROOTDIR handling * deploy configuration anyway if --root is specified --- setup.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 483a858..4b6b317 100755 --- a/setup.py +++ b/setup.py @@ -5,13 +5,16 @@ import os import re import sys -from distutils.core import setup +from distutils.core import setup, run_setup # some install path variables sysconfdir = os.getenv("SYSCONFDIR", "/etc") -datarootdir = os.getenv("DATAROOTDIR", sys.prefix) +datarootdir = os.getenv("DATAROOTDIR", os.path.join(sys.prefix, 'share')) -data_dir = os.path.join(sys.prefix, 'share', 'ldapcherry') +# path to install data +data_dir = os.path.join(datarootdir, 'ldapcherry') +# path to install configuration +config_dir = os.path.join(sysconfdir, 'ldapcherry') small_description = 'A simple web application to manage Ldap entries' # change requirements according to python version @@ -63,6 +66,13 @@ except ImportError: x +def as_option_root(): + for arg in sys.argv: + if re.match(r'--root.*', arg): + return True + return False + + # just a small function to easily install a complete directory def get_list_files(basedir, targetdir): return_list = [] @@ -77,15 +87,16 @@ def get_list_files(basedir, targetdir): # add static files and templates in the list of thing to deploy resources_files = get_list_files( 'resources', - os.path.join(datarootdir, 'share', 'ldapcherry') + data_dir, ) +as_option_root # add the configuration files if they don't exist -if not os.path.exists( - os.path.join(sysconfdir, 'ldapcherry')): +if as_option_root() or not os.path.exists( + config_dir): resources_files.append( ( - os.path.join(sysconfdir, 'ldapcherry'), + config_dir, [ 'conf/ldapcherry.ini', 'conf/attributes.yml', @@ -94,6 +105,7 @@ if not os.path.exists( ) ) + setup( name='ldapcherry', zip_safe=False, From 0bbad880978e2675eeac4d642a9983084f12615d Mon Sep 17 00:00:00 2001 From: kakwa Date: Sun, 19 Jul 2015 23:56:13 +0200 Subject: [PATCH 2/7] trying to add mock cherrypy module for API doc --- docs/conf.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 2531003..de797a6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,7 +41,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'LdapCherry - Performance Test Framework' +project = u'LdapCherry - Directory Management Interface' copyright = u'2014, Pierre-Francois Carpentier' # The version info for the project you're documenting, acts as replacement for @@ -165,3 +165,15 @@ html_file_suffix = ".html" # Output file base name for HTML help builder. htmlhelp_basename = 'LdapCherry-docs' +try: + from unittest.mock import MagicMock + + class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return Mock() + + MOCK_MODULES = ['cherrypy'] + sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) +except Exception as e: + pass From 0635fc2065cb8b691a97113b477441c7deae9cdc Mon Sep 17 00:00:00 2001 From: kakwa Date: Sun, 19 Jul 2015 23:59:40 +0200 Subject: [PATCH 3/7] adding debug message for mock --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index de797a6..715cf10 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -176,4 +176,5 @@ try: MOCK_MODULES = ['cherrypy'] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) except Exception as e: + print("No Mock of cherrypy") pass From fc0d75ebe1a9023e8258d0227052b90203bc0a37 Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 20 Jul 2015 00:01:18 +0200 Subject: [PATCH 4/7] more debug in doc configuration --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index 715cf10..3104484 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -177,4 +177,5 @@ try: sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) except Exception as e: print("No Mock of cherrypy") + print(str(e)) pass From efefc3b9a6cc485e6b0523f85c17717c5c5f2827 Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 20 Jul 2015 00:05:40 +0200 Subject: [PATCH 5/7] adding requirements.txt for doc --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8a305ba --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +CherryPy>=3.0.0 From ae59f34d3a3222f5c6e4f6b2177292d767304caf Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 20 Jul 2015 00:08:58 +0200 Subject: [PATCH 6/7] complete requirements.txt --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 8a305ba..ea61776 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ CherryPy>=3.0.0 +python-ldap +PyYAML +Mako From 4f83667e5088639f31cd204c33f4a25dda905249 Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 20 Jul 2015 00:11:48 +0200 Subject: [PATCH 7/7] changing install order --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ea61776..a9dabc8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ CherryPy>=3.0.0 -python-ldap PyYAML Mako +python-ldap