#NEWLINE# def install( self , args , options ) : #NEWLINE# #INDENT# if ( os . path . exists ( self . web_config ) and ( not options [ 'skip_config' ] ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'A web site configuration already exists in [%s] !' % self . install_dir ) ) #NEWLINE# #UNINDENT# static_dir = os . path . normcase ( os . path . abspath ( getattr ( settings , 'STATIC_ROOT' , '' ) ) ) #NEWLINE# static_url = getattr ( settings , 'STATIC_URL' , '/static/' ) #NEWLINE# static_match = re . match ( '^/([^/]+)/$' , static_url ) #NEWLINE# if static_match : #NEWLINE# #INDENT# static_is_local = True #NEWLINE# static_name = static_match . group ( 1 ) #NEWLINE# static_needs_virtual_dir = ( static_dir != os . path . join ( self . install_dir , static_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# static_is_local = False #NEWLINE# #UNINDENT# if ( ( static_dir == self . install_dir ) and static_is_local ) : #NEWLINE# #INDENT# raise CommandError ( 'The web site directory cannot be the same as the static directory,\nfor we cannot have two different web.config files in the same\ndirectory !' ) #NEWLINE# #UNINDENT# if ( not options [ 'skip_config' ] ) : #NEWLINE# #INDENT# print ( 'Creating web.config' ) #NEWLINE# template = get_template ( 'windows_tools/iis/web.config' ) #NEWLINE# file = open ( self . web_config , 'w' ) #NEWLINE# file . write ( template . render ( Context ( self . __dict__ ) ) ) #NEWLINE# file . close ( ) #NEWLINE# set_file_readable ( self . web_config ) #NEWLINE# #UNINDENT# if ( options [ 'monitorChangesTo' ] == '' ) : #NEWLINE# #INDENT# options [ 'monitorChangesTo' ] = os . path . join ( self . install_dir , 'web.config' ) #NEWLINE# #UNINDENT# if ( not options [ 'skip_fastcgi' ] ) : #NEWLINE# #INDENT# print ( 'Creating FastCGI application' ) #NEWLINE# if ( not self . create_fastcgi_section ( options ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'The FastCGI application creation has failed with the following message :\n%s' % self . last_command_error ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not options [ 'skip_site' ] ) : #NEWLINE# #INDENT# site_name = options [ 'site_name' ] #NEWLINE# print ( ( 'Creating application pool with name %s' % file ) ) #NEWLINE# if ( not self . run_config_command ( 'add' , 'apppool' , ( '/name:%s' % site_name ) ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'The Application Pool creation has failed with the following message :\n%s' % self . last_command_error ) ) #NEWLINE# #UNINDENT# print ( 'Creating the site' ) #NEWLINE# if ( not self . run_config_command ( 'add' , 'site' , ( '/name:%s' % site_name ) , ( '/bindings:%s' % options [ 'binding' ] ) , ( '/physicalPath:%s' % self . install_dir ) ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'The site creation has failed with the following message :\n%s' % self . last_command_error ) ) #NEWLINE# #UNINDENT# print ( 'Adding the site to the application pool' ) #NEWLINE# if ( not self . run_config_command ( 'set' , 'app' , ( '%s/' % site_name ) , ( '/applicationPool:%s' % site_name ) ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'Adding the site to the application pool has failed with the following message :\n%s' % self . last_command_error ) ) #NEWLINE# #UNINDENT# if ( static_is_local and static_needs_virtual_dir ) : #NEWLINE# #INDENT# print ( ( 'Creating virtual directory for [%s] in [%s]' % ( static_dir , static_url ) ) ) #NEWLINE# if ( not self . run_config_command ( 'add' , 'vdir' , ( '/app.name:%s/' % site_name ) , ( '/path:/%s' % static_name ) , ( '/physicalPath:%s' % static_dir ) ) ) : #NEWLINE# #INDENT# raise CommandError ( ( 'Adding the static virtual directory has failed with the following message :\n%s' % self . last_command_error ) )