##// END OF EJS Templates
Merge pull request #13328 from Carreau/last-of-37...
Merge pull request #13328 from Carreau/last-of-37 remove last bits of pre-38 codepath.

File last commit:

r26993:8a04efad
r27155:ec9fdb9f merge
Show More
_process_cli.py
70 lines | 2.0 KiB | text/x-python | PythonLexer
Doug Blank
Removed another of the tweaks, and added a note in that it is largely untested.
r15248 """cli-specific implementation of process utilities.
Doug Blank
Minimal changes to import IPython from IronPython
r15154
cli - Common Language Infrastructure for IronPython. Code
can run on any operating system. Check os.name for os-
specific settings.
This file is only meant to be imported by process.py, not by end-users.
Doug Blank
Removed another of the tweaks, and added a note in that it is largely untested.
r15248
This file is largely untested. To become a full drop-in process
interface for IronPython will probably require you to help fill
in the details.
Doug Blank
Minimal changes to import IPython from IronPython
r15154 """
# Import cli libraries:
import clr
import System
# Import Python libraries:
import os
# Import IPython libraries:
from IPython.utils import py3compat
from ._process_common import arg_split
def system(cmd):
"""
system(cmd) should work in a cli environment on Mac OSX, Linux,
and Windows
"""
psi = System.Diagnostics.ProcessStartInfo(cmd)
psi.RedirectStandardOutput = True
psi.RedirectStandardError = True
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
psi.UseShellExecute = False
# Start up process:
reg = System.Diagnostics.Process.Start(psi)
def getoutput(cmd):
"""
getoutput(cmd) should work in a cli environment on Mac OSX, Linux,
and Windows
"""
psi = System.Diagnostics.ProcessStartInfo(cmd)
psi.RedirectStandardOutput = True
psi.RedirectStandardError = True
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
psi.UseShellExecute = False
# Start up process:
reg = System.Diagnostics.Process.Start(psi)
myOutput = reg.StandardOutput
output = myOutput.ReadToEnd()
myError = reg.StandardError
error = myError.ReadToEnd()
return output
Amin Bandali
Add .NET implementation of check_pid
r17689
def check_pid(pid):
"""
Check if a process with the given PID (pid) exists
"""
try:
System.Diagnostics.Process.GetProcessById(pid)
Amin Bandali
Catch InvalidOperationException as well
r17690 # process with given pid is running
return True
except System.InvalidOperationException:
# process wasn't started by this object (but is running)
Amin Bandali
Add .NET implementation of check_pid
r17689 return True
except System.ArgumentException:
Amin Bandali
Catch InvalidOperationException as well
r17690 # process with given pid isn't running
Amin Bandali
Add .NET implementation of check_pid
r17689 return False