mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'deprecated_urlopen_cafile' of https://github.com/salty-horse/calibre
This commit is contained in:
commit
3c70c1d90b
@ -5,14 +5,16 @@
|
|||||||
import bz2
|
import bz2
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import ssl
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
|
|
||||||
def download_from_calibre_server(url):
|
def download_from_calibre_server(url):
|
||||||
ca = os.path.join(sys.resources_location, 'calibre-ebook-root-CA.crt')
|
ca = os.path.join(sys.resources_location, 'calibre-ebook-root-CA.crt')
|
||||||
with urlopen(url, cafile=ca) as f:
|
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
return f.read()
|
ssl_context.load_verify_locations(ca)
|
||||||
|
return urlopen(url, context=ssl_context).read()
|
||||||
|
|
||||||
|
|
||||||
def filter_ans(ans):
|
def filter_ans(ans):
|
||||||
|
@ -166,8 +166,8 @@ class RecentUAs(Command): # {{{
|
|||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
from setup.browser_data import get_data
|
from setup.browser_data import get_data
|
||||||
data = get_data()
|
data = get_data()
|
||||||
with open(self.UA_PATH, 'wb') as f:
|
with open(self.UA_PATH, 'w', encoding='utf-8') as f:
|
||||||
f.write(json.dumps(data, indent=2, ensure_ascii=False, sort_keys=True).encode('utf-8'))
|
json.dump(data, f, indent=2, ensure_ascii=False, sort_keys=True)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user