Skip to content

Instantly share code, notes, and snippets.

@johnrichardrinehart
Last active March 28, 2016 00:50
Show Gist options
  • Save johnrichardrinehart/29aaae9be1c0fcdb973b to your computer and use it in GitHub Desktop.
Save johnrichardrinehart/29aaae9be1c0fcdb973b to your computer and use it in GitHub Desktop.
if not os.path.exists(os.path.dirname(filename)):
try:
os.makedirs(os.path.dirname(filename))
except OSError as exc: # protects against race conds
if exc.errno != errno.EEXIST:
printToLog("Failed to make the directory!",1)
raise
with open(filename,"w") as f:
for chunk in res.iter_content(2**20):
f.write(chunk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment