changeset 7413:9de61c5b8694

cli: convert 'gearbox install-iis' into 'kallithea-cli iis-install'
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sun, 18 Nov 2018 20:02:17 +0100
parents e8c3241e5828
children 3158cf0dafb7
files docs/installation_iis.rst kallithea/bin/kallithea_cli.py kallithea/bin/kallithea_cli_iis.py kallithea/lib/paster_commands/install_iis.py setup.py
diffstat 5 files changed, 83 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/docs/installation_iis.rst	Sun Oct 14 22:09:49 2018 +0200
+++ b/docs/installation_iis.rst	Sun Nov 18 20:02:17 2018 +0100
@@ -59,7 +59,7 @@
 
 The ISAPI handler can be generated using::
 
-    gearbox install-iis -c my.ini --virtualdir=/
+    kallithea-cli iis-install -c my.ini --virtualdir=/
 
 This will generate a ``dispatch.py`` file in the current directory that contains
 the necessary components to finalize an installation into IIS. Once this file
--- a/kallithea/bin/kallithea_cli.py	Sun Oct 14 22:09:49 2018 +0200
+++ b/kallithea/bin/kallithea_cli.py	Sun Nov 18 20:02:17 2018 +0100
@@ -17,5 +17,6 @@
 
 # import commands (they will add themselves to the 'cli' object)
 import kallithea.bin.kallithea_cli_config
+import kallithea.bin.kallithea_cli_iis
 import kallithea.bin.kallithea_cli_ishell
 import kallithea.bin.kallithea_cli_repo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kallithea/bin/kallithea_cli_iis.py	Sun Nov 18 20:02:17 2018 +0100
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+# 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, either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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, see <http://www.gnu.org/licenses/>.
+import click
+import kallithea
+import kallithea.bin.kallithea_cli_base as cli_base
+
+import os
+import sys
+
+dispath_py_template = '''\
+# Created by Kallithea 'kallithea-cli iis-install'
+import sys
+
+if hasattr(sys, "isapidllhandle"):
+    import win32traceutil
+
+import isapi_wsgi
+import os
+
+def __ExtensionFactory__():
+    from paste.deploy import loadapp
+    from paste.script.util.logging_config import fileConfig
+    fileConfig('%(inifile)s')
+    application = loadapp('config:%(inifile)s')
+
+    def app(environ, start_response):
+        user = environ.get('REMOTE_USER', None)
+        if user is not None:
+            os.environ['REMOTE_USER'] = user
+        return application(environ, start_response)
+
+    return isapi_wsgi.ISAPIThreadPoolHandler(app)
+
+if __name__=='__main__':
+    from isapi.install import *
+    params = ISAPIParameters()
+    sm = [ScriptMapParams(Extension="*", Flags=0)]
+    vd = VirtualDirParameters(Name="%(virtualdir)s",
+                              Description = "Kallithea",
+                              ScriptMaps = sm,
+                              ScriptMapUpdate = "replace")
+    params.VirtualDirs = [vd]
+    HandleCommandLine(params)
+'''
+
+@cli_base.register_command(config_file=True)
+@click.option('--virtualdir', default='/',
+        help='The virtual folder to install into on IIS.')
+def iis_install(virtualdir):
+    """Install into IIS using isapi-wsgi."""
+
+    config_file_abs = kallithea.CONFIG['__file__']
+
+    try:
+        import isapi_wsgi
+    except ImportError:
+        sys.stderr.write('missing requirement: isapi-wsgi not installed\n')
+        sys.exit(1)
+
+    dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
+    click.echo('Writing %s' % dispatchfile)
+    with open(dispatchfile, 'w') as f:
+        f.write(dispath_py_template % {
+            'inifile': config_file_abs.replace('\\', '\\\\'),
+            'virtualdir': virtualdir,
+            })
+
+    click.echo('Run \'python "%s" install\' with administrative privileges '
+        'to generate the _dispatch.dll file and install it into the '
+        'default web site' % dispatchfile)
--- a/kallithea/lib/paster_commands/install_iis.py	Sun Oct 14 22:09:49 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-# 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, either version 3 of the License, or
-# (at your option) any later version.
-#
-# 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, see <http://www.gnu.org/licenses/>.
-"""
-kallithea.lib.paster_commands.install_iis
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-IIS installation tools for Kallithea
-"""
-
-
-import os
-
-from kallithea.lib.paster_commands.common import BasePasterCommand
-
-
-dispath_py_template = '''\
-# Created by Kallithea 'gearbox install-iis'
-import sys
-
-if hasattr(sys, "isapidllhandle"):
-    import win32traceutil
-
-import isapi_wsgi
-import os
-
-def __ExtensionFactory__():
-    from paste.deploy import loadapp
-    from paste.script.util.logging_config import fileConfig
-    fileConfig('%(inifile)s')
-    application = loadapp('config:%(inifile)s')
-
-    def app(environ, start_response):
-        user = environ.get('REMOTE_USER', None)
-        if user is not None:
-            os.environ['REMOTE_USER'] = user
-        return application(environ, start_response)
-
-    return isapi_wsgi.ISAPIThreadPoolHandler(app)
-
-if __name__=='__main__':
-    from isapi.install import *
-    params = ISAPIParameters()
-    sm = [ScriptMapParams(Extension="*", Flags=0)]
-    vd = VirtualDirParameters(Name="%(virtualdir)s",
-                              Description = "Kallithea",
-                              ScriptMaps = sm,
-                              ScriptMapUpdate = "replace")
-    params.VirtualDirs = [vd]
-    HandleCommandLine(params)
-'''
-
-
-class Command(BasePasterCommand):
-    '''Kallithea: Install into IIS using isapi-wsgi'''
-
-    requires_db_session = False
-
-    def take_action(self, args):
-        config_file = os.path.abspath(args.config_file)
-        try:
-            import isapi_wsgi
-        except ImportError:
-            self.error('missing requirement: isapi-wsgi not installed')
-
-        dispatchfile = os.path.join(os.getcwd(), 'dispatch.py')
-        print 'Writing %s' % dispatchfile
-        with open(dispatchfile, 'w') as f:
-            f.write(dispath_py_template % {
-                'inifile': config_file.replace('\\', '\\\\'),
-                'virtualdir': args.virtualdir,
-                })
-
-        print ('Run \'python "%s" install\' with administrative privileges '
-            'to generate the _dispatch.dll file and install it into the '
-            'default web site') % (dispatchfile,)
-
-    def get_parser(self, prog_name):
-        parser = super(Command, self).get_parser(prog_name)
-
-        parser.add_argument('--virtualdir',
-                      action='store',
-                      dest='virtualdir',
-                      default='/',
-                      help='The virtual folder to install into on IIS')
-
-        return parser
--- a/setup.py	Sun Oct 14 22:09:49 2018 +0200
+++ b/setup.py	Sun Nov 18 20:02:17 2018 +0100
@@ -160,7 +160,6 @@
 
     [gearbox.commands]
     celeryd=kallithea.lib.paster_commands.celeryd:Command
-    install-iis=kallithea.lib.paster_commands.install_iis:Command
     make-index=kallithea.lib.paster_commands.make_index:Command
     make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command
     setup-db=kallithea.lib.paster_commands.setup_db:Command