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