fixed #183
This commit is contained in:
@@ -5,6 +5,7 @@ ChangeLog
|
|||||||
|
|
||||||
- Avoid deprecated BaseException.message (#180)
|
- Avoid deprecated BaseException.message (#180)
|
||||||
- Add travis builds (#182)
|
- Add travis builds (#182)
|
||||||
|
- fixed wsdump to work with piped input (#183)
|
||||||
|
|
||||||
- 0.30.0
|
- 0.30.0
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import code
|
|||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
import websocket
|
import websocket
|
||||||
try:
|
try:
|
||||||
import readline
|
import readline
|
||||||
@@ -12,8 +13,17 @@ except:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def get_encoding():
|
||||||
|
encoding = getattr(sys.stdin, "encoding", "")
|
||||||
|
if not encoding:
|
||||||
|
return "utf-8"
|
||||||
|
else:
|
||||||
|
return encoding.lower()
|
||||||
|
|
||||||
|
|
||||||
OPCODE_DATA = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
|
OPCODE_DATA = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
|
||||||
ENCODING = getattr(sys.stdin, "encoding", "").lower()
|
ENCODING = get_encoding()
|
||||||
|
|
||||||
|
|
||||||
class VAction(argparse.Action):
|
class VAction(argparse.Action):
|
||||||
def __call__(self, parser, args, values, option_string=None):
|
def __call__(self, parser, args, values, option_string=None):
|
||||||
@@ -105,6 +115,7 @@ def main():
|
|||||||
def recv_ws():
|
def recv_ws():
|
||||||
while True:
|
while True:
|
||||||
opcode, data = recv()
|
opcode, data = recv()
|
||||||
|
print(data)
|
||||||
msg = None
|
msg = None
|
||||||
if not args.verbose and opcode in OPCODE_DATA:
|
if not args.verbose and opcode in OPCODE_DATA:
|
||||||
msg = "< %s" % data
|
msg = "< %s" % data
|
||||||
@@ -128,6 +139,7 @@ def main():
|
|||||||
try:
|
try:
|
||||||
message = console.raw_input("> ")
|
message = console.raw_input("> ")
|
||||||
ws.send(message)
|
ws.send(message)
|
||||||
|
time.sleep(0.05)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
return
|
return
|
||||||
except EOFError:
|
except EOFError:
|
||||||
|
Reference in New Issue
Block a user