def download_file_anyway(link, destination, chunk_size=16 * 1024, progress_func = None): print_info_msg("Trying to download {0} to {1} with python lib [urllib2].".format(link, destination)) if os.path.exists(destination): print_warning_msg("File {0} already exists, assuming it was downloaded before".format(destination)) return try: force_download_file(link, destination, chunk_size, progress_func = progress_func) except: print_error_msg("Download {0} with python lib [urllib2] failed with error: {1}".format(link, str(sys.exc_info()))) if not os.path.exists(destination): print "Trying to download {0} to {1} with [curl] command.".format(link, destination) #print_info_msg("Trying to download {0} to {1} with [curl] command.".format(link, destination)) curl_command = "curl --fail -k -o %s %s" % (destination, link) retcode, out, err = os_run_os_command(curl_command) if retcode != 0: print_error_msg("Download file {0} with [curl] command failed with error: {1}".format(link, out + err)) if not os.path.exists(destination): print_error_msg("Unable to download file {0}!".format(link)) print "ERROR: unable to donwload file %s!" % (link)
def run_in_shell(cmd, env=None, cwd=None): return os_run_os_command(cmd, env, True, cwd)
def run_os_command(cmd, env=None, cwd=None): return os_run_os_command(cmd, env, False, cwd)