Commit 7b198aba authored by Luke Macken's avatar Luke Macken

Add a PyrasiteIPC.title property, taken from the GUI

parent fb2667f2
...@@ -23,10 +23,12 @@ import os ...@@ -23,10 +23,12 @@ import os
import socket import socket
import struct import struct
import tempfile import tempfile
import pyrasite import subprocess
from os.path import dirname, abspath, join from os.path import dirname, abspath, join
import pyrasite
class PyrasiteIPC(object): class PyrasiteIPC(object):
"""Pyrasite Inter-Python Communication. """Pyrasite Inter-Python Communication.
...@@ -67,6 +69,14 @@ class PyrasiteIPC(object): ...@@ -67,6 +69,14 @@ class PyrasiteIPC(object):
self.hostname = None self.hostname = None
self.port = None self.port = None
@property
def title(self):
if not getattr(self, '_title', None):
p = subprocess.Popen('ps --no-heading -o cmd= -p %d' % self.pid,
stdout=subprocess.PIPE, shell=True)
self._title = p.communicate()[0].decode('utf-8')
return self._title.strip()
def connect(self): def connect(self):
""" """
Setup a communication socket with the process by injecting Setup a communication socket with the process by injecting
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment