mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: Start work on porting the server
This commit is contained in:
parent
1f86d92f7a
commit
5500e03a12
@ -24,11 +24,11 @@ from calibre.utils.socket_inheritance import set_socket_inherit
|
||||
from calibre.utils.logging import ThreadSafeLog
|
||||
from calibre.utils.monotonic import monotonic
|
||||
from calibre.utils.mdns import get_external_ip
|
||||
from polyglot.builtins import iteritems, range
|
||||
from polyglot.builtins import iteritems
|
||||
from polyglot.queue import Empty, Full
|
||||
|
||||
READ, WRITE, RDWR, WAIT = 'READ', 'WRITE', 'RDWR', 'WAIT'
|
||||
WAKEUP, JOB_DONE = bytes(bytearray(range(2)))
|
||||
WAKEUP, JOB_DONE = b'\0', b'\x01'
|
||||
IPPROTO_IPV6 = getattr(socket, "IPPROTO_IPV6", 41)
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import sys, inspect, re, time, numbers, json as jsonlib, textwrap
|
||||
from operator import attrgetter
|
||||
|
||||
from calibre.constants import ispy3
|
||||
from calibre.srv.errors import HTTPSimpleResponse, HTTPNotFound, RouteError
|
||||
from calibre.srv.utils import http_date
|
||||
from calibre.utils.serialize import msgpack_dumps, json_dumps, MSGPACK_MIME
|
||||
@ -158,6 +159,9 @@ class Route(object):
|
||||
self.names = [n for n, m in matchers if n is not None]
|
||||
self.all_names = frozenset(self.names)
|
||||
self.required_names = self.all_names - frozenset(self.defaults)
|
||||
if ispy3:
|
||||
argspec = inspect.getfullargspec(self.endpoint)
|
||||
else:
|
||||
argspec = inspect.getargspec(self.endpoint)
|
||||
if len(self.names) + 2 != len(argspec.args) - len(argspec.defaults or ()):
|
||||
raise route_error('Function must take %d non-default arguments' % (len(self.names) + 2))
|
||||
|
@ -13,6 +13,7 @@ from functools import partial
|
||||
from threading import Thread
|
||||
|
||||
from calibre.srv.utils import ServerLog
|
||||
from calibre.constants import ispy3
|
||||
from polyglot import http_client
|
||||
|
||||
rmtree = partial(shutil.rmtree, ignore_errors=True)
|
||||
@ -121,6 +122,9 @@ class TestServer(Thread):
|
||||
timeout = self.loop.opts.timeout
|
||||
if interface is None:
|
||||
interface = self.address[0]
|
||||
if ispy3:
|
||||
return http_client.HTTPConnection(interface, self.address[1], timeout=timeout)
|
||||
else:
|
||||
return http_client.HTTPConnection(interface, self.address[1], strict=True, timeout=timeout)
|
||||
|
||||
def change_handler(self, handler):
|
||||
|
Loading…
x
Reference in New Issue
Block a user