From fbb13abe9a22d08c3a2b86245cf02c1363c36d86 Mon Sep 17 00:00:00 2001 From: tilly-Q Date: Tue, 15 Apr 2014 13:35:22 -0400 Subject: [PATCH] Added the 'requests' library as a dependency and switched over to using it to fetch remote pieces of media in the batchupload script --- mediagoblin/gmg_commands/batchaddmedia.py | 9 ++++----- setup.py | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py index b058a47e..deb6c5bd 100644 --- a/mediagoblin/gmg_commands/batchaddmedia.py +++ b/mediagoblin/gmg_commands/batchaddmedia.py @@ -15,9 +15,10 @@ # along with this program. If not, see . import os -import tempfile, urllib, tarfile, zipfile, subprocess +import tempfile, tarfile, zipfile, subprocess, requests from csv import reader as csv_reader from urlparse import urlparse +import requests from pyld import jsonld from mediagoblin.gmg_commands import util as commands_util @@ -151,10 +152,8 @@ zip files and directories" filename = url.path.split()[-1] if url.scheme == 'http': - media_file = tempfile.TemporaryFile() - res = urllib.urlopen(url.geturl()) - media_file.write(res.read()) - media_file.seek(0) + res = requests.get(url.geturl()) + media_file = res.raw elif url.scheme == '': path = url.path diff --git a/setup.py b/setup.py index 93873d73..12739ffd 100644 --- a/setup.py +++ b/setup.py @@ -67,6 +67,7 @@ try: 'oauthlib==0.5.0', 'unidecode', 'jsonschema', + 'requests', ## Annoying. Please remove once we can! We only indirectly ## use pbr, and currently it breaks things, presumably till -- 2.25.1