зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1696531: fix fake adb process to support python2 and 3 r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D109729
This commit is contained in:
Родитель
195b6f4fbd
Коммит
0593562c2b
|
@ -10,14 +10,14 @@ A fake ADB binary
|
|||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import SocketServer
|
||||
import socketserver
|
||||
import sys
|
||||
|
||||
HOST = "127.0.0.1"
|
||||
PORT = 5037
|
||||
|
||||
|
||||
class ADBRequestHandler(SocketServer.BaseRequestHandler):
|
||||
class ADBRequestHandler(socketserver.BaseRequestHandler):
|
||||
def sendData(self, data):
|
||||
header = "OKAY%04x" % len(data)
|
||||
all_data = header + data
|
||||
|
@ -28,12 +28,12 @@ class ADBRequestHandler(SocketServer.BaseRequestHandler):
|
|||
# client is on heavy load (e.g. MOZ_CHAOSMODE) we can't send the whole
|
||||
# data at once.
|
||||
while sent_length < total_length:
|
||||
sent = self.request.send(all_data[sent_length:])
|
||||
sent = self.request.send(all_data[sent_length:].encode("utf-8", "replace"))
|
||||
sent_length = sent_length + sent
|
||||
|
||||
def handle(self):
|
||||
while True:
|
||||
data = self.request.recv(4096)
|
||||
data = self.request.recv(4096).decode("utf-8", "replace")
|
||||
if "host:kill" in data:
|
||||
self.sendData("")
|
||||
# Implicitly close all open sockets by exiting the program.
|
||||
|
@ -50,11 +50,11 @@ class ADBRequestHandler(SocketServer.BaseRequestHandler):
|
|||
break
|
||||
|
||||
|
||||
class ADBServer(SocketServer.TCPServer):
|
||||
class ADBServer(socketserver.TCPServer):
|
||||
def __init__(self, server_address):
|
||||
# Create a SocketServer with bind_and_activate 'False' to set
|
||||
# Create a socketserver with bind_and_activate 'False' to set
|
||||
# allow_reuse_address before binding.
|
||||
SocketServer.TCPServer.__init__(
|
||||
socketserver.TCPServer.__init__(
|
||||
self, server_address, ADBRequestHandler, bind_and_activate=False
|
||||
)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче