# HG changeset patch # User Mads Kiilerich # Date 2017-08-12 17:29:57 # Node ID 24fa228656f141c9e602a3a2857169a610e2bb21 # Parent 87496864d4c6e646c25ab283793f6eab580bf188 install-iis: refactor, put template as global dispath_py_template Don't hide the builtin 'file' function. diff --git a/kallithea/lib/paster_commands/install_iis.py b/kallithea/lib/paster_commands/install_iis.py --- a/kallithea/lib/paster_commands/install_iis.py +++ b/kallithea/lib/paster_commands/install_iis.py @@ -26,20 +26,8 @@ from paste.script.appinstall import Abst from kallithea.lib.paster_commands.common import BasePasterCommand -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') - - file = '''\ -# Created by Kallithea install_iis +dispath_py_template = '''\ +# Created by Kallithea 'gearbox install-iis' import sys if hasattr(sys, "isapidllhandle"): @@ -74,14 +62,24 @@ if __name__=='__main__': HandleCommandLine(params) ''' - outdata = file % { +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 + self.ensure_file(dispatchfile, dispath_py_template % { 'inifile': config_file.replace('\\', '\\\\'), 'virtualdir': args.virtualdir, - } - - dispatchfile = os.path.join(os.getcwd(), 'dispatch.py') - self.ensure_file(dispatchfile, outdata, False) - print 'Generating %s' % (dispatchfile,) + }, False) print ('Run \'python "%s" install\' with administrative privileges ' 'to generate the _dispatch.dll file and install it into the '