Changeset 1721:921b3780c6cc in orange-bioinformatics


Ignore:
Timestamp:
09/14/12 12:20:53 (19 months ago)
Author:
markotoplak
Branch:
default
Message:

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

Location:
server_update
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • server_update/updateDictyBase.py

    r1718 r1721  
    11##interval:7 
    2 import Orange.utils.serverfiles 
     2from common import * 
     3 
    34import sys, os 
    45from gzip import GzipFile 
    5 from getopt import getopt 
    66import tempfile 
    77from Orange.bio.obiDicty import DictyBase 
    8 import shutil 
    9  
    10 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    118 
    129tmpdir = tempfile.mkdtemp("dictybase") 
    13  
    14 username = opt.get("-u", opt.get("--user", "username")) 
    15 password = opt.get("-p", opt.get("--password", "password")) 
    16  
    17 print username, password 
    1810 
    1911base = DictyBase.pickle_data() 
     
    2719fn = DictyBase.filename 
    2820 
    29 sf = Orange.utils.serverfiles.ServerFiles(username, password) 
    30  
    3121try: 
    32     sf.create_domain('dictybase') 
     22    sf_server.create_domain('dictybase') 
    3323except: 
    3424    pass 
     
    3626print filename 
    3727 
    38 sf.upload(dom, fn, filename, title="dictyBase gene aliases", 
     28sf_server.upload(dom, fn, filename, title="dictyBase gene aliases", 
    3929    tags=DictyBase.tags) 
    40 sf.unprotect(dom, fn) 
     30sf_server.unprotect(dom, fn) 
    4131 
    4232shutil.rmtree(tmpdir) 
  • server_update/updateGEO.py

    r1718 r1721  
    33 
    44from Orange.bio import obiTaxonomy, obiGEO 
    5 import sys 
    6 import Orange.utils.serverfiles as orngServerFiles 
    7 from getopt import getopt 
    85import cPickle 
    96import re 
     
    118import time 
    129from datetime import datetime 
    13 import os 
     10 
     11from common import * 
    1412 
    1513DOMAIN = "GEO" 
     
    2119NCBI_DIR = "pub/geo/DATA/SOFT/GDS" 
    2220 
    23 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    24 username = opt.get("-u", opt.get("--user", "username")) 
    25 password = opt.get("-p", opt.get("--password", "password")) 
    26 server = orngServerFiles.ServerFiles(username, password) 
    27  
    2821force_update = False 
    2922# check if the DOMAIN/files are already on the server, else, create 
    30 if DOMAIN not in server.listdomains(): 
     23if DOMAIN not in sf_server.listdomains(): 
    3124    # DOMAIN does not exist on the server, create it 
    32     server.create_domain(DOMAIN) 
     25    sf_server.create_domain(DOMAIN) 
    3326 
    34 localfile = orngServerFiles.localpath(DOMAIN, GDS_INFO) 
     27localfile = sf_local.localpath(DOMAIN, GDS_INFO) 
    3528 
    3629def _create_path_for_file(target): #KEGG uses this! 
     
    4033        pass 
    4134 
    42 path = orngServerFiles.localpath(DOMAIN) 
    43 if GDS_INFO in server.listfiles(DOMAIN): 
     35path = sf_local.localpath(DOMAIN) 
     36if GDS_INFO in sf_server.listfiles(DOMAIN): 
    4437    print "Updating info file from server ..." 
    45     orngServerFiles.update(DOMAIN, GDS_INFO) 
    46     info = orngServerFiles.info(DOMAIN, GDS_INFO) 
     38    sf_local.update(DOMAIN, GDS_INFO) 
     39    info = sf_local.info(DOMAIN, GDS_INFO) 
    4740    gds_info_datetime = datetime.strptime(info["datetime"], "%Y-%m-%d %H:%M:%S.%f") 
    4841     
     
    5346    cPickle.dump(({}, {}), f, True) 
    5447    f.close() 
    55     server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS) 
    56     server.protect(DOMAIN, GDS_INFO, "0") 
     48    sf_server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS) 
     49    sf_server.protect(DOMAIN, GDS_INFO, "0") 
    5750    gds_info_datetime = datetime.fromtimestamp(0) 
    5851     
     
    129122    print "Updating %s:%s on the server ..." % (DOMAIN, GDS_INFO) 
    130123  
    131     server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS) 
    132     server.protect(DOMAIN, GDS_INFO, "0") 
     124    sf_server.upload(DOMAIN, GDS_INFO, localfile, TITLE, TAGS) 
     125    sf_server.protect(DOMAIN, GDS_INFO, "0") 
    133126else: 
    134127    print "No update required." 
  • server_update/updateGO.py

    r1719 r1721  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
     4from common import * 
     5 
    46from Orange.bio import obiGO, obiTaxonomy, obiGene, obiGenomicsUpdate 
    57 
    6 import Orange.utils.environ as orngEnviron 
    7 import Orange.utils.serverfiles as orngServerFiles 
    8 import os, sys, shutil, urllib2, tarfile 
    9 from getopt import getopt 
    10  
    11 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    12  
    13 username = opt.get("-u", opt.get("--user", "username")) 
    14 password = opt.get("-p", opt.get("--password", "password")) 
     8import urllib2, tarfile 
    159 
    1610from collections import defaultdict 
    1711 
    18 tmpDir = os.path.join(orngEnviron.buffer_dir, "tmp_GO") 
     12tmpDir = os.path.join(environ.buffer_dir, "tmp_GO") 
    1913try: 
    2014    os.mkdir(tmpDir) 
    2115except Exception: 
    2216    pass 
    23  
    24 serverFiles = orngServerFiles.ServerFiles(username, password) 
    2517 
    2618u = obiGO.Update(local_database_path = tmpDir) 
     
    3830    ##upload the ontology 
    3931    print "Uploading gene_ontology_edit.obo.tar.gz" 
    40     serverFiles.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)", 
     32    sf_server.upload("GO", "gene_ontology_edit.obo.tar.gz", filename, title = "Gene Ontology (GO)", 
    4133                       tags=["gene", "ontology", "GO", "essential", "#uncompressed:%i" % uncompressedSize(filename), "#version:%i" % obiGO.Ontology.version]) 
    42     serverFiles.unprotect("GO", "gene_ontology_edit.obo.tar.gz") 
     34    sf_server.unprotect("GO", "gene_ontology_edit.obo.tar.gz") 
    4335 
    4436#from obiGeneMatch import _dbOrgMap 
     
    8678#            print "unknown organism name translation for:", org 
    8779        print "Uploading", "gene_association." + org + ".tar.gz" 
    88         serverFiles.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName, 
     80        sf_server.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName, 
    8981                           tags=["gene", "annotation", "ontology", "GO", orgName, "#uncompressed:%i" % uncompressedSize(filename), 
    9082                                 "#organism:"+orgName, "#version:%i" % obiGO.Annotations.version] + (["essential"] if org in essentialOrgs else [])) 
    91         serverFiles.unprotect("GO", "gene_association." + org + ".tar.gz") 
     83        sf_server.unprotect("GO", "gene_association." + org + ".tar.gz") 
    9284         
    9385try: 
    9486    import cPickle 
    9587#    tax = cPickle.load(open(os.path.join(tmpDir, "taxonomy.pickle"), "rb")) 
    96     tax = cPickle.load(open(orngServerFiles.localpath_download("GO", "taxonomy.pickle"), "rb")) 
     88    tax = cPickle.load(open(sf_local.localpath_download("GO", "taxonomy.pickle"), "rb")) 
    9789except Exception: 
    9890    tax = {} 
     
    10395    cPickle.dump(tax, open(os.path.join(tmpDir, "taxonomy.pickle"), "wb")) 
    10496    print "Uploading", "taxonomy.pickle" 
    105     serverFiles.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs", 
     97    sf_server.upload("GO", "taxonomy.pickle", os.path.join(tmpDir, "taxonomy.pickle"), title="GO taxon IDs", 
    10698                       tags = ["GO", "taxon", "organism", "essential", "#version:%i" % obiGO.Taxonomy.version]) 
    107     serverFiles.unprotect("GO", "taxonomy.pickle") 
     99    sf_server.unprotect("GO", "taxonomy.pickle") 
  • server_update/updateHomoloGene.py

    r1719 r1721  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
     4from common import * 
     5 
    46from Orange.bio import obiHomoloGene 
    5 import Orange.utils.serverfiles as orngServerFiles 
    67 
    7 import Orange.utils.environ as orngEnviron 
    8 import os, sys 
    9 import gzip, shutil 
    10  
    11 from getopt import getopt 
    12  
    13 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    14  
    15 username = opt.get("-u", opt.get("--user", "username")) 
    16 password = opt.get("-p", opt.get("--password", "password")) 
    17  
    18 path = os.path.join(orngEnviron.buffer_dir, "tmp_HomoloGene") 
    19 serverFiles = orngServerFiles.ServerFiles(username, password) 
     8path = os.path.join(environ.buffer_dir, "tmp_HomoloGene") 
    209 
    2110try: 
     
    3120f.close() 
    3221 
    33 #serverFiles.create_domain("HomoloGene") 
     22#sf_server.create_domain("HomoloGene") 
    3423print "Uploading homologene.data" 
    35 serverFiles.upload("HomoloGene", "homologene.data", filename + ".gz", title="HomoloGene", 
     24sf_server.upload("HomoloGene", "homologene.data", filename + ".gz", title="HomoloGene", 
    3625                   tags=["genes", "homologs", "HomoloGene", "#compression:gz", 
    3726                         "#uncompressed:%i" % uncompressed,  
    3827                         "#version:%i" % obiHomoloGene.HomoloGene.VERSION]) 
    39 serverFiles.unprotect("HomoloGene", "homologene.data") 
     28sf_server.unprotect("HomoloGene", "homologene.data") 
    4029 
    4130#### 
     
    117106 
    118107print "Uploading InParanoid.sqlite" 
    119 serverFiles.upload("HomoloGene", "InParanoid.sqlite", filename + ".gz", title="InParanoid: Eukaryotic Ortholog Groups", 
     108sf_server.upload("HomoloGene", "InParanoid.sqlite", filename + ".gz", title="InParanoid: Eukaryotic Ortholog Groups", 
    120109                   tags=["genes", "homologs", "orthologs", "InParanoid", "#compression:gz", 
    121110                         "#uncompressed:%i" % os.stat(filename).st_size, 
    122111                         "#version:%i" % obiHomoloGene.InParanoid.VERSION]) 
    123 serverFiles.unprotect("HomoloGene", "InParanoid.sqlite") 
     112sf_server.unprotect("HomoloGene", "InParanoid.sqlite") 
    124113         
    125114         
  • server_update/updateMeSH.py

    r1719 r1721  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
     4from common import * 
    45from urllib import urlopen 
    5 import Orange.utils.serverfiles as orngServerFiles 
    6 import os, sys 
    7  
    8 from getopt import getopt 
    9  
    10 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    11  
    12 username = opt.get("-u", opt.get("--user", "username")) 
    13 password = opt.get("-p", opt.get("--password", "password")) 
    14  
    156 
    167ontology = urlopen("ftp://nlmpubs.nlm.nih.gov/online/mesh/.asciimesh/d2012.bin") 
     
    5243print "Ontology downloaded." 
    5344 
    54  
    55  
    56  
    57 ordinary = orngServerFiles.ServerFiles() 
    58 authenticated = orngServerFiles.ServerFiles(username, password) 
    59  
    60 authenticated.upload('MeSH', 'mesh-ontology.dat', 'mesh-ontology.dat', title="MeSH ontology", tags=['MeSH', 'ontology', 'orngMeSH']) 
     45sf_server.upload('MeSH', 'mesh-ontology.dat', 'mesh-ontology.dat', title="MeSH ontology", tags=['MeSH', 'ontology', 'orngMeSH']) 
    6146#authenticated.upload('MeSH', 'cid-annotation.dat', 'cid-annotation.dat', title="Annotation for chemicals (CIDs)", tags =['CID','MeSH','orngMeSH','annotation']) 
    6247 
    63 authenticated.unprotect('MeSH', 'mesh-ontology.dat') 
     48sf_server.unprotect('MeSH', 'mesh-ontology.dat') 
    6449os.remove('mesh-ontology.dat') 
    6550print "Ontology uploaded to server." 
  • server_update/updateNCBI_geneinfo.py

    r1719 r1721  
    11##interval:7 
     2from common import * 
    23from Orange.bio import obiGene, obiTaxonomy 
    3 import Orange.utils.serverfiles as orngServerFiles 
    4 import Orange.utils.environ as orngEnviron 
    5 import sys, os 
    64from gzip import GzipFile 
    7 from getopt import getopt 
    85 
    9 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    10  
    11 tmpdir = os.path.join(orngEnviron.buffer_dir, "tmp_NCBIGene_info") 
     6tmpdir = os.path.join(environ.buffer_dir, "tmp_NCBIGene_info") 
    127try: 
    138    os.mkdir(tmpdir) 
    149except Exception, ex: 
    1510    pass 
    16  
    17 username = opt.get("-u", opt.get("--user", "username")) 
    18 password = opt.get("-p", opt.get("--password", "password")) 
    1911 
    2012gene_info_filename = os.path.join(tmpdir, "gene_info") 
     
    4032        history[hi.split("\t", 1)[0]].append(hi.strip()) 
    4133 
    42          
    43 sf = orngServerFiles.ServerFiles(username, password) 
    44  
    4534for taxid, genes in genes.items(): 
    4635    filename = os.path.join(tmpdir, "gene_info.%s.db" % taxid) 
     
    5039    f.close() 
    5140    print "Uploading", filename 
    52     sf.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename, 
     41    sf_server.upload("NCBI_geneinfo", "gene_info.%s.db" % taxid, filename, 
    5342              title = "NCBI gene info for %s" % obiTaxonomy.name(taxid), 
    5443              tags = ["NCBI", "gene info", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else [])) 
    55     sf.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid) 
     44    sf_server.unprotect("NCBI_geneinfo", "gene_info.%s.db" % taxid) 
    5645     
    5746    filename = os.path.join(tmpdir, "gene_history.%s.db" % taxid) 
     
    6150    f.close() 
    6251    print "Uploading", filename 
    63     sf.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename, 
     52    sf_server.upload("NCBI_geneinfo", "gene_history.%s.db" % taxid, filename, 
    6453              title = "NCBI gene history for %s" % obiTaxonomy.name(taxid), 
    6554              tags = ["NCBI", "gene info", "history", "gene_names", obiTaxonomy.name(taxid)] + (["essential"] if taxid in essential else [])) 
    66     sf.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid) 
     55    sf_server.unprotect("NCBI_geneinfo", "gene_history.%s.db" % taxid) 
  • server_update/updateOMIM.py

    r1719 r1721  
    22##!contact=ales.erjavec@fri.uni-lj.si 
    33 
     4from common import * 
    45from Orange.bio import obiOMIM 
    5 import Orange.utils.serverfiles as orngServerFiles 
    66 
    7 import orngEnviron 
    87import os, sys 
    98 
    10 from getopt import getopt 
    11  
    12 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    13  
    14 username = opt.get("-u", opt.get("--user", "username")) 
    15 password = opt.get("-p", opt.get("--password", "password")) 
    16  
    17 path = os.path.join(orngEnviron.bufferDir, "tmp_OMIM") 
    18 serverFiles = orngServerFiles.ServerFiles(username, password) 
     9path = os.path.join(environ.buffer_dir, "tmp_OMIM") 
    1910 
    2011try: 
     
    2516obiOMIM.OMIM.download_from_NCBI(filename) 
    2617 
    27 serverFiles.upload("OMIM", "morbidmap", filename, title="Online Mendelian Inheritance in Man (OMIM)", 
     18sf_server.upload("OMIM", "morbidmap", filename, title="Online Mendelian Inheritance in Man (OMIM)", 
    2819                   tags=["genes", "diseases", "human", "OMIM" "#version:%i" % obiOMIM.OMIM.VERSION]) 
    29 serverFiles.unprotect("OMIM", "morbidmap") 
     20sf_server.unprotect("OMIM", "morbidmap") 
  • server_update/updatePPI.py

    r1719 r1721  
    33 
    44from Orange.bio import obiPPI 
    5 import Orange.utils.serverfiles as orngServerFiles 
    6 import os, sys, shutil, urllib2, tarfile 
    7 from getopt import getopt 
     5import urllib2, tarfile 
    86 
    9 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    10  
    11 username = opt.get("-u", opt.get("--user", "username")) 
    12 password = opt.get("-p", opt.get("--password", "password")) 
    13  
    14 serverFiles = orngServerFiles.ServerFiles(username, password) 
     7from common import * 
    158 
    169try: 
    17     os.mkdir(orngServerFiles.localpath("PPI")) 
     10    os.mkdir(sf_local.localpath("PPI")) 
    1811except OSError: 
    1912    pass 
    2013 
    2114try: 
    22     serverFiles.create_domain("PPI") 
     15    sf_server.create_domain("PPI") 
    2316except Exception, ex: 
    2417    print ex 
     
    2720    obiPPI.MIPS.download() 
    2821 
    29     filename = orngServerFiles.localpath("PPI", "mppi.gz") 
    30     serverFiles.upload("PPI", "allppis.xml", filename, "MIPS Protein interactions", 
     22    filename = sf_local.localpath("PPI", "mppi.gz") 
     23    sf_server.upload("PPI", "allppis.xml", filename, "MIPS Protein interactions", 
    3124                       tags=["protein interaction", "MIPS", "#compression:gz", "#version:%i" % obiPPI.MIPS.VERSION] 
    3225                       ) 
    33     serverFiles.unprotect("PPI", "allppis.xml")  
     26    sf_server.unprotect("PPI", "allppis.xml")  
    3427 
    3528if True: 
     
    3831    sfn = obiPPI.BioGRID.SERVER_FILE 
    3932 
    40     filename = orngServerFiles.localpath("PPI", sfn) 
     33    filename = sf_local.localpath("PPI", sfn) 
    4134 
    4235    import gzip 
     
    4538    gz.close() 
    4639 
    47     serverFiles.upload("PPI", sfn, filename + ".gz",  
     40    sf_server.upload("PPI", sfn, filename + ".gz",  
    4841        title="BioGRID Protein interactions",  
    4942        tags=["protein interaction", "BioGrid", "#compression:gz", "#version:%s" % obiPPI.BioGRID.VERSION] 
    5043        ) 
    51     serverFiles.unprotect("PPI", sfn) 
     44    sf_server.unprotect("PPI", sfn) 
    5245 
  • server_update/updateSTRING.py

    r1720 r1721  
    33 
    44from Orange.bio import obiPPI 
    5 import Orange.utils.serverfiles as orngServerFiles 
    6 import os, sys, shutil, urllib2, gzip 
    7 from getopt import getopt 
     5import urllib2, gzip 
    86 
    9 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
     7from common import * 
    108 
    11 username = opt.get("-u", opt.get("--user", "username")) 
    12 password = opt.get("-p", opt.get("--password", "password")) 
    13  
    14 serverFiles = orngServerFiles.ServerFiles(username, password) 
    15  
    16 filename = orngServerFiles.localpath("PPI", obiPPI.STRING.FILENAME) 
     9filename = sf_local.localpath("PPI", obiPPI.STRING.FILENAME) 
    1710 
    1811if False: 
     
    2518    shutil.copyfileobj(open(filename, "rb"), gzfile) 
    2619 
    27     serverFiles.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz",  
     20    sf_server.upload("PPI", obiPPI.STRING.FILENAME, filename + ".gz",  
    2821                       "STRING Protein interactions (Creative Commons Attribution 3.0 License)", 
    2922                       tags=["protein interaction", "STRING",  
    3023                             "#compression:gz", "#version:%s" % obiPPI.STRING.VERSION] 
    3124                       ) 
    32     serverFiles.unprotect("PPI", obiPPI.STRING.FILENAME) 
     25    sf_server.unprotect("PPI", obiPPI.STRING.FILENAME) 
    3326 
    3427# The second part 
    35 filename = orngServerFiles.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
     28filename = sf_local.localpath("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
    3629 
    3730if os.path.exists(filename): 
     
    4336shutil.copyfileobj(open(filename, "rb"), gzfile) 
    4437 
    45 serverFiles.upload("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED, filename + ".gz",  
     38sf_server.upload("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED, filename + ".gz",  
    4639                   "STRING Protein interactions (Creative Commons Attribution-Noncommercial-Share Alike 3.0 License)" , 
    4740                   tags=["protein interaction", "STRING", 
    4841                         "#compression:gz", "#version:%s" % obiPPI.STRINGDetailed.VERSION] 
    4942                   ) 
    50 serverFiles.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
     43sf_server.unprotect("PPI", obiPPI.STRINGDetailed.FILENAME_DETAILED) 
    5144     
  • server_update/updateTaxonomy.py

    r1720 r1721  
    11##!interval=7 
    22##!contact=ales.erjavec@fri.uni-lj.si 
     3 
     4from common import * 
    35 
    46from Orange.bio import obiTaxonomy 
     
    68import Orange.utils.environ 
    79 
    8 import os, sys, tarfile 
     10import tarfile 
    911import socket 
    1012 
    11 from getopt import getopt 
    12  
    13 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    14  
    15 username = opt.get("-u", opt.get("--user", "username")) 
    16 password = opt.get("-p", opt.get("--password", "password")) 
    17  
    18 path = os.path.join(Orange.utils.environ.buffer_dir, "tmp_Taxonomy") 
    19 serverFiles = orngServerFiles.ServerFiles(username, password) 
     13path = os.path.join(environ.buffer_dir, "tmp_Taxonomy") 
    2014u = obiTaxonomy.Update(local_database_path=path) 
    2115 
     
    3024            print ex 
    3125            pass 
    32     serverFiles.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy", 
     26    sf_server.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy", 
    3327                       tags=["NCBI", "taxonomy", "organism names", "essential", "#uncompressed:%i" % uncompressedSize(os.path.join(path, "ncbi_taxonomy.tar.gz"))]) 
    34     serverFiles.unprotect("Taxonomy", "ncbi_taxonomy.tar.gz") 
     28    sf_server.unprotect("Taxonomy", "ncbi_taxonomy.tar.gz") 
  • server_update/updatemiRNA.py

    r1719 r1721  
     1 
     2from common import * 
    13 
    24import urllib 
    35import re 
    4 import pylab 
    5 import random 
    6 import os 
    7 import math 
    8 import locale 
    9 import gzip 
    106import StringIO 
    11 import sys 
    12 from getopt import getopt 
    137import zipfile 
    148 
    159import Orange.bio.obiTaxonomy as tax 
    16 import Orange.utils.serverfiles as orngServerFiles 
    17 import Orange.utils.environ as orngEnviron 
    1810 
    1911def fastprint(filename,mode,what): 
     
    2517 
    2618def sendMail(subject): 
    27      
    28     print "MAIL", subject 
    29     toaddr = "rsberex@yahoo.it" 
    30     fromaddr = "orange@fri.uni-lj.si"; 
    31     msg = "From: %s\r\nTo: %s\r\nSubject: %s" % (fromaddr, toaddr, subject) 
    32     try: 
    33         import smtplib 
    34         s = smtplib.SMTP('212.235.188.18', 25) 
    35         s.sendmail(fromaddr, toaddr, msg) 
    36         s.quit() 
    37     except Exception, ex: 
    38         print "Failed to send error report due to:", ex 
    39  
     19    print "SHOULD MAIL:", subject 
    4020         
    4121def format_checker(content): 
     
    221201############################################################################################################################################################## 
    222202 
    223 opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0]) 
    224  
    225 username = opt.get("-u", opt.get("--user", "username")) 
    226 password = opt.get("-p", opt.get("--password", "password")) 
    227  
    228 path = os.path.join(orngEnviron.buffer_dir, "tmp_miRNA") 
     203path = os.path.join(environ.buffer_dir, "tmp_miRNA") 
    229204print 'path: ', path 
    230205 
    231 serverFiles = orngServerFiles.ServerFiles(username, password) 
     206serverFiles = sf_server 
    232207 
    233208try: 
     
    235210except OSError: 
    236211    pass 
    237  
    238212 
    239213org_taxo = [tax.name(id) for id in tax.common_taxids()] 
     
    322296    print "Check the address of miRNA file on %s" % address 
    323297 
    324                  
    325              
    326  
    327  
    328  
    329     
  • server_update/updater.py

    r1717 r1721  
    1 import sys, os 
    21import subprocess 
    32import time, glob 
    4 import optparse 
    53 
    6 from getopt import getopt 
    74from datetime import datetime 
    85 
    9 usage="""usage: %prog [options] [update_script ...] 
    10  
    11 Run update scripts""" 
    12  
    13 parser = optparse.OptionParser(usage=usage) 
    14 parser.add_option("-u", "--user", help="User name") 
    15 parser.add_option("-p", "--password", help="Password") 
    16 parser.add_option("-l", "--log-dir", dest="log_dir", help="Directory to store the logs", default="./") 
    17 parser.add_option("-m", "--mailto", help="e-mail the results to EMAIL", metavar="EMAIL", default=None) 
    18  
    19 option, args = parser.parse_args() 
     6from common import * 
    207 
    218if not args: 
     
    4532 
    4633def files_report(): 
    47   import orngServerFiles as sf 
    48   sf = sf.ServerFiles() 
    49   html = [] 
    50   for domain in sf.listdomains(): 
    51       if domain not in ["demo", "demo2", "test", "gad"]: 
    52           allinfo = sf.allinfo(domain) 
    53           html += ["<h2>%s</h2>" % domain, 
    54                    "<table><tr><th>Title</th><th>Date</th><th>Filename</th></tr>"] + \ 
    55                   ["<tr><td>%s</td><td>%s</td><td>%s</td></tr>" % (info["title"], info["datetime"], file) \ 
    56                    for file, info in allinfo.items()] + \ 
    57                   ["</table>"] 
    58   return "\n".join(html) 
     34    sf = serverfiles.ServerFiles() 
     35    html = [] 
     36    for domain in sf.listdomains(): 
     37        if domain not in ["demo", "demo2", "test", "gad"]: 
     38            allinfo = sf.allinfo(domain) 
     39            html += ["<h2>%s</h2>" % domain, 
     40                     "<table><tr><th>Title</th><th>Date</th><th>Filename</th></tr>"] + \ 
     41                    ["<tr><td>%s</td><td>%s</td><td>%s</td></tr>" % (info["title"], info["datetime"], file) \ 
     42                     for file, info in allinfo.items()] + \ 
     43                    ["</table>"] 
     44    return "\n".join(html) 
    5945   
    6046open(os.path.join(option.log_dir, "serverFiles.html"), "wb").write(files_report()) 
Note: See TracChangeset for help on using the changeset viewer.