terminator/terminatorlib/cwd.py

23 lines
501 B
Python
Raw Permalink Normal View History

2009-08-11 22:36:37 +00:00
# Terminator by Chris Jones <cmsj@tenshu.net>
# GPL v2 only
2010-01-14 23:33:06 +00:00
"""cwd.py - function necessary to get the cwd for a given pid on various OSes
2020-06-10 16:10:09 +00:00
>>> cwd = get_pid_cwd(None)
2020-05-15 16:45:15 +00:00
>>> cwd.__class__.__name__
'str'
2010-01-14 23:33:06 +00:00
"""
2009-08-11 22:36:37 +00:00
2020-05-15 15:27:36 +00:00
import psutil
2020-06-10 16:10:09 +00:00
from .util import dbg
2020-06-10 16:10:09 +00:00
def get_pid_cwd(pid = None):
"""Determine the cwd of the current process"""
2020-06-10 16:10:09 +00:00
psinfo = psutil.Process(pid).as_dict()
dbg('psinfo: %s %s' % (psinfo['cwd'],psinfo['pid']))
# return func
return psinfo['cwd']
2009-08-11 22:36:37 +00:00
# vim: set expandtab ts=4 sw=4: