comparison mercurial/util.py @ 30647:e995f00a9e9a

py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 19 Dec 2016 02:26:41 +0530
parents d524c88511a7
children 10b17ed9b591
comparison
equal deleted inserted replaced
30646:16b5df5792a8 30647:e995f00a9e9a
793 outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-') 793 outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
794 os.close(outfd) 794 os.close(outfd)
795 cmd = cmd.replace('INFILE', inname) 795 cmd = cmd.replace('INFILE', inname)
796 cmd = cmd.replace('OUTFILE', outname) 796 cmd = cmd.replace('OUTFILE', outname)
797 code = os.system(cmd) 797 code = os.system(cmd)
798 if sys.platform == 'OpenVMS' and code & 1: 798 if pycompat.sysplatform == 'OpenVMS' and code & 1:
799 code = 0 799 code = 0
800 if code: 800 if code:
801 raise Abort(_("command '%s' failed: %s") % 801 raise Abort(_("command '%s' failed: %s") %
802 (cmd, explainexit(code))) 802 (cmd, explainexit(code)))
803 return readfile(outname) 803 return readfile(outname)
996 if val is True: 996 if val is True:
997 return '1' 997 return '1'
998 return str(val) 998 return str(val)
999 origcmd = cmd 999 origcmd = cmd
1000 cmd = quotecommand(cmd) 1000 cmd = quotecommand(cmd)
1001 if sys.platform == 'plan9' and (sys.version_info[0] == 2 1001 if pycompat.sysplatform == 'plan9' and (sys.version_info[0] == 2
1002 and sys.version_info[1] < 7): 1002 and sys.version_info[1] < 7):
1003 # subprocess kludge to work around issues in half-baked Python 1003 # subprocess kludge to work around issues in half-baked Python
1004 # ports, notably bichued/python: 1004 # ports, notably bichued/python:
1005 if not cwd is None: 1005 if not cwd is None:
1006 os.chdir(cwd) 1006 os.chdir(cwd)
1018 stderr=subprocess.STDOUT) 1018 stderr=subprocess.STDOUT)
1019 for line in iter(proc.stdout.readline, ''): 1019 for line in iter(proc.stdout.readline, ''):
1020 out.write(line) 1020 out.write(line)
1021 proc.wait() 1021 proc.wait()
1022 rc = proc.returncode 1022 rc = proc.returncode
1023 if sys.platform == 'OpenVMS' and rc & 1: 1023 if pycompat.sysplatform == 'OpenVMS' and rc & 1:
1024 rc = 0 1024 rc = 0
1025 if rc and onerr: 1025 if rc and onerr:
1026 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]), 1026 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]),
1027 explainexit(rc)[0]) 1027 explainexit(rc)[0])
1028 if errprefix: 1028 if errprefix:
1381 function if need.''' 1381 function if need.'''
1382 return path.split(pycompat.ossep) 1382 return path.split(pycompat.ossep)
1383 1383
1384 def gui(): 1384 def gui():
1385 '''Are we running in a GUI?''' 1385 '''Are we running in a GUI?'''
1386 if sys.platform == 'darwin': 1386 if pycompat.sysplatform == 'darwin':
1387 if 'SSH_CONNECTION' in encoding.environ: 1387 if 'SSH_CONNECTION' in encoding.environ:
1388 # handle SSH access to a box where the user is logged in 1388 # handle SSH access to a box where the user is logged in
1389 return False 1389 return False
1390 elif getattr(osutil, 'isgui', None): 1390 elif getattr(osutil, 'isgui', None):
1391 # check if a CoreGraphics session is available 1391 # check if a CoreGraphics session is available