Changeset 1721:921b3780c6cc in orange-bioinformatics for server_update/updateGEO.py


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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." 
Note: See TracChangeset for help on using the changeset viewer.