def UpdateToolTip(self): state = {0:"local, updataed", 1:"local, needs update", 2:"on server, download for local use", 3:"obsolete"} tooltip = "State: %s\nTags: %s" % (state[self.state], ", ".join(self.tags)) if self.state != 2: tooltip += "\nFile: %s" % orngServerFiles.localpath(self.domain, self.filename) for i in range(1, 5): self.setToolTip(i, tooltip)
##!interval=7 ##[email protected] import obiPPI, orngServerFiles import os, sys, shutil, urllib2, tarfile from getopt import getopt opt = dict(getopt(sys.argv[1:], "u:p:", ["user="******"password="******"-u", opt.get("--user", "username")) password = opt.get("-p", opt.get("--password", "password")) serverFiles = orngServerFiles.ServerFiles(username, password) try: os.mkdir(orngServerFiles.localpath("PPI")) except OSError: pass obiPPI.MIPS.download() try: serverFiles.create_domain("PPI") except Exception, ex: print ex filename = orngServerFiles.localpath("PPI", "mppi.gz") serverFiles.upload("PPI", "allppis.xml", filename, "MIPS Protein interactions", tags=[
import orngServerFiles import os reload(orngServerFiles) domain = "demo" filename = "orngServerFiles.py" print "Downloading domain: %s, file: %s" % (domain, filename) orngServerFiles.download(domain, filename, verbose=False) print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename) # change the access and modified time of the local file # this is stored in the .info file (does not depend on the actual datetime # values that we could access through os.stat(path) or set using us.utime) path = orngServerFiles.localpath(domain, filename) + ".info" f = file(path) str = [f.readline()] # first line s = "1800" + f.readline()[4:] # second line with date, change it print "Changing date to", s.strip() str += [s] str += f.readlines() # remaining lines f.close() f = file(path, "w") f.writelines(str) f.close() print "Needs update? %s (should be True)" % orngServerFiles.needs_update(domain, filename) print "Updating ..." orngServerFiles.update(domain, filename, verbose=False) print "Needs update? %s (should be False)" % orngServerFiles.needs_update(domain, filename)
FTP_NCBI = "ftp.ncbi.nih.gov" NCBI_DIR = "pub/geo/DATA/SOFT/GDS" opt = dict(getopt(sys.argv[1:], "u:p:", ["user="******"password="******"-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(): # DOMAIN does not exist on the server, create it server.create_domain(DOMAIN) localfile = orngServerFiles.localpath(DOMAIN, GDS_INFO) path = orngServerFiles.localpath(DOMAIN) if GDS_INFO in server.listfiles(DOMAIN): print "Updating info file from server ..." orngServerFiles.update(DOMAIN, GDS_INFO) info = orngServerFiles.info(DOMAIN, GDS_INFO) gds_info_datetime = datetime.strptime(info["datetime"], "%Y-%m-%d %H:%M:%S.%f") else: print "Creating a local path..." orngServerFiles.createPathForFile(localfile) f = file(localfile, "wb") cPickle.dump(({}, {}), f, True) f.close()
import orngServerFiles import os reload(orngServerFiles) domain = "demo" filename = "orngServerFiles.py" print "Downloading domain: %s, file: %s" % (domain, filename) orngServerFiles.download(domain, filename, verbose=False) print "Needs update? %s (should be False)" % orngServerFiles.needs_update( domain, filename) # change the access and modified time of the local file # this is stored in the .info file (does not depend on the actual datetime # values that we could access through os.stat(path) or set using us.utime) path = orngServerFiles.localpath(domain, filename) + ".info" f = file(path) str = [f.readline()] # first line s = "1800" + f.readline()[4:] # second line with date, change it print "Changing date to", s.strip() str += [s] str += f.readlines() # remaining lines f.close() f = file(path, "w") f.writelines(str) f.close() print "Needs update? %s (should be True)" % orngServerFiles.needs_update( domain, filename) print "Updating ..." orngServerFiles.update(domain, filename, verbose=False)