##// END OF EJS Templates
py3: replace os.environ with encoding.environ (part 3 of 5)
Pulkit Goyal -
r30636:f1c9fafc default
parent child Browse files
Show More
@@ -16,6 +16,7 b' from .i18n import _'
16 from .node import nullid, short
16 from .node import nullid, short
17
17
18 from . import (
18 from . import (
19 encoding,
19 error,
20 error,
20 formatter,
21 formatter,
21 match,
22 match,
@@ -165,7 +166,7 b' def _picktool(repo, ui, path, binary, sy'
165 return (force, force)
166 return (force, force)
166
167
167 # HGMERGE takes next precedence
168 # HGMERGE takes next precedence
168 hgmerge = os.environ.get("HGMERGE")
169 hgmerge = encoding.environ.get("HGMERGE")
169 if hgmerge:
170 if hgmerge:
170 if changedelete and not supportscd(hgmerge):
171 if changedelete and not supportscd(hgmerge):
171 return ":prompt", None
172 return ":prompt", None
@@ -13,6 +13,7 b' import mimetypes'
13 import os
13 import os
14
14
15 from .. import (
15 from .. import (
16 encoding,
16 pycompat,
17 pycompat,
17 util,
18 util,
18 )
19 )
@@ -191,7 +192,7 b' def get_contact(config):'
191 """
192 """
192 return (config("web", "contact") or
193 return (config("web", "contact") or
193 config("ui", "username") or
194 config("ui", "username") or
194 os.environ.get("EMAIL") or "")
195 encoding.environ.get("EMAIL") or "")
195
196
196 def caching(web, req):
197 def caching(web, req):
197 tag = 'W/"%s"' % web.mtime
198 tag = 'W/"%s"' % web.mtime
@@ -286,7 +286,8 b' class hgweb(object):'
286 Modern servers should be using WSGI and should avoid this
286 Modern servers should be using WSGI and should avoid this
287 method, if possible.
287 method, if possible.
288 """
288 """
289 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
289 if not encoding.environ.get('GATEWAY_INTERFACE',
290 '').startswith("CGI/1."):
290 raise RuntimeError("This function is only intended to be "
291 raise RuntimeError("This function is only intended to be "
291 "called while running as a CGI script.")
292 "called while running as a CGI script.")
292 wsgicgi.launch(self)
293 wsgicgi.launch(self)
@@ -186,7 +186,8 b' class hgwebdir(object):'
186 self.lastrefresh = time.time()
186 self.lastrefresh = time.time()
187
187
188 def run(self):
188 def run(self):
189 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
189 if not encoding.environ.get('GATEWAY_INTERFACE',
190 '').startswith("CGI/1."):
190 raise RuntimeError("This function is only intended to be "
191 raise RuntimeError("This function is only intended to be "
191 "called while running as a CGI script.")
192 "called while running as a CGI script.")
192 wsgicgi.launch(self)
193 wsgicgi.launch(self)
@@ -10,9 +10,8 b''
10
10
11 from __future__ import absolute_import
11 from __future__ import absolute_import
12
12
13 import os
14
15 from .. import (
13 from .. import (
14 encoding,
16 util,
15 util,
17 )
16 )
18
17
@@ -24,7 +23,7 b' def launch(application):'
24 util.setbinary(util.stdin)
23 util.setbinary(util.stdin)
25 util.setbinary(util.stdout)
24 util.setbinary(util.stdout)
26
25
27 environ = dict(os.environ.iteritems())
26 environ = dict(encoding.environ.iteritems())
28 environ.setdefault('PATH_INFO', '')
27 environ.setdefault('PATH_INFO', '')
29 if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
28 if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'):
30 # IIS includes script_name in PATH_INFO
29 # IIS includes script_name in PATH_INFO
@@ -15,6 +15,7 b' import socket'
15
15
16 from .i18n import _
16 from .i18n import _
17 from . import (
17 from . import (
18 encoding,
18 error,
19 error,
19 httpconnection as httpconnectionmod,
20 httpconnection as httpconnectionmod,
20 keepalive,
21 keepalive,
@@ -118,8 +119,8 b' class proxyhandler(urlreq.proxyhandler):'
118 if ui.config("http_proxy", "host"):
119 if ui.config("http_proxy", "host"):
119 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
120 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
120 try:
121 try:
121 if env in os.environ:
122 if env in encoding.environ:
122 del os.environ[env]
123 del encoding.environ[env]
123 except OSError:
124 except OSError:
124 pass
125 pass
125
126
@@ -177,7 +177,7 b' def _is_win_9x():'
177 try:
177 try:
178 return sys.getwindowsversion()[3] == 1
178 return sys.getwindowsversion()[3] == 1
179 except AttributeError:
179 except AttributeError:
180 return 'command' in os.environ.get('comspec', '')
180 return 'command' in encoding.environ.get('comspec', '')
181
181
182 def openhardlinks():
182 def openhardlinks():
183 return not _is_win_9x()
183 return not _is_win_9x()
@@ -303,7 +303,7 b' def findexe(command):'
303 PATH isn't searched if command is an absolute or relative path.
303 PATH isn't searched if command is an absolute or relative path.
304 An extension from PATHEXT is found and added if not present.
304 An extension from PATHEXT is found and added if not present.
305 If command isn't found None is returned.'''
305 If command isn't found None is returned.'''
306 pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
306 pathext = encoding.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
307 pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)]
307 pathexts = [ext for ext in pathext.lower().split(pycompat.ospathsep)]
308 if os.path.splitext(command)[1].lower() in pathexts:
308 if os.path.splitext(command)[1].lower() in pathexts:
309 pathexts = ['']
309 pathexts = ['']
@@ -319,7 +319,7 b' def findexe(command):'
319 if pycompat.ossep in command:
319 if pycompat.ossep in command:
320 return findexisting(command)
320 return findexisting(command)
321
321
322 for path in os.environ.get('PATH', '').split(pycompat.ospathsep):
322 for path in encoding.environ.get('PATH', '').split(pycompat.ospathsep):
323 executable = findexisting(os.path.join(path, command))
323 executable = findexisting(os.path.join(path, command))
324 if executable is not None:
324 if executable is not None:
325 return executable
325 return executable
General Comments 0
You need to be logged in to leave comments. Login now