Jason R. Coombs avatar Jason R. Coombs committed eba1c32

Completed TODOs and cleaned up import issues.

Comments (0)

Files changed (1)

adamsrow/tracker/isapi.py

 
 """
 Things to remember when deploying an isapi_wsgi app:
- - easy_install munges permissions on zip eggs (the easiest solution is to just install them with -Z)
- - any dependency that's installed in a user folder (i.e. setup develop) will probably not work due to insufficient permissions
+	- easy_install munges permissions on zip eggs (the easiest solution is to
+		just install them with -Z)
+	- any dependency that's installed in a user folder (i.e. setup develop)
+		will probably not work due to insufficient permissions
 """
 
 import sys
 import os
 import traceback
 import subprocess
+import importlib
 from textwrap import dedent
 
 import isapi_wsgi
 from roundup.cgi import wsgi_handler
 
 if hasattr(sys, "isapidllhandle"):
-	import win32traceutil
+	importlib.import_module('win32traceutil')
+
+appdir = None
 
 def setup_environment(entry_file):
 	"""
 	os.chdir(appdir)
 
 def setup_application():
-	import adamsrow.tracker
-	tracker_home = os.path.join(appdir)
+	tracker_home = appdir
 	return wsgi_handler.RequestDispatcher(tracker_home)
 
 def factory():
 	isapi.install.HandleCommandLine(params)
 
 def create_site():
-	root = 'C:\\inetpub\\adams row tracker'
-	# todo: create site using 'roundup-admin install' and edit config
-	# todo: Give AppPoolIdentity access to root
+	root = r'C:\Inetpub\Adams Row Tracker'
+	if not os.path.isdir(root):
+		os.path.makedirs(root)
+	create_iis_site(root)
+	set_permissions()
 	script = os.path.join(root, 'tracker.py')
 	open(script, 'w').write(dedent("""
 		from adamsrow.tracker.isapi import (
 		setup_environment(__file__)
 		if __name__ == '__main__': handle_command_line()
 		"""))
-	#subprocess.check_call([sys.executable, script, 'install'])
+	subprocess.check_call([sys.executable, script, 'install'])
+	print("Now create site using 'roundup-admin install' and edit "
+		"the config, or copy a previous instance.")
 
 def appcmd(cmd, **kwargs):
 	if isinstance(cmd, basestring):
 	appcmd(['set', 'app', 'Adams Row Tracker/'],
 		applicationPool="Adams Row Tracker")
 
-# set permissions
-r"""
-icacls "C:\Inetpub\Adams Row Tracker" /grant "IIS AppPool\Adams Row Tracker:(OI)(CI)(IO)(F)"
-icacls "C:\Inetpub\Adams Row Tracker" /grant "IUSR:(OI)(CI)(IO)(F)"
-"""
+def set_permissions(root):
+	subprocess.check_call([
+		'icacls',
+		root,
+		'/grant',
+		'IIS AppPool\Adams Row Tracker:(OI)(CI)(IO)(F)',
+	])
+	subprocess.check_call([
+		'icacls',
+		root,
+		'/grant',
+		'IUSR:(OI)(CI)(IO)(F)',
+	])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.