Skip to content

Commit

Permalink
Merge branch 'main' into color-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
laszewsk authored Jan 8, 2024
2 parents 9d2a1a3 + 61a0a2f commit 383e076
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.51
5.0.52
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [

[project]
name = "cloudmesh-common"
version = "5.0.51"
version = "5.0.52"
description = "A set of useful APIs for cloudmesh"
readme = "README.md"
requires-python = ">=3.8"
Expand Down Expand Up @@ -75,4 +75,4 @@ Changelog = "https://github.com/cloudmesh/cloudmesh-common/blob/main/CHANGELOG.m

[tool.setuptools.packages.find]
where = ["src"]
include = ["cloudmesh.common", "cloudmesh.common.*"]
include = ["cloudmesh.common", "cloudmesh.common.*"]
37 changes: 37 additions & 0 deletions src/cloudmesh/common/Shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,43 @@ def keystone(cls, *args):
"""
return cls.execute("keystone", args)

@staticmethod
def find_process(name):
"""
Find a process by name.
Args:
name (str): The name of the process.
Returns:
list: A list of dictionaries containing the attributes 'pid', 'command',
and 'created' for each process that matches the specified name.
Example:
>>> find_process("python")
[{'pid': 1234, 'command': 'python script.py', 'created': 1634567890}]
"""
processes = None
for p in psutil.process_iter():
found = None
try:
found = p.name()
except (psutil.AccessDenied, psutil.ZombieProcess):
pass
except psutil.NoSuchProcess:
continue
if name == found:
if processes is None:
processes = []
processes.append(
{
"pid": p.pid,
"command": " ".join(p.cmdline()),
"created": p.create_time(),
}
)
return processes

@staticmethod
def kill_pid(pid):
"""
Expand Down

0 comments on commit 383e076

Please sign in to comment.