source: orange-bioinformatics/server_update/updateAll.py @ 1717:b9f395780e75

Revision 1717:b9f395780e75, 1.8 KB checked in by markotoplak, 20 months ago (diff)

Copied server update scripts from Orange source.

RevLine 
[1717]1import sys, os
2import subprocess
3import time
4
5from getopt import getopt
6from datetime import datetime
7
8opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
9
10username = opt.get("-u", opt.get("--user", "username"))
11password = opt.get("-p", opt.get("--password", "password"))
12
13age = datetime.now() - datetime.fromtimestamp(0) ## age of the universe
14
15files = ["updateTaxonomy.py", "updateGO.py", "updateMeSH.py", "updateNCBI_geneinfo.py",
16         "updateHomoloGene.py", "updateDictyBase.py", "updatePPI.py"]
17
18for filename in files:
19    options = dict([line[3:].split("=") for line in open(filename).readlines() if line.startswith("##!")])
20    if age.days % int(options.get("interval", "7")) == 0:
21        output = open("log.txt", "w")
22        process = subprocess.Popen([sys.executable, filename, "-u", username, "-p", password], stdout=output, stderr=output)
23        while process.poll() == None:
24            time.sleep(3)
25#        print "/sw/bin/python2.5 %s -u %s -p %s" % (filename, username, password)
26#        print os.system("/sw/bin/python2.5 %s -u %s -p %s" % (filename, username, password))
27        output.close()
28        if process.poll() != 0:
29            content = open("log.txt", "r").read()
30            print content
31            toaddr = options.get("contact", "ales.erjavec@fri.uni-lj.si")
32            fromaddr = "orange@fri.uni-lj.si"
33            msg = "From: %s\r\nTo: %s\r\nSubject: Exception in server update script - %s\r\n\r\n" % (fromaddr, toaddr, filename) + content
34            try:
35                import smtplib
36                s = smtplib.SMTP('212.235.188.18', 25)
37                s.sendmail(fromaddr, toaddr, msg)
38                s.quit()
39            except Exception, ex:
40                print "Failed to send error report due to:", ex
41               
Note: See TracBrowser for help on using the repository browser.