Changeset - 24fa228656f1
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2017-08-12 17:29:57
mads@kiilerich.com
install-iis: refactor, put template as global dispath_py_template

Don't hide the builtin 'file' function.
1 file changed with 18 insertions and 20 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/paster_commands/install_iis.py
Show inline comments
 
@@ -23,26 +23,14 @@ import os
 
import sys
 
from paste.script.appinstall import AbstractInstallCommand
 

	
 
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"):
 
    import win32traceutil
 

	
 
import isapi_wsgi
 
@@ -71,20 +59,30 @@ if __name__=='__main__':
 
                              ScriptMaps = sm,
 
                              ScriptMapUpdate = "replace")
 
    params.VirtualDirs = [vd]
 
    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 '
 
            'default web site') % (dispatchfile,)
 

	
 
    def get_parser(self, prog_name):
0 comments (0 inline, 0 general)