comparison mercurial/statprof.py @ 30637:344e68882cd3

py3: replace os.environ with encoding.environ (part 4 of 5)
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 18 Dec 2016 02:06:00 +0530
parents c6ce11f2ee50
children 262c2be8ea5a
comparison
equal deleted inserted replaced
30636:f1c9fafcbf46 30637:344e68882cd3
115 import tempfile 115 import tempfile
116 import threading 116 import threading
117 import time 117 import time
118 118
119 from . import ( 119 from . import (
120 encoding,
120 pycompat, 121 pycompat,
121 ) 122 )
122 123
123 defaultdict = collections.defaultdict 124 defaultdict = collections.defaultdict
124 contextmanager = contextlib.contextmanager 125 contextmanager = contextlib.contextmanager
322 stopthread.set() 323 stopthread.set()
323 state.thread.join() 324 state.thread.join()
324 325
325 state.accumulate_time(clock()) 326 state.accumulate_time(clock())
326 state.last_start_time = None 327 state.last_start_time = None
327 statprofpath = os.environ.get('STATPROF_DEST') 328 statprofpath = encoding.environ.get('STATPROF_DEST')
328 if statprofpath: 329 if statprofpath:
329 save_data(statprofpath) 330 save_data(statprofpath)
330 331
331 return state 332 return state
332 333
678 if root.count > 0: 679 if root.count > 0:
679 _write(root, 0, False) 680 _write(root, 0, False)
680 681
681 def write_to_flame(data, fp, scriptpath=None, outputfile=None, **kwargs): 682 def write_to_flame(data, fp, scriptpath=None, outputfile=None, **kwargs):
682 if scriptpath is None: 683 if scriptpath is None:
683 scriptpath = os.environ['HOME'] + '/flamegraph.pl' 684 scriptpath = encoding.environ['HOME'] + '/flamegraph.pl'
684 if not os.path.exists(scriptpath): 685 if not os.path.exists(scriptpath):
685 print("error: missing %s" % scriptpath, file=fp) 686 print("error: missing %s" % scriptpath, file=fp)
686 print("get it here: https://github.com/brendangregg/FlameGraph", 687 print("get it here: https://github.com/brendangregg/FlameGraph",
687 file=fp) 688 file=fp)
688 return 689 return