Changeset 658
- Timestamp:
- Nov 25, 2011 8:14:28 PM (14 years ago)
- Location:
- pvMail/src/pyEpics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pvMail/src/pyEpics ¶
- Property svn:ignore
-
TabularUnified
old new 1 pvMail.log1 *.log 2 2 pvMail_email.txt 3 3
-
- Property svn:ignore
-
TabularUnified pvMail/src/pyEpics/pvMail.py ¶
r657 r658 60 60 import logging 61 61 import os 62 import shlex63 62 import socket 64 import subprocess65 63 import sys 66 64 import time 67 65 68 66 67 __description__ = "Watch an EPICS PV. Send email when it changes from 0 to 1." 69 68 __version__ = "3.0a." + "$Rev$".split(" ")[1] 70 69 __svnid__ = "$Id$" 71 __description__ = "Watch an EPICS PV. Send email when it changes from 0 to 1." 72 LOG_FILE = "pvMail.log" 70 __license__ = "(c) 2009-2012, UChicago Argonne, LLC, BSD-style license, see LICENSE file for details" 71 72 LOG_FILE = "pvMail-%d.log" % os.getpid() 73 73 MESSAGE_FILE = "pvmail_email.txt" 74 74 RETRY_INTERVAL_S = 0.2 … … 206 206 ''' 207 207 logger("send_test_message") 208 self.recipients = [" prjemian@gmail.com"]208 self.recipients = ["jemian", "prjemian"] 209 209 self.message = "this is a test\n\n" + self.addMessageTail() 210 210 self.subject = "pvMail development test" … … 222 222 messageFile = "/tmp/pvmail_message.txt" 223 223 logger("sending email to: " + ", ".join(recipients)) 224 # send the message 224 225 # write the message to a file 226 # TODO: how can we avoid writing a temporary file? 225 227 pvMailMsg = open(messageFile, "w") 226 228 pvMailMsg.write(message) 227 229 pvMailMsg.close() 228 230 231 # send the message 229 232 cmd_fmt = '''mail -s "%s" %s < %s''' 230 for who in recipients: 231 # send a message to each recipient 232 cmd = cmd_fmt % ( subject, who, messageFile ) 233 logger( cmd ) 234 os.popen(cmd) # for now 235 # popen is deprecated since Python 2.6 236 # use subprocess module instead 237 238 # THIS DOES NOT WORK CORRECTLY! 239 #sends mail to /tmp/pvmail_message.txt with no message 240 #args = shlex.split(cmd) 241 #subprocess.call(args) 233 cmd = cmd_fmt % ( subject, " ".join(recipients), messageFile ) 234 logger( cmd ) 235 os.popen(cmd) 236 # popen is deprecated since Python 2.6 237 # use subprocess module instead 238 239 # THIS DOES NOT WORK CORRECTLY! 240 #sends mail to /tmp/pvmail_message.txt with no message 241 #args = shlex.split(cmd) 242 #subprocess.call(args) 242 243 243 244 … … 272 273 report_time = time.time() + 5.0 273 274 logger("time remaining: %.1f seconds ..." % (end_time - time.time())) 274 275 time.sleep(retry_interval_s) 275 276 pvm.doStop() 276 277
Note: See TracChangeset
for help on using the changeset viewer.