FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ipython/IPython/utils/_process_cli.py at python-3.14-dev · krassowski/ipython · GitHub
krassowski
ipython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ipython
/
IPython
/
utils
/
_process_cli.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (59 loc) · 1.97 KB
Breadcrumbs
ipython
/
IPython
/
utils
/
_process_cli.py
Copy path
File metadata and controls
71 lines (59 loc) · 1.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""cli-specific implementation of process utilities.
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.
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.
"""
# Import cli libraries:
import
clr
import
System
# Import Python libraries:
import
os
# Import IPython libraries:
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
def
check_pid
(
pid
):
"""
Check if a process with the given PID (pid) exists
"""
try
:
System
.
Diagnostics
.
Process
.
GetProcessById
(
pid
)
# process with given pid is running
return
True
except
System
.
InvalidOperationException
:
# process wasn't started by this object (but is running)
return
True
except
System
.
ArgumentException
:
# process with given pid isn't running
return
False
Back
|
FazBrowse Home
|
New Git URL