Commits

Jason R. Coombs committed 8c21e42

Brought over appcmd from adamsrow.tracker. Refactored create_site.
Added reset_binding function and reset-binding command
Renamed install-jaraco-site to jaraco-site-install (for easier namespacing)

Comments (0)

Files changed (2)

jaraco/site/manage.py

 	create_site()
 	register_isapi()
 
+def appcmd(cmd, **kwargs):
+	if isinstance(cmd, basestring):
+		cmd = cmd.split()
+	args = [
+		'/{key}:{value}'.format(**vars())
+		for key, value in kwargs.items()
+	]
+	return subprocess.check_call([
+		r'\Windows\System32\InetSrv\appcmd.exe',
+		] + cmd + args)
+
+bindings = 'http/*:80:www.jaraco.com,https/*:443:www.jaraco.com'
+
+def reset_bindings():
+	"""
+	Creating the site unfortunately doesn't assign the certificate, and
+	setting the certificate manually disallows setting the https hostname,
+	so the bindings need to be reset.
+	See http://sarafianalex.wordpress.com/2010/08/04/setting-host-name-on-ssl-binding-on-iis7/
+	"""
+	appcmd('set site',
+		name = 'Primary Web Site',
+		bindings = bindings,
+	)
+
 def create_site():
-	app_cmd = r'\windows\system32\inetsrv\appcmd.exe'
-	subprocess.check_call([
-		app_cmd,
-		'add', 'site',
-		'/id:3', '/name:Primary Web Site',
-		r'/physicalPath:c:\inetpub\jaraco.site',
-		'/bindings:http/*:80:www.jaraco.com,https/*:443:www.jaraco.com',
-		],
+	appcmd('add site',
+		id=3,
+		name = 'Primary Web Site',
+		physicalPath = r'C:\InetPub\jaraco.site',
+		bindings = bindings,
 	)
-	subprocess.check_call([
-		app_cmd,
-		'add', 'apppool',
-		'/name:Primary Web Site',
-	])
-	subprocess.check_call([
-		app_cmd,
-		'set', 'app',
-		'Primary Web Site/',
-		'/applicationPool:Primary Web Site',
-	])
+	appcmd('add apppool', name='Primary Web Site')
+	appcmd('set app', name="Primary Web Site",
+		applicationPool="Primary Web Site")
 
 def register_isapi():
 	subprocess.check_call([
 	],
 	entry_points = dict(
 		console_scripts = [
-			'install-jaraco-site = jaraco.site.manage:install',
+			'jaraco-site-install = jaraco.site.manage:install',
+			'jaraco-site-reset-bindings = jaraco.site.manage:reset_bindings',
 		],
 	),
 	setup_requires = [
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.