##// END OF EJS Templates
py3: replace os.environ with encoding.environ (part 4 of 5)
Pulkit Goyal -
r30637:344e6888 default
parent child Browse files
Show More
@@ -3,6 +3,7 b' from __future__ import absolute_import'
3 3 import os
4 4
5 5 from . import (
6 encoding,
6 7 osutil,
7 8 pycompat,
8 9 util,
@@ -48,7 +49,7 b' def userrcpath():'
48 49 home = os.path.expanduser('~')
49 50 path = [os.path.join(home, 'mercurial.ini'),
50 51 os.path.join(home, '.hgrc')]
51 userprofile = os.environ.get('USERPROFILE')
52 userprofile = encoding.environ.get('USERPROFILE')
52 53 if userprofile and userprofile != home:
53 54 path.append(os.path.join(userprofile, 'mercurial.ini'))
54 55 path.append(os.path.join(userprofile, '.hgrc'))
@@ -117,6 +117,7 b' import threading'
117 117 import time
118 118
119 119 from . import (
120 encoding,
120 121 pycompat,
121 122 )
122 123
@@ -324,7 +325,7 b' def stop():'
324 325
325 326 state.accumulate_time(clock())
326 327 state.last_start_time = None
327 statprofpath = os.environ.get('STATPROF_DEST')
328 statprofpath = encoding.environ.get('STATPROF_DEST')
328 329 if statprofpath:
329 330 save_data(statprofpath)
330 331
@@ -680,7 +681,7 b' def display_hotpath(data, fp, limit=0.05'
680 681
681 682 def write_to_flame(data, fp, scriptpath=None, outputfile=None, **kwargs):
682 683 if scriptpath is None:
683 scriptpath = os.environ['HOME'] + '/flamegraph.pl'
684 scriptpath = encoding.environ['HOME'] + '/flamegraph.pl'
684 685 if not os.path.exists(scriptpath):
685 686 print("error: missing %s" % scriptpath, file=fp)
686 687 print("get it here: https://github.com/brendangregg/FlameGraph",
@@ -143,7 +143,7 b' class ui(object):'
143 143 self.fin = util.stdin
144 144
145 145 # shared read-only environment
146 self.environ = os.environ
146 self.environ = encoding.environ
147 147
148 148 self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm()
149 149
@@ -948,14 +948,14 b' def hgexecutable():'
948 948 Defaults to $HG or 'hg' in the search path.
949 949 """
950 950 if _hgexecutable is None:
951 hg = os.environ.get('HG')
951 hg = encoding.environ.get('HG')
952 952 mainmod = sys.modules['__main__']
953 953 if hg:
954 954 _sethgexecutable(hg)
955 955 elif mainfrozen():
956 956 if getattr(sys, 'frozen', None) == 'macosx_app':
957 957 # Env variable set by py2app
958 _sethgexecutable(os.environ['EXECUTABLEPATH'])
958 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
959 959 else:
960 960 _sethgexecutable(sys.executable)
961 961 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg':
@@ -1006,7 +1006,7 b' def system(cmd, environ=None, cwd=None, '
1006 1006 os.chdir(cwd)
1007 1007 rc = os.system(cmd)
1008 1008 else:
1009 env = dict(os.environ)
1009 env = dict(encoding.environ)
1010 1010 env.update((k, py2shell(v)) for k, v in environ.iteritems())
1011 1011 env['HG'] = hgexecutable()
1012 1012 if out is None or _isstdout(out):
@@ -1384,7 +1384,7 b' def splitpath(path):'
1384 1384 def gui():
1385 1385 '''Are we running in a GUI?'''
1386 1386 if sys.platform == 'darwin':
1387 if 'SSH_CONNECTION' in os.environ:
1387 if 'SSH_CONNECTION' in encoding.environ:
1388 1388 # handle SSH access to a box where the user is logged in
1389 1389 return False
1390 1390 elif getattr(osutil, 'isgui', None):
@@ -1394,7 +1394,7 b' def gui():'
1394 1394 # pure build; use a safe default
1395 1395 return True
1396 1396 else:
1397 return os.name == "nt" or os.environ.get("DISPLAY")
1397 return os.name == "nt" or encoding.environ.get("DISPLAY")
1398 1398
1399 1399 def mktempcopy(name, emptyok=False, createmode=None):
1400 1400 """Create a temporary file with the same contents from name
@@ -2297,7 +2297,7 b' def hgcmd():'
2297 2297 if mainfrozen():
2298 2298 if getattr(sys, 'frozen', None) == 'macosx_app':
2299 2299 # Env variable set by py2app
2300 return [os.environ['EXECUTABLEPATH']]
2300 return [encoding.environ['EXECUTABLEPATH']]
2301 2301 else:
2302 2302 return [sys.executable]
2303 2303 return gethgcmd()
@@ -14,6 +14,8 b' import os'
14 14 import random
15 15 import subprocess
16 16
17 from . import encoding
18
17 19 _kernel32 = ctypes.windll.kernel32
18 20 _advapi32 = ctypes.windll.advapi32
19 21 _user32 = ctypes.windll.user32
@@ -424,8 +426,8 b' def spawndetached(args):'
424 426 pi = _PROCESS_INFORMATION()
425 427
426 428 env = ''
427 for k in os.environ:
428 env += "%s=%s\0" % (k, os.environ[k])
429 for k in encoding.environ:
430 env += "%s=%s\0" % (k, encoding.environ[k])
429 431 if not env:
430 432 env = '\0'
431 433 env += '\0'
@@ -433,7 +435,7 b' def spawndetached(args):'
433 435 args = subprocess.list2cmdline(args)
434 436 # Not running the command in shell mode makes Python 2.6 hang when
435 437 # writing to hgweb output socket.
436 comspec = os.environ.get("COMSPEC", "cmd.exe")
438 comspec = encoding.environ.get("COMSPEC", "cmd.exe")
437 439 args = comspec + " /c " + args
438 440
439 441 res = _kernel32.CreateProcessA(
General Comments 0
You need to be logged in to leave comments. Login now