source: orange-bioinformatics/server_update/updateTaxonomy.py @ 1720:354d91b1af9f

Revision 1720:354d91b1af9f, 1.2 KB checked in by markotoplak, 20 months ago (diff)

Fixed update scripts for STRING and Taxonomy.

Line 
1##!interval=7
2##!contact=ales.erjavec@fri.uni-lj.si
3
4from Orange.bio import obiTaxonomy
5import Orange.utils.serverfiles as orngServerFiles
6import Orange.utils.environ
7
8import os, sys, tarfile
9import socket
10
11from getopt import getopt
12
13opt = dict(getopt(sys.argv[1:], "u:p:", ["user=", "password="])[0])
14
15username = opt.get("-u", opt.get("--user", "username"))
16password = opt.get("-p", opt.get("--password", "password"))
17
18path = os.path.join(Orange.utils.environ.buffer_dir, "tmp_Taxonomy")
19serverFiles = orngServerFiles.ServerFiles(username, password)
20u = obiTaxonomy.Update(local_database_path=path)
21
22uncompressedSize = lambda filename: sum(info.size for info in tarfile.open(filename).getmembers())
23
24if u.IsUpdatable(obiTaxonomy.Update.UpdateTaxonomy, ()):
25    for i in range(3):
26        try:
27            u.UpdateTaxonomy()
28            break
29        except socket.timeout, ex:
30            print ex
31            pass
32    serverFiles.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy",
33                       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")
Note: See TracBrowser for help on using the repository browser.