def downloadURL(url, filename):
path_temp_bviewfile = os.path.join(c.raw_data, c.bview_dir, '<STR_LIT>', filename)<EOL>path_bviewfile = os.path.join(c.raw_data, c.bview_dir, filename)<EOL>try:<EOL><INDENT>f = urlopen(url)<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>if f.getcode() != <NUM_LIT:200>:<EOL><INDENT>publisher.warning('<STR_LIT>'.format(url, f.getcode()))<EOL>return False<EOL><DEDENT>try:<EOL><INDENT>with open(path_temp_bviewfile, '<STR_LIT:w>') as outfile:<EOL><INDENT>outfile.write(f.read())<EOL><DEDENT>os.rename(path_temp_bviewfile, path_bviewfile)<EOL><DEDENT>except:<EOL><INDENT>os.remove(path_temp_bviewfile)<EOL>return False<EOL><DEDENT>return True<EOL>
Inconditianilly download the URL in a temporary directory.
When finished, the file is moved in the real directory.
Like this an other process will not attempt to extract an inclomplete file.