Hello everyone,
I have been trying to grep certain lines out of STDIN. Basically this is a little app that email is piped to. It works fine, the onlt thing is I get the whole email. I need only to strip out from and subject. Here is what I have so far
#!/usr/bin/python
import wx
import sys
import os
email = sys.stdin.read()
email_info = os.popen('grep -i \"^[subject:|from:]\" %s' %email)<------------------
--------th
is is where i run into problems!
class EvoTray(wx.TaskBarIcon):
def __init__(self, frame):
wx.TaskBarIcon.__init__(se
lf)
self.frame = frame
self.SetIcon(wx.Icon('/hom
e/administ
rator/Desk
top/env.pn
g',wx.BITM
AP_TYPE_PN
G), 'EvoTray')
self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=1)
self.Bind(wx.EVT_MENU, self.OnTaskBarDeactivate, id=2)
self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=3)
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(1, 'Show')
menu.Append(2, 'Hide')
menu.Append(3, 'Close')
return menu
def OnTaskBarClose(self, event):
self.frame.Close()
def OnTaskBarActivate(self, event):
if not self.frame.IsShown():
self.frame.Show()
def OnTaskBarDeactivate(self, event):
if self.frame.IsShown():
self.frame.Hide()
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, (-1, -1),
(290, 280))
self.txt_ctrl = wx.TextCtrl(self,-1,email_
info,style
=wx.TE_MUL
TILINE|wx.
TE_BESTWRA
P)
self.tskic = EvoTray(self)
self.Centre()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
self.tskic.Destroy()
self.Destroy()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'EvoMailNotification')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
thanks in advance.
Start Free Trial