changeset 6792:24fa228656f1

install-iis: refactor, put template as global dispath_py_template Don't hide the builtin 'file' function.
author Mads Kiilerich <mads@kiilerich.com>
date Sat, 12 Aug 2017 17:29:57 +0200
parents 87496864d4c6
children 240d54a3091e
files kallithea/lib/paster_commands/install_iis.py
diffstat 1 files changed, 18 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/paster_commands/install_iis.py	Sat Aug 12 17:29:06 2017 +0200
+++ b/kallithea/lib/paster_commands/install_iis.py	Sat Aug 12 17:29:57 2017 +0200
@@ -26,20 +26,8 @@
 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 @@
     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 '