source: orange-bioinformatics/server_update/updateTaxonomy.py @ 1717:b9f395780e75

Revision 1717:b9f395780e75, 1.2 KB checked in by markotoplak, 20 months ago (diff)

Copied server update scripts from Orange source.

Line 
1##!interval=7
2##!contact=ales.erjavec@fri.uni-lj.si
3
4import obiTaxonomy
5import orngServerFiles
6
7import orngEnviron
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(orngEnviron.bufferDir, "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.