mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
Merge branch 'master' of https://github.com/dae/anki
This commit is contained in:
commit
69d7e10e7d
4 changed files with 72 additions and 67 deletions
|
|
@ -30,6 +30,6 @@ if arch[1] == "ELF":
|
|||
sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % (
|
||||
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
|
||||
__all__ = ["Collection"]
|
||||
|
|
|
|||
|
|
@ -3,12 +3,24 @@
|
|||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
from __future__ import division
|
||||
import re, os, random, time, math, htmlentitydefs, subprocess, \
|
||||
tempfile, shutil, string, httplib2, sys, locale
|
||||
import re
|
||||
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 anki.lang import _, ngettext
|
||||
import platform
|
||||
|
||||
from anki.lang import _, ngettext
|
||||
|
||||
|
||||
if sys.version_info[1] < 5:
|
||||
def format_string(a, b):
|
||||
return a % b
|
||||
|
|
@ -16,6 +28,14 @@ if sys.version_info[1] < 5:
|
|||
|
||||
try:
|
||||
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:
|
||||
import json
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ you can enter it here. Use \\t to represent tab."""),
|
|||
err = repr(str(e))
|
||||
if "1-character string" in err:
|
||||
msg += err
|
||||
elif "invalidTempFolder" in err:
|
||||
msg += self.mw.errorHandler.tempFolderMsg()
|
||||
else:
|
||||
msg += unicode(traceback.format_exc(), "ascii", "replace")
|
||||
showText(msg)
|
||||
|
|
|
|||
17
aqt/sync.py
17
aqt/sync.py
|
|
@ -449,7 +449,6 @@ httplib.HTTPConnection.send = _incrementalSend
|
|||
|
||||
# receiving in httplib2
|
||||
def _conn_request(self, conn, request_uri, method, body, headers):
|
||||
for i in range(httplib2.RETRIES):
|
||||
try:
|
||||
if conn.sock is None:
|
||||
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
|
||||
# that the server didn't send a response.
|
||||
if conn.sock is None:
|
||||
if i == 0:
|
||||
conn.close()
|
||||
conn.connect()
|
||||
continue
|
||||
else:
|
||||
conn.close()
|
||||
raise
|
||||
if i == 0:
|
||||
conn.close()
|
||||
conn.connect()
|
||||
continue
|
||||
pass
|
||||
try:
|
||||
response = conn.getresponse()
|
||||
except (socket.error, httplib.HTTPException):
|
||||
if i == 0:
|
||||
conn.close()
|
||||
conn.connect()
|
||||
continue
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
content = ""
|
||||
|
|
@ -512,7 +496,6 @@ def _conn_request(self, conn, request_uri, method, body, headers):
|
|||
response = httplib2.Response(response)
|
||||
if method != "HEAD":
|
||||
content = httplib2._decompressContent(response, content)
|
||||
break
|
||||
return (response, content)
|
||||
|
||||
httplib2.Http._conn_request = _conn_request
|
||||
|
|
|
|||
Loading…
Reference in a new issue