Commits

Marko Toplak  committed 921b378

Moved common functionality of the server files update scripts to a separate file.

  • Participants
  • Parent commits 354d91b

Comments (0)

Files changed (13)

File server_update/common.py

+import Orange
+import Orange.utils.serverfiles as serverfiles
+import Orange.utils.environ as environ
+import os, sys
+import optparse
+import gzip, shutil
+
+usage="""usage: %prog [options] [update_script ...]"""
+
+parser = optparse.OptionParser(usage=usage)
+parser.add_option("-u", "--user", help="User name")
+parser.add_option("-p", "--password", help="Password")
+parser.add_option("-l", "--log-dir", dest="log_dir", help="Directory to store the logs", default="./")
+parser.add_option("-m", "--mailto", help="e-mail the results to EMAIL", metavar="EMAIL", default=None)
+
+option, args = parser.parse_args()
+
+sf_server = serverfiles.ServerFiles(option.user, option.password)
+sf_local = Orange.utils.serverfiles

File server_update/updateDictyBase.py

 ##interval:7
-import Orange.utils.serverfiles
+from common import *
+
 import sys, os
 from gzip import GzipFile
-from getopt import getopt
 import tempfile
 from Orange.bio.obiDicty import DictyBase
-import shutil
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
 
 tmpdir = tempfile.mkdtemp("dictybase")
 
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-print username, password
-
 base = DictyBase.pickle_data()
 filename = os.path.join(tmpdir, "tf")
 
 dom = DictyBase.domain
 fn = DictyBase.filename
 
-sf = Orange.utils.serverfiles.ServerFiles(username, password)
-
 try:
-    sf.create_domain('dictybase')
+    sf_server.create_domain('dictybase')
 except:
     pass
 
 print filename
 
-sf.upload(dom, fn, filename, title="dictyBase gene aliases",
+sf_server.upload(dom, fn, filename, title="dictyBase gene aliases",
     tags=DictyBase.tags)
-sf.unprotect(dom, fn)
+sf_server.unprotect(dom, fn)
 
 shutil.rmtree(tmpdir)

File server_update/updateGEO.py

 ##!contact=blaz.zupan@fri.uni-lj.si
 
 from Orange.bio import obiTaxonomy, obiGEO
-import sys
-import Orange.utils.serverfiles as orngServerFiles
-from getopt import getopt
 import cPickle
 import re
 import ftplib
 import time
 from datetime import datetime
-import os
+
+from common import *
 
 DOMAIN = "GEO"
 GDS_INFO = "gds_info.pickled"
 FTP_NCBI = "ftp.ncbi.nih.gov"
 NCBI_DIR = "pub/geo/DATA/SOFT/GDS"
 
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-server = orngServerFiles.ServerFiles(username, password)
-
 force_update = False
 # check if the DOMAIN/files are already on the server, else, create
-if DOMAIN not in server.listdomains():
+if DOMAIN not in sf_server.listdomains():
     # DOMAIN does not exist on the server, create it
-    server.create_domain(DOMAIN)
+    sf_server.create_domain(DOMAIN)
 
-localfile = orngServerFiles.localpath(DOMAIN, GDS_INFO)
+localfile = sf_local.localpath(DOMAIN, GDS_INFO)
 
 def _create_path_for_file(target): #KEGG uses this!
     try:
     except OSError:
         pass
 
-path = orngServerFiles.localpath(DOMAIN)
-if GDS_INFO in server.listfiles(DOMAIN):
+path = sf_local.localpath(DOMAIN)
+if GDS_INFO in sf_server.listfiles(DOMAIN):
     print "Updating info file from server ..."
-    orngServerFiles.update(DOMAIN, GDS_INFO)
-    info = orngServerFiles.info(DOMAIN, GDS_INFO)
+    sf_local.update(DOMAIN, GDS_INFO)
+    info = sf_local.info(DOMAIN, GDS_INFO)
     gds_info_datetime = datetime.strptime(info["datetime"], "%Y-%m-%d %H:%M:%S.%f")
     
 else:
     f = file(localfile, "wb")
     cPickle.dump(({}, {}), f, True)
     f.close()
-    server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS)
-    server.protect(DOMAIN, GDS_INFO, "0")
+    sf_server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS)
+    sf_server.protect(DOMAIN, GDS_INFO, "0")
     gds_info_datetime = datetime.fromtimestamp(0)
     
 
     
     print "Updating %s:%s on the server ..." % (DOMAIN, GDS_INFO)
  
-    server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS)
-    server.protect(DOMAIN, GDS_INFO, "0")
+    sf_server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS)
+    sf_server.protect(DOMAIN, GDS_INFO, "0")
 else:
     print "No update required."
 

File server_update/updateGO.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+from common import *
+
 from Orange.bio import obiGO, obiTaxonomy, obiGene, obiGenomicsUpdate
 
-import Orange.utils.environ as orngEnviron
-import Orange.utils.serverfiles as orngServerFiles
-import os, sys, shutil, urllib2, tarfile
-from getopt import getopt
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
+import urllib2, tarfile
 
 from collections import defaultdict
 
-tmpDir = os.path.join(orngEnviron.buffer_dir, "tmp_GO")
+tmpDir = os.path.join(environ.buffer_dir, "tmp_GO")
 try:
     os.mkdir(tmpDir)
 except Exception:
     pass
 
-serverFiles = orngServerFiles.ServerFiles(username, password)
-
 u = obiGO.Update(local_database_path = tmpDir)
 
 uncompressedSize = lambda filename: sum(info.size for info in tarfile.open(filename).getmembers())
     del o
     ##upload the ontology
     print "Uploading gene_ontology_edit.obo.tar.gz"
-    serverFiles.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)",
+    sf_server.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)",
                        tags=["gene", "ontology", "GO", "essential", "#uncompressed:%i" % uncompressedSize(filename), "#version:%i" % obiGO.Ontology.version])
-    serverFiles.unprotect("GO", "gene_ontology_edit.obo.tar.gz")
+    sf_server.unprotect("GO", "gene_ontology_edit.obo.tar.gz")
 
 #from obiGeneMatch import _dbOrgMap
 #
         orgName = obiTaxonomy.name(commonOrgs[org])
 #            print "unknown organism name translation for:", org
         print "Uploading", "gene_association." + org + ".tar.gz"
-        serverFiles.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName,
+        sf_server.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName,
                            tags=["gene", "annotation", "ontology", "GO", orgName, "#uncompressed:%i" % uncompressedSize(filename),
                                  "#organism:"+orgName, "#version:%i" % obiGO.Annotations.version] + (["essential"] if org in essentialOrgs else []))
-        serverFiles.unprotect("GO", "gene_association." + org + ".tar.gz")
+        sf_server.unprotect("GO", "gene_association." + org + ".tar.gz")
         
 try:
     import cPickle
 #    tax = cPickle.load(open(os.path.join(tmpDir, "taxonomy.pickle"), "rb"))
-    tax = cPickle.load(open(orngServerFiles.localpath_download("GO", "taxonomy.pickle"), "rb"))
+    tax = cPickle.load(open(sf_local.localpath_download("GO", "taxonomy.pickle"), "rb"))
 except Exception:
     tax = {}
 
     tax.update(updatedTaxonomy)
     cPickle.dump(tax, open(os.path.join(tmpDir, "taxonomy.pickle"), "wb"))
     print "Uploading", "taxonomy.pickle"
-    serverFiles.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs",
+    sf_server.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs",
                        tags = ["GO", "taxon", "organism", "essential", "#version:%i" % obiGO.Taxonomy.version])
-    serverFiles.unprotect("GO", "taxonomy.pickle")
+    sf_server.unprotect("GO", "taxonomy.pickle")

File server_update/updateHomoloGene.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+from common import *
+
 from Orange.bio import obiHomoloGene
-import Orange.utils.serverfiles as orngServerFiles
 
-import Orange.utils.environ as orngEnviron
-import os, sys
-import gzip, shutil
-
-from getopt import getopt
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-path = os.path.join(orngEnviron.buffer_dir, "tmp_HomoloGene")
-serverFiles = orngServerFiles.ServerFiles(username, password)
+path = os.path.join(environ.buffer_dir, "tmp_HomoloGene")
 
 try:
     os.mkdir(path)
 shutil.copyfileobj(open(filename), f)
 f.close()
 
-#serverFiles.create_domain("HomoloGene")
+#sf_server.create_domain("HomoloGene")
 print "Uploading homologene.data"
-serverFiles.upload("HomoloGene", "homologene.data", filename + ".gz", title="HomoloGene",
+sf_server.upload("HomoloGene", "homologene.data", filename + ".gz", title="HomoloGene",
                    tags=["genes", "homologs", "HomoloGene", "#compression:gz",
                          "#uncompressed:%i" % uncompressed, 
                          "#version:%i" % obiHomoloGene.HomoloGene.VERSION])
-serverFiles.unprotect("HomoloGene", "homologene.data")
+sf_server.unprotect("HomoloGene", "homologene.data")
 
 ####
 # InParanioid Orthologs update
 gzfile.close()
 
 print "Uploading InParanoid.sqlite"
-serverFiles.upload("HomoloGene", "InParanoid.sqlite", filename + ".gz", title="InParanoid: Eukaryotic Ortholog Groups",
+sf_server.upload("HomoloGene", "InParanoid.sqlite", filename + ".gz", title="InParanoid: Eukaryotic Ortholog Groups",
                    tags=["genes", "homologs", "orthologs", "InParanoid", "#compression:gz",
                          "#uncompressed:%i" % os.stat(filename).st_size,
                          "#version:%i" % obiHomoloGene.InParanoid.VERSION])
-serverFiles.unprotect("HomoloGene", "InParanoid.sqlite")
+sf_server.unprotect("HomoloGene", "InParanoid.sqlite")
         
         
             

File server_update/updateMeSH.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+from common import *
 from urllib import urlopen
-import Orange.utils.serverfiles as orngServerFiles
-import os, sys
-
-from getopt import getopt
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
 
 ontology = urlopen("ftp://nlmpubs.nlm.nih.gov/online/mesh/.asciimesh/d2012.bin")
 size = int(ontology.info().getheader("Content-Length"))
 output.close()
 print "Ontology downloaded."
 
-
-
-
-ordinary = orngServerFiles.ServerFiles()
-authenticated = orngServerFiles.ServerFiles(username, password)
-
-authenticated.upload('MeSH', 'mesh-ontology.dat', 'mesh-ontology.dat', title="MeSH ontology", tags=['MeSH', 'ontology', 'orngMeSH'])
+sf_server.upload('MeSH', 'mesh-ontology.dat', 'mesh-ontology.dat', title="MeSH ontology", tags=['MeSH', 'ontology', 'orngMeSH'])
 #authenticated.upload('MeSH', 'cid-annotation.dat', 'cid-annotation.dat', title="Annotation for chemicals (CIDs)", tags =['CID','MeSH','orngMeSH','annotation'])
 
-authenticated.unprotect('MeSH', 'mesh-ontology.dat')
+sf_server.unprotect('MeSH', 'mesh-ontology.dat')
 os.remove('mesh-ontology.dat')
 print "Ontology uploaded to server."

File server_update/updateNCBI_geneinfo.py

 ##interval:7
+from common import *
 from Orange.bio import obiGene, obiTaxonomy
-import Orange.utils.serverfiles as orngServerFiles
-import Orange.utils.environ as orngEnviron
-import sys, os
 from gzip import GzipFile
-from getopt import getopt
 
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-tmpdir = os.path.join(orngEnviron.buffer_dir, "tmp_NCBIGene_info")
+tmpdir = os.path.join(environ.buffer_dir, "tmp_NCBIGene_info")
 try:
     os.mkdir(tmpdir)
 except Exception, ex:
     pass
 
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
 gene_info_filename = os.path.join(tmpdir, "gene_info")
 gene_history_filename = os.path.join(tmpdir, "gene_history")
 
     if any(hi.startswith(id + "\t") for id in taxids): 
         history[hi.split("\t", 1)[0]].append(hi.strip())
 
-        
-sf = orngServerFiles.ServerFiles(username, password)
-
 for taxid, genes in genes.items():
     filename = os.path.join(tmpdir, "gene_info.%s.db" % taxid)
     f = open(filename, "wb")
     f.flush()
     f.close()
     print "Uploading", filename
-    sf.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename,
+    sf_server.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename,
               title = "NCBI gene info for %s" % obiTaxonomy.name(taxid),
               tags = ["NCBI", "gene info", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else []))
-    sf.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid)
+    sf_server.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid)
     
     filename = os.path.join(tmpdir, "gene_history.%s.db" % taxid)
     f = open(filename, "wb")
     f.flush()
     f.close()
     print "Uploading", filename
-    sf.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename,
+    sf_server.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename,
               title = "NCBI gene history for %s" % obiTaxonomy.name(taxid),
               tags = ["NCBI", "gene info", "history", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else []))
-    sf.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid)
+    sf_server.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid)

File server_update/updateOMIM.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+from common import *
 from Orange.bio import obiOMIM
-import Orange.utils.serverfiles as orngServerFiles
 
-import orngEnviron
 import os, sys
 
-from getopt import getopt
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-path = os.path.join(orngEnviron.bufferDir, "tmp_OMIM")
-serverFiles = orngServerFiles.ServerFiles(username, password)
+path = os.path.join(environ.buffer_dir, "tmp_OMIM")
 
 try:
     os.mkdir(path)
 filename = os.path.join(path, "morbidmap")
 obiOMIM.OMIM.download_from_NCBI(filename)
 
-serverFiles.upload("OMIM", "morbidmap", filename, title="Online Mendelian Inheritance in Man (OMIM)",
+sf_server.upload("OMIM", "morbidmap", filename, title="Online Mendelian Inheritance in Man (OMIM)",
                    tags=["genes", "diseases", "human", "OMIM" "#version:%i" % obiOMIM.OMIM.VERSION])
-serverFiles.unprotect("OMIM", "morbidmap")
+sf_server.unprotect("OMIM", "morbidmap")

File server_update/updatePPI.py

 ##!contact=ales.erjavec@fri.uni-lj.si
 
 from Orange.bio import obiPPI
-import Orange.utils.serverfiles as orngServerFiles
-import os, sys, shutil, urllib2, tarfile
-from getopt import getopt
+import urllib2, tarfile
 
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-serverFiles = orngServerFiles.ServerFiles(username, password)
+from common import *
 
 try:
-    os.mkdir(orngServerFiles.localpath("PPI"))
+    os.mkdir(sf_local.localpath("PPI"))
 except OSError:
     pass
 
 try:
-    serverFiles.create_domain("PPI")
+    sf_server.create_domain("PPI")
 except Exception, ex:
     print ex
 
 if True:
     obiPPI.MIPS.download()
 
-    filename = orngServerFiles.localpath("PPI", "mppi.gz")
-    serverFiles.upload("PPI", "allppis.xml", filename, "MIPS Protein interactions",
+    filename = sf_local.localpath("PPI", "mppi.gz")
+    sf_server.upload("PPI", "allppis.xml", filename, "MIPS Protein interactions",
                        tags=["protein interaction", "MIPS", "#compression:gz", "#version:%i" % obiPPI.MIPS.VERSION]
                        )
-    serverFiles.unprotect("PPI", "allppis.xml") 
+    sf_server.unprotect("PPI", "allppis.xml") 
 
 if True:
     obiPPI.BioGRID.download_data("http://thebiogrid.org/downloads/archives/Release%20Archive/BIOGRID-3.1.91/BIOGRID-ALL-3.1.91.tab2.zip") #replace with the newest version
 
     sfn = obiPPI.BioGRID.SERVER_FILE
 
-    filename = orngServerFiles.localpath("PPI", sfn)
+    filename = sf_local.localpath("PPI", sfn)
 
     import gzip
     gz = gzip.GzipFile(filename + ".gz", "wb")
     gz.write(open(filename, "rb").read())
     gz.close()
 
-    serverFiles.upload("PPI", sfn, filename + ".gz", 
+    sf_server.upload("PPI", sfn, filename + ".gz", 
         title="BioGRID Protein interactions", 
         tags=["protein interaction", "BioGrid", "#compression:gz", "#version:%s" % obiPPI.BioGRID.VERSION]
         )
-    serverFiles.unprotect("PPI", sfn)
+    sf_server.unprotect("PPI", sfn)
 

File server_update/updateSTRING.py

 ##!contact=ales.erjavec@fri.uni-lj.si
 
 from Orange.bio import obiPPI
-import Orange.utils.serverfiles as orngServerFiles
-import os, sys, shutil, urllib2, gzip
-from getopt import getopt
+import urllib2, gzip
 
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
+from common import *
 
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-serverFiles = orngServerFiles.ServerFiles(username, password)
-
-filename = orngServerFiles.localpath("PPI", obiPPI.STRING.FILENAME)
+filename = sf_local.localpath("PPI", obiPPI.STRING.FILENAME)
 
 if False:
     if os.path.exists(filename):
     gzfile = gzip.GzipFile(filename + ".gz", "wb")
     shutil.copyfileobj(open(filename, "rb"), gzfile)
 
-    serverFiles.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz", 
+    sf_server.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz", 
                        "STRING Protein interactions (Creative Commons Attribution 3.0 License)",
                        tags=["protein interaction", "STRING", 
                              "#compression:gz", "#version:%s" % obiPPI.STRING.VERSION]
                        )
-    serverFiles.unprotect("PPI", obiPPI.STRING.FILENAME)
+    sf_server.unprotect("PPI", obiPPI.STRING.FILENAME)
 
 # The second part
-filename = orngServerFiles.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
+filename = sf_local.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
 
 if os.path.exists(filename):
     os.remove(filename)
 gzfile = gzip.GzipFile(filename + ".gz", "wb")
 shutil.copyfileobj(open(filename, "rb"), gzfile)
 
-serverFiles.upload("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED, filename + ".gz", 
+sf_server.upload("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED, filename + ".gz", 
                    "STRING Protein interactions (Creative Commons Attribution-Noncommercial-Share Alike 3.0 License)" ,
                    tags=["protein interaction", "STRING",
                          "#compression:gz", "#version:%s" % obiPPI.STRINGDetailed.VERSION]
                    )
-serverFiles.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
+sf_server.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED)
     

File server_update/updateTaxonomy.py

 ##!interval=7
 ##!contact=ales.erjavec@fri.uni-lj.si
 
+from common import *
+
 from Orange.bio import obiTaxonomy
 import Orange.utils.serverfiles as orngServerFiles
 import Orange.utils.environ
 
-import os, sys, tarfile
+import tarfile
 import socket
 
-from getopt import getopt
-
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-path = os.path.join(Orange.utils.environ.buffer_dir, "tmp_Taxonomy")
-serverFiles = orngServerFiles.ServerFiles(username, password)
+path = os.path.join(environ.buffer_dir, "tmp_Taxonomy")
 u = obiTaxonomy.Update(local_database_path=path)
 
 uncompressedSize = lambda filename: sum(info.size for info in tarfile.open(filename).getmembers())
         except socket.timeout, ex:
             print ex
             pass
-    serverFiles.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy",
+    sf_server.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy",
                        tags=["NCBI", "taxonomy", "organism names", "essential", "#uncompressed:%i" % uncompressedSize(os.path.join(path, "ncbi_taxonomy.tar.gz"))])
-    serverFiles.unprotect("Taxonomy", "ncbi_taxonomy.tar.gz")
+    sf_server.unprotect("Taxonomy", "ncbi_taxonomy.tar.gz")

File server_update/updatemiRNA.py

+
+from common import *
 
 import urllib
 import re
-import pylab
-import random
-import os
-import math
-import locale
-import gzip
 import StringIO
-import sys
-from getopt import getopt
 import zipfile
 
 import Orange.bio.obiTaxonomy as tax
-import Orange.utils.serverfiles as orngServerFiles
-import Orange.utils.environ as orngEnviron
 
 def fastprint(filename,mode,what):
     
     
 
 def sendMail(subject):
-    
-    print "MAIL", subject
-    toaddr = "rsberex@yahoo.it"
-    fromaddr = "orange@fri.uni-lj.si";
-    msg = "From: %s\r\nTo: %s\r\nSubject: %s" % (fromaddr, toaddr, subject)
-    try:
-        import smtplib
-        s = smtplib.SMTP('212.235.188.18', 25)
-        s.sendmail(fromaddr, toaddr, msg)
-        s.quit()
-    except Exception, ex:
-        print "Failed to send error report due to:", ex
-
+    print "SHOULD MAIL:", subject
         
 def format_checker(content):
     
 ##############################################################################################################################################################
 ##############################################################################################################################################################
 
-opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
-
-username = opt.get("-u", opt.get("--user", "username"))
-password = opt.get("-p", opt.get("--password", "password"))
-
-path = os.path.join(orngEnviron.buffer_dir, "tmp_miRNA")
+path = os.path.join(environ.buffer_dir, "tmp_miRNA")
 print 'path: ', path
 
-serverFiles = orngServerFiles.ServerFiles(username, password)
+serverFiles = sf_server
 
 try:
     os.mkdir(path)
 except OSError:
     pass
 
-
 org_taxo = [tax.name(id) for id in tax.common_taxids()]
 
 ### targets library from TargetScan
 else:
     print "Check the address of miRNA file on %s" % address
 
-                
-            
-
-
-
-   

File server_update/updater.py

-import sys, os
 import subprocess
 import time, glob
-import optparse
 
-from getopt import getopt
 from datetime import datetime
 
-usage="""usage: %prog [options] [update_script ...]
-
-Run update scripts"""
-
-parser = optparse.OptionParser(usage=usage)
-parser.add_option("-u", "--user", help="User name")
-parser.add_option("-p", "--password", help="Password")
-parser.add_option("-l", "--log-dir", dest="log_dir", help="Directory to store the logs", default="./")
-parser.add_option("-m", "--mailto", help="e-mail the results to EMAIL", metavar="EMAIL", default=None)
-
-option, args = parser.parse_args()
+from common import *
 
 if not args:
     args = ["updateTaxonomy.py", "updateGO.py", "updateMeSH.py", "updateNCBI_geneinfo.py",
     
 
 def files_report():
-  import orngServerFiles as sf
-  sf = sf.ServerFiles()
-  html = []
-  for domain in sf.listdomains():
-      if domain not in ["demo", "demo2", "test", "gad"]:
-          allinfo = sf.allinfo(domain)
-          html += ["<h2>%s</h2>" % domain,
-                   "<table><tr><th>Title</th><th>Date</th><th>Filename</th></tr>"] + \
-                  ["<tr><td>%s</td><td>%s</td><td>%s</td></tr>" % (info["title"], info["datetime"], file) \
-                   for file, info in allinfo.items()] + \
-                  ["</table>"]
-  return "\n".join(html)
+    sf = serverfiles.ServerFiles()
+    html = []
+    for domain in sf.listdomains():
+        if domain not in ["demo", "demo2", "test", "gad"]:
+            allinfo = sf.allinfo(domain)
+            html += ["<h2>%s</h2>" % domain,
+                     "<table><tr><th>Title</th><th>Date</th><th>Filename</th></tr>"] + \
+                    ["<tr><td>%s</td><td>%s</td><td>%s</td></tr>" % (info["title"], info["datetime"], file) \
+                     for file, info in allinfo.items()] + \
+                    ["</table>"]
+    return "\n".join(html)
   
 open(os.path.join(option.log_dir, "serverFiles.html"), "wb").write(files_report())