How to control popen within a class

This is the place for queries that don't fit in any of the other categories.

How to control popen within a class

Postby tbaror » Mon Sep 30, 2013 7:10 pm

Hi All,

I am writing a class to do some tasks with shell utility (tshark) using subprocess popen
My problem is that i am stacked actually don't have idea how to interact with method i created that running the popen and for example kill or terminate it , shown in code below.
So if someone could assist me or have another idea will be great
Please advice
Thanks

Code: Select all
import subprocess

class TsharkCtrl():
    def __init__(self,):
       
    def run(self,NIC_LISTEN,FL_TRNAME,OPS_WR=None):
        if OPS_WR == None:
            tsharkCall = ["tshark","-i" ,NIC_LISTEN, "-w" + FL_TRNAME]
            tsharkProc = subprocess.Popen(tsharkCall,executable="C:/Program Files/Wireshark/tshark.exe")
           
           
           
    def killProc(self):
        ?????? :?:

tbaror
 
Posts: 10
Joined: Sun Jul 07, 2013 8:06 pm

Re: How to control popen within a class

Postby micseydel » Mon Sep 30, 2013 10:13 pm

You can use the code
Code: Select all
help(subprocess.Popen)

to find out methods of that object. You should check out kill() and terminate() especially.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1128
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 3 guests