source: orange-bioinformatics/server_update/updateTaxonomy.py @ 1721:921b3780c6cc

Revision 1721:921b3780c6cc, 990 bytes checked in by markotoplak, 19 months ago (diff)

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

Line 
1##!interval=7
2##!contact=ales.erjavec@fri.uni-lj.si
3
4from common import *
5
6from Orange.bio import obiTaxonomy
7import Orange.utils.serverfiles as orngServerFiles
8import Orange.utils.environ
9
10import tarfile
11import socket
12
13path = os.path.join(environ.buffer_dir, "tmp_Taxonomy")
14u = obiTaxonomy.Update(local_database_path=path)
15
16uncompressedSize = lambda filename: sum(info.size for info in tarfile.open(filename).getmembers())
17
18if u.IsUpdatable(obiTaxonomy.Update.UpdateTaxonomy, ()):
19    for i in range(3):
20        try:
21            u.UpdateTaxonomy()
22            break
23        except socket.timeout, ex:
24            print ex
25            pass
26    sf_server.upload("Taxonomy", "ncbi_taxonomy.tar.gz", os.path.join(path, "ncbi_taxonomy.tar.gz"), title ="NCBI Taxonomy",
27                       tags=["NCBI", "taxonomy", "organism names", "essential", "#uncompressed:%i" % uncompressedSize(os.path.join(path, "ncbi_taxonomy.tar.gz"))])
28    sf_server.unprotect("Taxonomy", "ncbi_taxonomy.tar.gz")
Note: See TracBrowser for help on using the repository browser.