lb
HCQ script.
#!/usr/local/bin/python2.7
import sys, os, os.path, time, string, shell_command, re, ConfigParser, logging, datetime, smtplib, cv2
from email.mime.text import MIMEText
from logging import handlers
from logging import basicConfig
from logging.handlers import SysLogHandler
from shell_command import shell_output
so = shell_output
from shell_command import shell_call
sc = shell_call
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
syslog = SysLogHandler(address='/dev/log',facility=SysLogHandler.LOG_LOCAL0)
#logger.basicConfig(format='%(asctime) s %(message) s')
formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
syslog.setFormatter(formatter)
logger.addHandler(syslog)
def fSendAlert(pharm, pharmmail, msg, sender):
ts = datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p")
logger.debug('Script Request %s %s %s' % (ts, pharm, pharmmail))
tfile = "/tmp/zSendAlert"
wr = open(tfile, "w")
wr.write("%s fill script\n %s" % (pharm, msg))
wr.close()
r = open(tfile, 'rb')
msg = MIMEText(r.read())
r.close()
sndr = "mailserver.com"
rcpt = "%s" % (pharmail)
msg['Subject'] = 'Refil Request-%s' % (sender)
msg['From'] = sndr
msg['To'] = rcpt
shoot = smtplib.SMTP('mail.mailserver.com')
shoot.sendmail(sndr, [rcpt], msg.as_string())
shoot.quit()
return()
sender = ( raw_input("Enter your name : ")
pharm = ( raw_input("Enter pharmacy name : ")
rmsg = (raw_input("Enter script image location: ")
try:
so = ('ls %s' % rmsg)
if so = 0:
msg = = cv2.imread('%s' % rmsg)
break
else:
print ('Please use proper file location. %s not found.' % rmsg)
sys.exit(1)
except:
print ('Please use proper file location. %s not found.' % rmsg)
sys.exit(1)
pharmmail = (raw_input("Enter Pharmacy email: ")
fSendAlert(pharm, pharmmail, msg, sender)
sys.exit(0)