Changeset cf4b7f4
- Timestamp:
- Sep 15, 2012, 10:51:23 PM (13 years ago)
- Branches:
- master, space-access, stable, stage
- Children:
- 0f60d8b
- Parents:
- 08d4fa6
- git-author:
- Alex Dehnert <adehnert@…> (09/15/12 22:51:23)
- git-committer:
- Alex Dehnert <adehnert@…> (09/15/12 22:51:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/models.py
r3113644 rcf4b7f4 11 11 import re 12 12 import shutil 13 import subprocess 13 14 import urlparse 14 15 import urllib … … 169 170 new_mimetype = None 170 171 if url.startswith('/afs/') or url.startswith('/mit/'): 171 new_ fp = open(url, 'rb')172 new_data = mit.pag_check_output(['/bin/cat', url], aklog=False, stderr=subprocess.STDOUT) 172 173 else: 173 174 new_fp = urllib2.urlopen(url) 174 175 if new_fp.info().getheader('Content-Type'): 175 176 new_mimetype = new_fp.info().gettype() 176 177 new_data = new_fp.read() 178 new_fp.close() 177 new_data = new_fp.read() 178 new_fp.close() 179 179 except urllib2.HTTPError, e: 180 180 error_msg = "HTTPError: %s %s" % (e.code, e.msg) 181 181 except urllib2.URLError, e: 182 182 error_msg = "URLError: %s" % (e.reason) 183 except subprocess.CalledProcessError, e: 184 results = e.output.split(": ") 185 if len(results) == 3 and results[0] == '/bin/cat' and results[1] == url: 186 cat_err = results[2] 187 else: 188 cat_err = e.output 189 error_msg = "CalledProcessError %d: %s" % (e.returncode, cat_err) 183 190 except IOError: 184 191 error_msg = "IOError"
Note: See TracChangeset
for help on using the changeset viewer.