Mercurial > public > mercurial-scm > hg
comparison contrib/win32/hgwebdir_wsgi.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | d22198b4b3dd |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
43075:57875cf423c9 | 43076:2372284d9457 |
---|---|
82 | 82 |
83 # Configuration file location | 83 # Configuration file location |
84 hgweb_config = r'c:\your\directory\wsgi.config' | 84 hgweb_config = r'c:\your\directory\wsgi.config' |
85 | 85 |
86 # Global settings for IIS path translation | 86 # Global settings for IIS path translation |
87 path_strip = 0 # Strip this many path elements off (when using url rewrite) | 87 path_strip = 0 # Strip this many path elements off (when using url rewrite) |
88 path_prefix = 1 # This many path elements are prefixes (depends on the | 88 path_prefix = 1 # This many path elements are prefixes (depends on the |
89 # virtual path of the IIS application). | 89 # virtual path of the IIS application). |
90 | 90 |
91 import sys | 91 import sys |
92 | 92 |
93 # Adjust python path if this is not a system-wide install | 93 # Adjust python path if this is not a system-wide install |
94 #sys.path.insert(0, r'C:\your\custom\hg\build\lib.win32-2.7') | 94 # sys.path.insert(0, r'C:\your\custom\hg\build\lib.win32-2.7') |
95 | 95 |
96 # Enable tracing. Run 'python -m win32traceutil' to debug | 96 # Enable tracing. Run 'python -m win32traceutil' to debug |
97 if getattr(sys, 'isapidllhandle', None) is not None: | 97 if getattr(sys, 'isapidllhandle', None) is not None: |
98 import win32traceutil | 98 import win32traceutil |
99 win32traceutil.SetupForPrint # silence unused import warning | 99 |
100 win32traceutil.SetupForPrint # silence unused import warning | |
100 | 101 |
101 import isapi_wsgi | 102 import isapi_wsgi |
102 from mercurial.hgweb.hgwebdir_mod import hgwebdir | 103 from mercurial.hgweb.hgwebdir_mod import hgwebdir |
103 | 104 |
104 # Example tweak: Replace isapi_wsgi's handler to provide better error message | 105 # Example tweak: Replace isapi_wsgi's handler to provide better error message |
105 # Other stuff could also be done here, like logging errors etc. | 106 # Other stuff could also be done here, like logging errors etc. |
106 class WsgiHandler(isapi_wsgi.IsapiWsgiHandler): | 107 class WsgiHandler(isapi_wsgi.IsapiWsgiHandler): |
107 error_status = '500 Internal Server Error' # less silly error message | 108 error_status = '500 Internal Server Error' # less silly error message |
109 | |
108 | 110 |
109 isapi_wsgi.IsapiWsgiHandler = WsgiHandler | 111 isapi_wsgi.IsapiWsgiHandler = WsgiHandler |
110 | 112 |
111 # Only create the hgwebdir instance once | 113 # Only create the hgwebdir instance once |
112 application = hgwebdir(hgweb_config) | 114 application = hgwebdir(hgweb_config) |
115 | |
113 | 116 |
114 def handler(environ, start_response): | 117 def handler(environ, start_response): |
115 | 118 |
116 # Translate IIS's weird URLs | 119 # Translate IIS's weird URLs |
117 url = environ['SCRIPT_NAME'] + environ['PATH_INFO'] | 120 url = environ['SCRIPT_NAME'] + environ['PATH_INFO'] |
123 environ['SCRIPT_NAME'] = script_name | 126 environ['SCRIPT_NAME'] = script_name |
124 environ['PATH_INFO'] = path_info | 127 environ['PATH_INFO'] = path_info |
125 | 128 |
126 return application(environ, start_response) | 129 return application(environ, start_response) |
127 | 130 |
131 | |
128 def __ExtensionFactory__(): | 132 def __ExtensionFactory__(): |
129 return isapi_wsgi.ISAPISimpleHandler(handler) | 133 return isapi_wsgi.ISAPISimpleHandler(handler) |
130 | 134 |
131 if __name__=='__main__': | 135 |
136 if __name__ == '__main__': | |
132 from isapi.install import ISAPIParameters, HandleCommandLine | 137 from isapi.install import ISAPIParameters, HandleCommandLine |
138 | |
133 params = ISAPIParameters() | 139 params = ISAPIParameters() |
134 HandleCommandLine(params) | 140 HandleCommandLine(params) |