Added the 'requests' library as a dependency and switched over to using it to
authortilly-Q <nattilypigeonfowl@gmail.com>
Tue, 15 Apr 2014 17:35:22 +0000 (13:35 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Tue, 15 Apr 2014 17:35:22 +0000 (13:35 -0400)
fetch remote pieces of media in the batchupload script

mediagoblin/gmg_commands/batchaddmedia.py
setup.py

index b058a47eaa674612afc7e5dc1c511382f5f7566d..deb6c5bdffe3f9d3557464dc9bc5b879f9a9139b 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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
index 93873d73b8e565b04de051f85d8a8e170da58aae..12739ffd3375485485db6a60a62ab1fd694a9802 100644 (file)
--- 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