mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
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 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)
|
||||
|
||||
|
|
@ -22,7 +27,7 @@ Update to Python 3
|
|||
to terminal and can be stopped with Ctrl-C. Using `evennia reload`, or reloading in-game, will
|
||||
return Server to normal daemon operation.
|
||||
- For validating passwords, use safe Django password-validation backend instead of custom Evennia one.
|
||||
- Alias `evennia restart` to mean the same as `evennia reload`.
|
||||
- Alias `evennia restart` to mean the same as `evennia reload`.
|
||||
|
||||
### Prototype changes
|
||||
|
||||
|
|
|
|||
|
|
@ -316,17 +316,17 @@ def _init():
|
|||
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.
|
||||
|
||||
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
|
||||
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
|
||||
`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:
|
||||
To use:
|
||||
|
|
@ -345,14 +345,12 @@ def set_trace(debugger="auto", term_size=(140, 40)):
|
|||
"""
|
||||
import sys
|
||||
dbg = None
|
||||
pudb_mode = False
|
||||
|
||||
if debugger in ('auto', 'pudb'):
|
||||
try:
|
||||
from pudb import debugger
|
||||
dbg = debugger.Debugger(stdout=sys.__stdout__,
|
||||
term_size=term_size)
|
||||
pudb_mode = True
|
||||
except ImportError:
|
||||
if debugger == 'pudb':
|
||||
raise
|
||||
|
|
@ -361,12 +359,11 @@ def set_trace(debugger="auto", term_size=(140, 40)):
|
|||
if not dbg:
|
||||
import pdb
|
||||
dbg = pdb.Pdb(stdout=sys.__stdout__)
|
||||
pudb_mode = False
|
||||
|
||||
if pudb_mode:
|
||||
# Stopped at breakpoint. Press 'n' to continue into the code.
|
||||
dbg.set_trace()
|
||||
else:
|
||||
try:
|
||||
# Start debugger, forcing it up one stack frame (otherwise `set_trace` will start debugger
|
||||
# this point, not the actual code location)
|
||||
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):
|
||||
"""
|
||||
Called when starting to try to connect to the MUD server.
|
||||
Called when starting to try to connect to the Portal AMP server.
|
||||
|
||||
Args:
|
||||
connector (Connector): Twisted Connector instance representing
|
||||
|
|
@ -102,6 +102,7 @@ class AMPServerClientProtocol(amp.AMPMultiConnectionProtocol):
|
|||
Called when a new connection is established.
|
||||
|
||||
"""
|
||||
print("AMPClient new connection {}".format(self))
|
||||
info_dict = self.factory.server.get_info_dict()
|
||||
super(AMPServerClientProtocol, self).connectionMade()
|
||||
# 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
|
||||
|
||||
print("send_instruction: {}, {}, {}, {}, {})".format(operation, arguments, callback, errback, AMP_CONNECTION))
|
||||
|
||||
|
||||
if None in (AMP_HOST, AMP_PORT, AMP_INTERFACE):
|
||||
print(ERROR_AMP_UNCONFIGURED)
|
||||
sys.exit()
|
||||
|
|
@ -663,13 +660,11 @@ def send_instruction(operation, arguments, callback=None, errback=None):
|
|||
|
||||
def _send():
|
||||
if operation == PSTATUS:
|
||||
print("send PSTATUS ... {}".format(AMP_CONNECTION))
|
||||
return AMP_CONNECTION.callRemote(MsgStatus, status="").addCallbacks(_callback, _errback)
|
||||
return AMP_CONNECTION.callRemote(MsgStatus, status=b"").addCallbacks(_callback, _errback)
|
||||
else:
|
||||
print("send callremote")
|
||||
return AMP_CONNECTION.callRemote(
|
||||
MsgLauncher2Portal,
|
||||
operation=operation,
|
||||
operation=bytes(operation, 'utf-8'),
|
||||
arguments=pickle.dumps(arguments, pickle.HIGHEST_PROTOCOL)).addCallbacks(
|
||||
_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):
|
||||
"Get size of file in bytes, get diff compared with previous size"
|
||||
new_size = os.path.getsize(filename)
|
||||
try:
|
||||
new_size = os.path.getsize(filename)
|
||||
except FileNotFoundError:
|
||||
return False, 0
|
||||
return new_size != prev_size, new_size
|
||||
|
||||
def _get_new_lines(filehandle, old_linecount):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from functools import wraps
|
|||
import time
|
||||
from twisted.protocols import amp
|
||||
from collections import defaultdict, namedtuple
|
||||
from io import StringIO, BytesIO
|
||||
from io import BytesIO
|
||||
from itertools import count
|
||||
import zlib # Used in Compressed class
|
||||
import pickle
|
||||
|
|
@ -282,6 +282,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
|||
"""
|
||||
Handle non-AMP messages, such as HTTP communication.
|
||||
"""
|
||||
print("dataReceived: {}".format(data))
|
||||
if data[:1] == NUL:
|
||||
# an AMP communication
|
||||
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.
|
||||
|
||||
"""
|
||||
print("connectionMade: {}".format(self))
|
||||
self.factory.broadcasts.append(self)
|
||||
|
||||
def connectionLost(self, reason):
|
||||
|
|
@ -330,6 +332,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
|||
portal will continuously try to reconnect, showing the problem
|
||||
that way.
|
||||
"""
|
||||
print("ConnectionLost: {}: {}".format(self, reason))
|
||||
try:
|
||||
self.factory.broadcasts.remove(self)
|
||||
except ValueError:
|
||||
|
|
@ -385,6 +388,8 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
|||
|
||||
"""
|
||||
deferreds = []
|
||||
print("broadcast: {} {}: {}".format(command, sessid, kwargs))
|
||||
|
||||
for protcl in self.factory.broadcasts:
|
||||
deferreds.append(protcl.callRemote(command, **kwargs).addErrback(
|
||||
self.errback, command.key))
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
|||
|
||||
"""
|
||||
# start the Server
|
||||
print("Portal starting server ... {}".format(server_twistd_cmd))
|
||||
process = None
|
||||
with open(settings.SERVER_LOG_FILE, 'a') as logfile:
|
||||
# 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.
|
||||
|
||||
"""
|
||||
print("send status to launcher")
|
||||
print("self.get_status(): {}".format(self.get_status()))
|
||||
if self.factory.launcher_connection:
|
||||
self.factory.launcher_connection.callRemote(
|
||||
amp.MsgStatus,
|
||||
|
|
@ -302,7 +305,7 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
|||
|
||||
_, 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
|
||||
# first, check if server is already running
|
||||
|
|
@ -382,6 +385,9 @@ class AMPServerProtocol(amp.AMPMultiConnectionProtocol):
|
|||
self.factory.server_connection = self
|
||||
|
||||
sessid, kwargs = self.data_in(packed_data)
|
||||
|
||||
logger.log_msg("Evennia Server->Portal admin data %s:%s received" % (sessid, kwargs))
|
||||
|
||||
operation = kwargs.pop("operation")
|
||||
portal_sessionhandler = self.factory.portal.sessions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue