-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
46 lines (36 loc) · 1.3 KB
/
run.py
File metadata and controls
46 lines (36 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!flask/bin/python
import sys
import subprocess
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from app import app
print "looking if circos is running properly"
cmd = 'circos'
o,e = subprocess.Popen(cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()
# Not enough if celery and run.py are launched from different terminal.
# Circos need to be found by celery // not a problem if one uses run.sh
error_string_en = 'ommand not found'
error_string_fr = 'ommande introuvable'
if error_string_en in o or error_string_en in e or error_string_fr in o or error_string_fr in e:
print 'Command not found',
print str(o)
print str(e)
no_reply = 'mycircos@iric.ca'
user = 'mycircos@iric.ca'
msg = MIMEMultipart()
msg['Subject'] = 'ERROR'
msg['From'] = no_reply
msg['To'] = 'Admin'
message = 'An error occured while lauching myCircos and the app is currently not running. \n %s \n %s' % (str(o), str(e))
msg.attach(MIMEText(message, 'plain'))
try:
s = smtplib.SMTP('localhost')
s.sendmail(no_reply, [user], msg.as_string())
s.quit()
print 'Email successfully sent'
except Exception, e:
print 'Error: unable to send email to ' + user
print e
sys.exit(0)
app.run(debug = True, host='0.0.0.0', port=8081)