Commit 762525a1 authored by Luke Macken's avatar Luke Macken

Use the new pyrasite.utils.run everywhere

parent eab58d17
......@@ -28,6 +28,6 @@ class ObjectInspector(object):
'gdb --quiet -p %s -batch' % self.pid,
'-eval-command="print (PyObject *)%s"' % address,
])
for line in run(cmd).split('\n'):
for line in run(cmd)[1].split('\n'):
if line.startswith('$1 = '):
return line[5:]
......@@ -27,14 +27,18 @@ from meliae import loader
from gi.repository import GLib, GObject, Pango, GdkPixbuf, Gtk
import pyrasite
from pyrasite.utils import run, PyrasiteIPC
from pyrasite.utils import run, setup_logger
from pyrasite.ipc import PyrasiteIPC
log = logging.getLogger('pyrasite')
class Process(GObject.GObject):
def __init__(self, pid):
super(Process, self).__init__()
self.pid = pid
self.title = run('ps --no-heading -o cmd= -p %d' % pid)
self.title = run('ps --no-heading -o cmd= -p %d' % pid)[1]
self.command = self.title
self.title = self.title[:25]
self.ipc = None
......
......@@ -15,15 +15,16 @@
#
# Copyright (C) 2011 Red Hat, Inc.
import unittest, subprocess
import unittest
from pyrasite.inject import CodeInjector
from pyrasite.utils import run
class TestCodeInjection(unittest.TestCase):
def test_injection(self):
cmd = 'python -c "import time; time.sleep(0.5)"'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
p = run(cmd, communicate=False)[0]
ci = CodeInjector(p.pid, verbose=True)
ci.inject('payloads/helloworld.py')
......@@ -37,8 +38,7 @@ class TestCodeInjection(unittest.TestCase):
'snooze = lambda: time.sleep(0.5)',
'threading.Thread(target=snooze).start()',
]
p = subprocess.Popen('python -c "%s"' % ';'.join(cmd),
shell=True, stdout=subprocess.PIPE)
p = run('python -c "%s"' % ';'.join(cmd), communicate=False)[0]
ci = CodeInjector(p.pid, verbose=True)
ci.inject('payloads/helloworld.py')
......
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