Changeset 1610:f6c73952d74f in orange-bioinformatics for obiGO.py


Ignore:
Timestamp:
03/27/12 14:18:19 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
rebase_source:
c83e4bbf02d43b8dc1cb4f41b43f10464e08ce86
Message:

Save download file to a temporary '.part' file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiGO.py

    r1609 r1610  
    455455            filename = os.path.join(default_database_path, "gene_ontology_edit@rev%s.obo" % rev) 
    456456        r = urllib2.urlopen(url) 
    457         shutil.copyfileobj(r, open(filename, "wb")) 
     457         
     458        with open(filename + ".part", "wb") as f: 
     459            shutil.copyfileobj(r, f) 
     460             
     461        os.rename(filename + ".part", filename) 
    458462         
    459463         
     
    971975        url += ";content-type=application%2Fx-gzip" 
    972976        r = urllib2.urlopen(url) 
    973         shutil.copyfileobj(r, open(filename, "wb")) 
     977         
     978        with open(filename + ".part", "wb") as f: 
     979            shutil.copyfileobj(r, f) 
     980         
     981        os.rename(filename + ".part", filename) 
    974982 
    975983from obiTaxonomy import pickled_cache 
Note: See TracChangeset for help on using the changeset viewer.