More unworking testing
This commit is contained in:
parent
36755c4bd4
commit
bd2a2356b6
6 changed files with 34 additions and 22 deletions
|
|
@ -7,6 +7,11 @@ Update to Python 3
|
||||||
- Use `python3 -m venv <myenvname>`
|
- Use `python3 -m venv <myenvname>`
|
||||||
- Use `python3 -m pdb <script>` for debugging
|
- Use `python3 -m pdb <script>` for debugging
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
- Swap argument order of `evennia.set_trace` to `set_trace(term_size=(140, 40), debugger='auto')`
|
||||||
|
since the size is more likely to be changed on the command line.
|
||||||
|
|
||||||
|
|
||||||
## Evennia 0.8 (2018)
|
## Evennia 0.8 (2018)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,17 +316,17 @@ def _init():
|
||||||
del _EvContainer
|
del _EvContainer
|
||||||
|
|
||||||
|
|
||||||
def set_trace(debugger="auto", term_size=(140, 40)):
|
def set_trace(term_size=(140, 40), debugger="auto"):
|
||||||
"""
|
"""
|
||||||
Helper function for running a debugger inside the Evennia event loop.
|
Helper function for running a debugger inside the Evennia event loop.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
term_size (tuple, optional): Only used for Pudb and defines the size of the terminal
|
||||||
|
(width, height) in number of characters.
|
||||||
debugger (str, optional): One of 'auto', 'pdb' or 'pudb'. Pdb is the standard debugger. Pudb
|
debugger (str, optional): One of 'auto', 'pdb' or 'pudb'. Pdb is the standard debugger. Pudb
|
||||||
is an external package with a different, more 'graphical', ncurses-based UI. With
|
is an external package with a different, more 'graphical', ncurses-based UI. With
|
||||||
'auto', will use pudb if possible, otherwise fall back to pdb. Pudb is available through
|
'auto', will use pudb if possible, otherwise fall back to pdb. Pudb is available through
|
||||||
`pip install pudb`.
|
`pip install pudb`.
|
||||||
term_size (tuple, optional): Only used for Pudb and defines the size of the terminal
|
|
||||||
(width, height) in number of characters.
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
To use:
|
To use:
|
||||||
|
|
@ -345,14 +345,12 @@ def set_trace(debugger="auto", term_size=(140, 40)):
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
dbg = None
|
dbg = None
|
||||||
pudb_mode = False
|
|
||||||
|
|
||||||
if debugger in ('auto', 'pudb'):
|
if debugger in ('auto', 'pudb'):
|
||||||
try:
|
try:
|
||||||
from pudb import debugger
|
from pudb import debugger
|
||||||
dbg = debugger.Debugger(stdout=sys.__stdout__,
|
dbg = debugger.Debugger(stdout=sys.__stdout__,
|
||||||
term_size=term_size)
|
term_size=term_size)
|
||||||
pudb_mode = True
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if debugger == 'pudb':
|
if debugger == 'pudb':
|
||||||
raise
|
raise
|
||||||
|
|
@ -361,12 +359,11 @@ def set_trace(debugger="auto", term_size=(140, 40)):
|
||||||
if not dbg:
|
if not dbg:
|
||||||
import pdb
|
import pdb
|
||||||
dbg = pdb.Pdb(stdout=sys.__stdout__)
|
dbg = pdb.Pdb(stdout=sys.__stdout__)
|
||||||
pudb_mode = False
|
|
||||||
|
|
||||||
if pudb_mode:
|
try:
|
||||||
# Stopped at breakpoint. Press 'n' to continue into the code.
|
|
||||||
dbg.set_trace()
|
|
||||||
else:
|
|
||||||
# Start debugger, forcing it up one stack frame (otherwise `set_trace` will start debugger
|
# Start debugger, forcing it up one stack frame (otherwise `set_trace` will start debugger
|
||||||
# this point, not the actual code location)
|
# this point, not the actual code location)
|
||||||
dbg.set_trace(sys._getframe().f_back)
|
dbg.set_trace(sys._getframe().f_back)
|
||||||
|
except Exception:
|
||||||
|
# Stopped at breakpoint. Press 'n' to continue into the code.
|
||||||
|
dbg.set_trace()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class AMPClientFactory(protocol.ReconnectingClientFactory):
|
||||||
|
|
||||||
def startedConnecting(self, connector):
|
def startedConnecting(self, connector):
|
||||||
"""
|
"""
|
||||||
Called when starting to try to connect to the MUD server.
|
Called when starting to try to connect to the Portal AMP server.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
connector (Connector): Twisted Connector instance representing
|
connector (Connector): Twisted Connector instance representing
|
||||||
|
|
@ -102,6 +102,7 @@ class AMPServerClientProtocol(amp.AMPMultiConnectionProtocol):
|
||||||
Called when a new connection is established.
|
Called when a new connection is established.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
print("AMPClient new connection {}".format(self))
|
||||||
info_dict = self.factory.server.get_info_dict()
|
info_dict = self.factory.server.get_info_dict()
|
||||||
super(AMPServerClientProtocol, self).connectionMade()
|
super(AMPServerClientProtocol, self).connectionMade()
|
||||||
# first thing we do is to request the Portal to sync all sessions
|
# first thing we do is to request the Portal to sync all sessions
|
||||||
|
|
|
||||||
|
|
@ -632,9 +632,6 @@ def send_instruction(operation, arguments, callback=None, errback=None):
|
||||||
"""
|
"""
|
||||||
global AMP_CONNECTION, REACTOR_RUN
|
global AMP_CONNECTION, REACTOR_RUN
|
||||||
|
|
||||||
print("send_instruction: {}, {}, {}, {}, {})".format(operation, arguments, callback, errback, AMP_CONNECTION))
|
|
||||||
|
|
||||||
|
|
||||||
if None in (AMP_HOST, AMP_PORT, AMP_INTERFACE):
|
if None in (AMP_HOST, AMP_PORT, AMP_INTERFACE):
|
||||||
print(ERROR_AMP_UNCONFIGURED)
|
print(ERROR_AMP_UNCONFIGURED)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
@ -663,13 +660,11 @@ def send_instruction(operation, arguments, callback=None, errback=None):
|
||||||
|
|
||||||
def _send():
|
def _send():
|
||||||
if operation == PSTATUS:
|
if operation == PSTATUS:
|
||||||
print("send PSTATUS ... {}".format(AMP_CONNECTION))
|
return AMP_CONNECTION.callRemote(MsgStatus, status=b"").addCallbacks(_callback, _errback)
|
||||||
return AMP_CONNECTION.callRemote(MsgStatus, status="").addCallbacks(_callback, _errback)
|
|
||||||
else:
|
else:
|
||||||
print("send callremote")
|
|
||||||
return AMP_CONNECTION.callRemote(
|
return AMP_CONNECTION.callRemote(
|
||||||
MsgLauncher2Portal,
|
MsgLauncher2Portal,
|
||||||
operation=operation,
|
operation=bytes(operation, 'utf-8'),
|
||||||
arguments=pickle.dumps(arguments, pickle.HIGHEST_PROTOCOL)).addCallbacks(
|
arguments=pickle.dumps(arguments, pickle.HIGHEST_PROTOCOL)).addCallbacks(
|
||||||
_callback, _errback)
|
_callback, _errback)
|
||||||
|
|
||||||
|
|
@ -1095,7 +1090,10 @@ def tail_log_files(filename1, filename2, start_lines1=20, start_lines2=20, rate=
|
||||||
|
|
||||||
def _file_changed(filename, prev_size):
|
def _file_changed(filename, prev_size):
|
||||||
"Get size of file in bytes, get diff compared with previous size"
|
"Get size of file in bytes, get diff compared with previous size"
|
||||||
|
try:
|
||||||
new_size = os.path.getsize(filename)
|
new_size = os.path.getsize(filename)
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False, 0
|
||||||
return new_size != prev_size, new_size
|
return new_size != prev_size, new_size
|
||||||
|
|
||||||
def _get_new_lines(filehandle, old_linecount):
|
def _get_new_lines(filehandle, old_linecount):
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from functools import wraps
|
||||||
import time
|
import time
|
||||||
from twisted.protocols import amp
|
from twisted.protocols import amp
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from io import StringIO, BytesIO
|
from io import BytesIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
import zlib # Used in Compressed class
|
import zlib # Used in Compressed class
|
||||||
import pickle
|
import pickle
|
||||||
|
|
@ -282,6 +282,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
||||||
"""
|
"""
|
||||||
Handle non-AMP messages, such as HTTP communication.
|
Handle non-AMP messages, such as HTTP communication.
|
||||||
"""
|
"""
|
||||||
|
print("dataReceived: {}".format(data))
|
||||||
if data[:1] == NUL:
|
if data[:1] == NUL:
|
||||||
# an AMP communication
|
# an AMP communication
|
||||||
if data[-2:] != NULNUL:
|
if data[-2:] != NULNUL:
|
||||||
|
|
@ -318,6 +319,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
||||||
This is called when an AMP connection is (re-)established. AMP calls it on both sides.
|
This is called when an AMP connection is (re-)established. AMP calls it on both sides.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
print("connectionMade: {}".format(self))
|
||||||
self.factory.broadcasts.append(self)
|
self.factory.broadcasts.append(self)
|
||||||
|
|
||||||
def connectionLost(self, reason):
|
def connectionLost(self, reason):
|
||||||
|
|
@ -330,6 +332,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
||||||
portal will continuously try to reconnect, showing the problem
|
portal will continuously try to reconnect, showing the problem
|
||||||
that way.
|
that way.
|
||||||
"""
|
"""
|
||||||
|
print("ConnectionLost: {}: {}".format(self, reason))
|
||||||
try:
|
try:
|
||||||
self.factory.broadcasts.remove(self)
|
self.factory.broadcasts.remove(self)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
@ -385,6 +388,8 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
deferreds = []
|
deferreds = []
|
||||||
|
print("broadcast: {} {}: {}".format(command, sessid, kwargs))
|
||||||
|
|
||||||
for protcl in self.factory.broadcasts:
|
for protcl in self.factory.broadcasts:
|
||||||
deferreds.append(protcl.callRemote(command, **kwargs).addErrback(
|
deferreds.append(protcl.callRemote(command, **kwargs).addErrback(
|
||||||
self.errback, command.key))
|
self.errback, command.key))
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# start the Server
|
# start the Server
|
||||||
|
print("Portal starting server ... {}".format(server_twistd_cmd))
|
||||||
process = None
|
process = None
|
||||||
with open(settings.SERVER_LOG_FILE, 'a') as logfile:
|
with open(settings.SERVER_LOG_FILE, 'a') as logfile:
|
||||||
# we link stdout to a file in order to catch
|
# we link stdout to a file in order to catch
|
||||||
|
|
@ -226,6 +227,8 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
||||||
Send a status stanza to the launcher.
|
Send a status stanza to the launcher.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
print("send status to launcher")
|
||||||
|
print("self.get_status(): {}".format(self.get_status()))
|
||||||
if self.factory.launcher_connection:
|
if self.factory.launcher_connection:
|
||||||
self.factory.launcher_connection.callRemote(
|
self.factory.launcher_connection.callRemote(
|
||||||
amp.MsgStatus,
|
amp.MsgStatus,
|
||||||
|
|
@ -302,7 +305,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
||||||
|
|
||||||
_, server_connected, _, _, _, _ = self.get_status()
|
_, server_connected, _, _, _, _ = self.get_status()
|
||||||
|
|
||||||
# logger.log_msg("Evennia Launcher->Portal operation %s received" % (ord(operation)))
|
logger.log_msg("Evennia Launcher->Portal operation %s:%s received" % (ord(operation), arguments))
|
||||||
|
|
||||||
if operation == amp.SSTART: # portal start #15
|
if operation == amp.SSTART: # portal start #15
|
||||||
# first, check if server is already running
|
# first, check if server is already running
|
||||||
|
|
@ -382,6 +385,9 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
||||||
self.factory.server_connection = self
|
self.factory.server_connection = self
|
||||||
|
|
||||||
sessid, kwargs = self.data_in(packed_data)
|
sessid, kwargs = self.data_in(packed_data)
|
||||||
|
|
||||||
|
logger.log_msg("Evennia Server->Portal admin data %s:%s received" % (sessid, kwargs))
|
||||||
|
|
||||||
operation = kwargs.pop("operation")
|
operation = kwargs.pop("operation")
|
||||||
portal_sessionhandler = self.factory.portal.sessions
|
portal_sessionhandler = self.factory.portal.sessions
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue