This commit is contained in:
Soren I. Bjornstad 2013-11-09 17:11:33 -06:00
commit 69d7e10e7d
4 changed files with 72 additions and 67 deletions

View file

@ -30,6 +30,6 @@ if arch[1] == "ELF":
sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % ( sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % (
sys.version_info[1], arch[0][0:2]))) sys.version_info[1], arch[0][0:2])))
version="2.0.16" # build scripts grep this line, so preserve formatting version="2.0.17" # build scripts grep this line, so preserve formatting
from anki.storage import Collection from anki.storage import Collection
__all__ = ["Collection"] __all__ = ["Collection"]

View file

@ -3,12 +3,24 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import division from __future__ import division
import re, os, random, time, math, htmlentitydefs, subprocess, \ import re
tempfile, shutil, string, httplib2, sys, locale import os
import random
import time
import math
import htmlentitydefs
import subprocess
import tempfile
import shutil
import string
import sys
import locale
from hashlib import sha1 from hashlib import sha1
from anki.lang import _, ngettext
import platform import platform
from anki.lang import _, ngettext
if sys.version_info[1] < 5: if sys.version_info[1] < 5:
def format_string(a, b): def format_string(a, b):
return a % b return a % b
@ -16,6 +28,14 @@ if sys.version_info[1] < 5:
try: try:
import simplejson as json import simplejson as json
# make sure simplejson's loads() always returns unicode
# we don't try to support .load()
origLoads = json.loads
def loads(s, *args, **kwargs):
if not isinstance(s, unicode):
s = unicode(s, "utf8")
return origLoads(s, *args, **kwargs)
json.loads = loads
except ImportError: except ImportError:
import json import json

View file

@ -167,6 +167,8 @@ you can enter it here. Use \\t to represent tab."""),
err = repr(str(e)) err = repr(str(e))
if "1-character string" in err: if "1-character string" in err:
msg += err msg += err
elif "invalidTempFolder" in err:
msg += self.mw.errorHandler.tempFolderMsg()
else: else:
msg += unicode(traceback.format_exc(), "ascii", "replace") msg += unicode(traceback.format_exc(), "ascii", "replace")
showText(msg) showText(msg)

View file

@ -449,7 +449,6 @@ httplib.HTTPConnection.send = _incrementalSend
# receiving in httplib2 # receiving in httplib2
def _conn_request(self, conn, request_uri, method, body, headers): def _conn_request(self, conn, request_uri, method, body, headers):
for i in range(httplib2.RETRIES):
try: try:
if conn.sock is None: if conn.sock is None:
conn.connect() conn.connect()
@ -475,26 +474,11 @@ def _conn_request(self, conn, request_uri, method, body, headers):
# Just because the server closed the connection doesn't apparently mean # Just because the server closed the connection doesn't apparently mean
# that the server didn't send a response. # that the server didn't send a response.
if conn.sock is None: if conn.sock is None:
if i == 0:
conn.close()
conn.connect()
continue
else:
conn.close() conn.close()
raise raise
if i == 0:
conn.close()
conn.connect()
continue
pass
try: try:
response = conn.getresponse() response = conn.getresponse()
except (socket.error, httplib.HTTPException): except (socket.error, httplib.HTTPException):
if i == 0:
conn.close()
conn.connect()
continue
else:
raise raise
else: else:
content = "" content = ""
@ -512,7 +496,6 @@ def _conn_request(self, conn, request_uri, method, body, headers):
response = httplib2.Response(response) response = httplib2.Response(response)
if method != "HEAD": if method != "HEAD":
content = httplib2._decompressContent(response, content) content = httplib2._decompressContent(response, content)
break
return (response, content) return (response, content)
httplib2.Http._conn_request = _conn_request httplib2.Http._conn_request = _conn_request