Jeremy Stanley [Sun, 2 Sep 2018 00:36:22 +0000 (00:36 +0000)]
Expand logging for User class methods
Increase logging detail so that client connection/disconnection,
account login/logout, avatar activation/deactivation and
creation/deletion can be clearly associated and followed for ease of
troubleshooting.
Jeremy Stanley [Sun, 26 Aug 2018 17:42:15 +0000 (17:42 +0000)]
Support clients using CR+NUL to signal EOL
IETF RFC 854 requires that a Telnet server accept CR+NUL
interchangeably with CR+LF to indicate end of an input line from any
NVT (client). CR+NUL also happens to be the default behavior of
popular Telnet clients specifically when communicating on TCP port
23 (as opposed to non-default ports where more liberal protocol
fallbacks get employed). Previously these clients would need to `set
crlf` in their .telnetrc or at a telnet> command prompt as a
workaround.
Alter the selftest framework to send \r\0 from the NVT as an EOL to
make sure this does not regress, and add a test to explicitly end a
command with a \r\n just to make sure we can continue to support
CR+LF from clients.
Jeremy Stanley [Sun, 29 Jul 2018 17:56:52 +0000 (17:56 +0000)]
Add a "debug" testenv
Create a convenience tox testenv named "debug" which simply starts
the mudpy service with the daemon test configuration, for use in
manual client testing.
Jeremy Stanley [Sun, 29 Jul 2018 17:55:16 +0000 (17:55 +0000)]
Streamline selftest output
The standard output from a selftest run is much more brief, with the
prior verbose information redirected to a capture_tests.log file.
Jeremy Stanley [Sun, 29 Jul 2018 17:53:41 +0000 (17:53 +0000)]
Clean up leading space typo in test title
This is merely a cosmetic fix removing stray leading whitespace from
a test's title.
Jeremy Stanley [Tue, 17 Jul 2018 23:51:14 +0000 (23:51 +0000)]
Drop Python 3.3 support
Since wheel 0.30 and later no longer works with Python 3.3, it's
increasingly hard to test. Very few old platforms are likely to lack
Python 3.4 or later so this is a relatively safe move.
Also clean up some 3.3 workarounds as they're no longer needed if we
don't support running on it.
Jeremy Stanley [Tue, 17 Jul 2018 23:17:07 +0000 (23:17 +0000)]
Add signed artifact URL to Python package metadata
As PyPI doesn't support serving detached signatures for sdist and
wheel packages, but we provide some, link the URL to our copies in
the package metadata so that it appears in the links on the PyPI
project page.
Jeremy Stanley [Mon, 16 Jul 2018 03:40:03 +0000 (03:40 +0000)]
Clean up tox.ini
Remove an unused testenv:venv definition from tox.ini, and clean up
an unneeded ignore for .venv when running flake8.
Jeremy Stanley [Mon, 16 Jul 2018 03:35:52 +0000 (03:35 +0000)]
Apply correct Python version in tox base envs
Since we set basepython to python3 in tox's default testenv, this
has the unwanted side effect of causing all tox base envs (e.g.
py35) to use whatever interpreter is linked from the python3
executable name even if it isn't the requested version. Add a new
option from tox 3.1 to ignore this basepython override conflict.
Jeremy Stanley [Mon, 16 Jul 2018 03:32:07 +0000 (03:32 +0000)]
Test the default example config
To make sure the example config at etc/mudpy.yaml remains valid and
functional, add a separate tox test environment to exercise it
explicitly with the selftest suite.
Jeremy Stanley [Mon, 16 Jul 2018 03:29:15 +0000 (03:29 +0000)]
Add py3 to the default tox env list
Add a py3 environment to tox's list of default envs so that it will
be included in a basic `tox` run.
Jeremy Stanley [Mon, 16 Jul 2018 03:26:05 +0000 (03:26 +0000)]
Run the selftest in base tox testenvs
Configure tox so that the default (py35, py36, py37...) test
environments run the selftest with the daemon test configuration.
Jeremy Stanley [Mon, 16 Jul 2018 03:18:17 +0000 (03:18 +0000)]
Optionally manage a daemon during selftest runs
If a mudpy config file is supplied when invoking the selftest suite,
use it to start the service. This is intended for use with testing
automation such as tox. Handle both daemonized/disassociated and
direct child process possibilities, and attempt to clean the up
afterward. Also clean up the test environment when starting in case
stale processes or old logs were left behind by a previous run.
Jeremy Stanley [Mon, 16 Jul 2018 03:12:50 +0000 (03:12 +0000)]
Resolve included files only once
Remove an unnecessary additional round of included file resolution
and rely on the one which happens once the parent file has been
completely loaded. This was causing a startup race which would
sometimes result in the configured search path to not get applied
depending on initial config file load order, because it would
prematurely attempt to resolve included files before the configured
search path was loaded.
Jeremy Stanley [Sun, 15 Jul 2018 19:06:22 +0000 (19:06 +0000)]
Fix deprecated regex pattern syntax in selftests
A deprecated (non-raw with escape sequences) regular expression
string went unnoticed in a recent commit, so this change fixes it to
be ready for eventual Python 3.8.
Jeremy Stanley [Fri, 13 Jul 2018 17:04:24 +0000 (17:04 +0000)]
Clean up at the end of every selftest run
As the last sequence of calls made in the selftest suite, delete
remaining created accounts. This makes it possible to rerun the
selftest with data files preserved from a previous run to confirm we
don't introduce any dependencies on a fresh environment.
Jeremy Stanley [Fri, 13 Jul 2018 16:56:17 +0000 (16:56 +0000)]
Overhaul data reloading
The data model change left the reload feature in a miserable state
causing facets of mutable elements to be lost, changes introduced in
read-only origins to be ignored, and so on. Simplify the
implementation to just save, wipe and re-read all persistent data as
if the engine were starting initially. Also add a basic check to the
reload test to make sure a mutable element still has facets after
reloading, so that we reduce the risk of future regression. Include
a bit more verbose logging around when and what files are read at
load/reload time.
Jeremy Stanley [Sun, 8 Jul 2018 19:31:38 +0000 (19:31 +0000)]
Include "docs" in default tox envs list
Encourage regular testing that docs builds aren't broken by
generating them by default when tox is run without specific env
list. Also remove the doc tree from the flake8 exclusion list as it
should no longer contain anything to which that would object.
Jeremy Stanley [Sun, 8 Jul 2018 19:12:12 +0000 (19:12 +0000)]
Check readme suitability for PyPI
When generating sdists and wheels with the testenv:dist env in tox,
first run a check of the readme to make sure its contents will be
correctly parsed by PyPI/Warehouse. Also add dist to the set of
default envs and stop excluding the dist directory it creates from
testenv:flake8 runs since it shouldn't contain anything problematic
anyway. Clean up an unused VIRTUAL_ENV assignment in the tox.ini
too.
Update the Coder Guide with the simpler tox invocation while we're
at it.
Jeremy Stanley [Sun, 8 Jul 2018 18:55:53 +0000 (18:55 +0000)]
Rename "initial" state to "telopt_negotiation"
There was a rare race where if a client disconnected during the
initial Telnet option negotiation pause, an attempt to log an entry
about it would raise an exception because the "initial" state
placeholder in the default menu data was incorrectly-named. Fix
that, and rename the state to "telopt_negotiation" so it's less
confusing to debug if similar issues are discovered with this state
in the future.
Jeremy Stanley [Sat, 30 Jun 2018 20:52:23 +0000 (20:52 +0000)]
Test that ANSI input is filtered
Add a simple regression test to make sure ANSI escape sequences
aren't allowed in input lines. The escape (byte \x1b) character
should be filtered from non-binary-mode clients because we filter to
a "printable" set. For binary-mode clients an escape won't be valid
UTF-8 and so will cause the entire line of input on which it's found
to be skipped.
Jeremy Stanley [Sat, 30 Jun 2018 20:21:58 +0000 (20:21 +0000)]
Only wrap on actual spaces
Trying to match on Unicode character classes to determine where to
wrap lines turns out to be a fragile and blacklist-heavy exercise.
Instead, just wrap on actual (ASCII \x20) space characters. This
fixes a bug where the escape characters starting ANSI sequences were
sometimes matching as a wrap point garbling the output, but also
simplifies the code by no longer needing to exclude carriage returns
in a CR+LF line ending sequence. Further it solves a couple TODO
reminders to stop wrapping on non-breaking (Unicode \xa0) space
characters.
Jeremy Stanley [Sat, 30 Jun 2018 13:42:40 +0000 (13:42 +0000)]
Filter non-ASCII input when not in binary mode
If the client does not have binary send enabled per prior Telnet
option negotiation, filter for non-ASCII characters. This fixes a
bug where previously only binary mode senders were checked for
non-ASCII input and 7-bit senders were checked for non-UTF-8 input
rather than the other way around.
Jeremy Stanley [Fri, 25 May 2018 06:10:52 +0000 (06:10 +0000)]
Retool word wrapping
Better handle CR+LF injection when encountering words longer than
the terminal width. If a word is so wide it cannot be wrapped, leave
it on a line by itself and allow the terminal to apply its own
wrapping rules instead. Fixes a bug where excessive EOL markers
would get added in such situations. Also more accurately handles
skipping ANSI escape sequences in subsequently wrapped content.
Include a word-wrapping test in the selftests to avoid regressing
here.
Jeremy Stanley [Wed, 9 May 2018 13:23:50 +0000 (13:23 +0000)]
Include show version in help
Mention the new show version subcommand in help string for the
version command. Also tweak the explanations for a couple of other
subcommands for consistency.
Jeremy Stanley [Tue, 8 May 2018 19:23:52 +0000 (19:23 +0000)]
Clean dist directory in tox dist environment
To avoid accumulating deleted cruft in the dist directory, remove it
prior to running bdist_wheel/sdist.
Jeremy Stanley [Tue, 8 May 2018 18:46:54 +0000 (18:46 +0000)]
Add version command and diagnostic logging
Implement a new Versions class which is instantiated at startup and
reflects the versions of mudpy as well as the Python interpreter on
which it's running and versions of associated Python dependencies
plus any other importable Python packages which are found to be
present in the environment.
Include a show version command which provides a relevant summary of
this information and a selftest routine to make sure it's exercised.
Also log detailed version and diagnostic information at service
start, for ease of troubleshooting and defect reporting.
Jeremy Stanley [Wed, 2 May 2018 01:52:32 +0000 (01:52 +0000)]
Provide a dist environment for tox
A convenience env to create Python packages via tox.
Jeremy Stanley [Wed, 2 May 2018 01:50:34 +0000 (01:50 +0000)]
Indicate Python3.7 support
Update the Python package trove metadata to reflect that the project
is tested to work with the (still in beta) Python3.7 interpreter.
Jeremy Stanley [Wed, 2 May 2018 01:30:40 +0000 (01:30 +0000)]
Note platform in package metadata
In the Python package metadata, indicate that this project expects
and is targeted at POSIX/Unix platforms.
Jeremy Stanley [Wed, 2 May 2018 01:29:48 +0000 (01:29 +0000)]
Add keywords to Python package metadata
Include some relevant package search keywords for ease of location
on PyPI.
Jeremy Stanley [Wed, 2 May 2018 01:22:30 +0000 (01:22 +0000)]
Include license info in Python packages
Add the license metadata option for clear indication on PyPI, and
also link the license file for inclusion directly in Python wheel
packages. Add the URL for the generic license text redirect too.
Jeremy Stanley [Wed, 2 May 2018 01:18:49 +0000 (01:18 +0000)]
Update URLs in package metadata
Update the home-page URL in setup.cfg to reflect the switch to
HTTPS, and also add specific PEP 345 Project-URL entries for generic
documentation, VCS cloning/browsing and defect tracking redirects.
Jeremy Stanley [Wed, 2 May 2018 01:15:06 +0000 (01:15 +0000)]
Correct metadata entry for README
Properly link to the README file in setup.cfg for use as the long
description for Python packages. Also indicate that it's in
reStructuredText using PEP 566 description-content-type metadata.
Jeremy Stanley [Wed, 2 May 2018 01:09:59 +0000 (01:09 +0000)]
Clean build directory in tox docs environment
To avoid accumulating deleted cruft in generated documentation,
remove the build directory prior to running sphinx-build.
Jeremy Stanley [Wed, 2 May 2018 01:06:59 +0000 (01:06 +0000)]
Update copyright year in LICENSE
As the LICENSE file carries a general copyright for the whole
project, update the year range to reflect the changes which have
been made in 2018.
Jeremy Stanley [Wed, 2 May 2018 01:04:42 +0000 (01:04 +0000)]
Add copyright to api.rst
The doc/source/api.rst file was added without a copyright/license
header, so include one now. Also adjust the title level to match
that of the rest of the documentation.
Jeremy Stanley [Wed, 2 May 2018 01:03:32 +0000 (01:03 +0000)]
Add copyright to .yamllint
The .yamllint file was originally added without a copyright notice,
so include one now.
Jeremy Stanley [Mon, 30 Apr 2018 19:41:32 +0000 (19:41 +0000)]
Add a docs tox env
Provide a convenience environment definition for using tox to build
project documentation.
Jeremy Stanley [Mon, 30 Apr 2018 19:40:05 +0000 (19:40 +0000)]
Track doc building dependencies
A requirements list for the Python packages used to build project
documentation.
Jeremy Stanley [Mon, 30 Apr 2018 19:39:14 +0000 (19:39 +0000)]
Add Sphinx configuration
Configuration for using Sphinx to build the mudpy documentation
suite/site.
Jeremy Stanley [Mon, 30 Apr 2018 19:37:45 +0000 (19:37 +0000)]
Include a documentation index
A documentation index page with the project's README text
transcluded, so that it can also serve as the main page for a new
mudpy Web site.
Jeremy Stanley [Mon, 30 Apr 2018 19:36:39 +0000 (19:36 +0000)]
Include license text in documentation
Add a page to the documentation which embeds the full LICENSE file
for the project so that it will be available in Sphinx rendered
documentation.
Jeremy Stanley [Mon, 30 Apr 2018 19:35:35 +0000 (19:35 +0000)]
Include generated changelog in docs
Add a page for housing the PBR-generated changelog in the project
documentation.
Jeremy Stanley [Mon, 30 Apr 2018 19:34:24 +0000 (19:34 +0000)]
Basic API documentation
Add a stub page to generate autodoc-based API documentation for use
with Sphinx.
Jeremy Stanley [Mon, 30 Apr 2018 19:31:32 +0000 (19:31 +0000)]
Include the mudpy logo
A basic SVG rendering of the original mudpy logo, for use in
documentation builds.
Jeremy Stanley [Mon, 30 Apr 2018 18:39:10 +0000 (18:39 +0000)]
Add client configuration notes
This covers the last of the content from the old mudpy Web site, a
stub page with an example configuration for 8-bit Telnet clients.
Jeremy Stanley [Mon, 30 Apr 2018 17:48:50 +0000 (17:48 +0000)]
Document the data model
Add some prose documenting the terminology for the mudpy data model.
Include brief descriptions of element groups within the .mudpy
top-level namespace, as well as _prefixed local variables in the
individual storage units (currently YAML format files).
Jeremy Stanley [Mon, 30 Apr 2018 17:43:17 +0000 (17:43 +0000)]
Add configuration guide
Document the current configuration options along with their data
types and examples use.
Jeremy Stanley [Sat, 31 Mar 2018 17:35:02 +0000 (17:35 +0000)]
Update coder guide for new site redirects
A number of stable HTTP redirects have been added as part of a mudpy
Web site overhaul, so switch to using those in documentation in an
effort to require fewer URL updates in the future.
Jeremy Stanley [Sat, 17 Feb 2018 14:40:09 +0000 (14:40 +0000)]
Standardize formatting for the coder guide
In preparation for combining existing documentation into a cohesive
manual, adjust formatting of the coder guide for consistency with
other documents.
Jeremy Stanley [Sun, 4 Feb 2018 00:15:22 +0000 (00:15 +0000)]
Switch to extensionless README and LICENSE files
Since the README and LICENSE files are going to get included into
reStructuredText files for documentation rendering, they don't
really need .rst extensions and this keeps them more consistent with
the AUTHORS and ChangeLog files generated by PBR.
Jeremy Stanley [Sat, 3 Feb 2018 23:28:11 +0000 (23:28 +0000)]
Reformat README.rst
In further preparation for embedding the README.rst in Sphinx
rendered documentation, shorten the title, switch the copyright
statement from a field to a comment and while here clarify that the
YAML version used for configuration data is explicitly YAML 1.1.
Jeremy Stanley [Sun, 21 Jan 2018 23:41:46 +0000 (23:41 +0000)]
Test that unknown telnet commands are filtered
Using the recently added support for injecting raw bytes into the
client socket in self tests, send a made-up IAC sequence which the
server won't recognize as a valid telnet command and make sure that
it gets properly logged and filtered out of the input sequence while
preserving the remaining input.
Jeremy Stanley [Sun, 21 Jan 2018 23:39:45 +0000 (23:39 +0000)]
Fix TypeError with IAC escaping
Declare the literal newline as a byte type when analyzing an input
sequence with a double IAC byte, fixing a lingering crash which
raised a TypeError in negotiate_telnet_options(). Add regression
testing for proper handling and deduplication of an inline IAC pair.
While we're here, improve the log message about undecodeable UTF-8
sequences to be clear it's not just some of the bytes which were
discarded.
Jeremy Stanley [Wed, 6 Dec 2017 22:26:59 +0000 (22:26 +0000)]
Trim readme file
In preparation for embedding the README.rst in rendered
documentation, remove the final paragraph referring to the included
docs and URL to the version published online.
Jeremy Stanley [Sun, 3 Dec 2017 13:56:29 +0000 (13:56 +0000)]
Update login and banner art
Replace the old login splash screen and menu banner ASCII art with
something a little more stylish.
Jeremy Stanley [Fri, 1 Dec 2017 00:17:00 +0000 (00:17 +0000)]
Test sample data style with yamllint
Add a tox environment and associated support for running the
yamllint YAML style checking utility. This tool should be used to
check all edits made to any included YAML files for ease of
readability and future maintenance. It can also be used to check
YAML data generated by the mudpy engine, as its output style matches
the expectations of yamllint's default ruleset. One override has
been added via the included .yamllint configuration file, to prevent
it complaining about the extremely long PBKDF2 password hashes in
account elements which can't effectively be line-wrapped when
written.
Jeremy Stanley [Wed, 29 Nov 2017 16:50:16 +0000 (16:50 +0000)]
Indent block sequences in emitted files
Override the default Emitter and Dumper from the pyyaml library to
introduce (or more specifically stop suppressing) indentation when
writing block sequences. Also adjust the dump parameters to match
the indentation and related style used for included sample data and
configuration files.
Jeremy Stanley [Wed, 29 Nov 2017 16:41:35 +0000 (16:41 +0000)]
Convert mappings and sequences from flow to block
For ease of readability, standardize on indented block-style YAML
mapping and sequence definitions in sample data and configuration.
Also wrap long lines, add explicit document start markers and
introduce spaces in commented lines to ease future checking with the
yamllint utility's default style rules.
Jeremy Stanley [Wed, 22 Nov 2017 23:09:10 +0000 (23:09 +0000)]
Disconnect user on ConnectionResetError
If sending to a user's socket results in a connection reset
response, treat this as the same as a broken pipe and clean up the
session.
Jeremy Stanley [Sat, 18 Nov 2017 15:47:39 +0000 (15:47 +0000)]
Be careful about marking facets modified
Make sure to only set the modified flag on a facet when setting a
value if it has no corresponding node in its origin or the value
differs. This prevents the engine from unnecessarily rewriting the
origin's backing file on startup or reload.
Jeremy Stanley [Thu, 16 Nov 2017 02:36:34 +0000 (02:36 +0000)]
Use "group" instead of "category"
Update all uses of category/categories to group/groups. Also add
selftests for the "show groups" and "show group <group>" commands.
Jeremy Stanley [Sun, 12 Nov 2017 01:48:28 +0000 (01:48 +0000)]
Drop old-style Element support
The transition to the new data model is complete, and support for
the old model is now removed.
Jeremy Stanley [Sun, 12 Nov 2017 01:35:15 +0000 (01:35 +0000)]
Convert sample data to new style
Use the new data model for the sample room and prop definitions.
Jeremy Stanley [Sun, 12 Nov 2017 00:52:06 +0000 (00:52 +0000)]
Use new style for menu definitions
Convert menus to the new data model.
Jeremy Stanley [Sun, 12 Nov 2017 00:27:25 +0000 (00:27 +0000)]
Convert command Elements to new-style
Apply the new data model to command definitions.
Jeremy Stanley [Fri, 10 Nov 2017 02:09:44 +0000 (02:09 +0000)]
Switch archetypes to new-style Elements
Apply the new data model to archetypes.
Jeremy Stanley [Fri, 10 Nov 2017 01:55:04 +0000 (01:55 +0000)]
Switch internal counters to new-style Element
Convert the internal:counters Element to internal.counters following
the new data model.
Jeremy Stanley [Thu, 9 Nov 2017 10:00:11 +0000 (10:00 +0000)]
Switch actors to new-style elements
Actor elements created for avatars now follow the new data model.
Jeremy Stanley [Thu, 9 Nov 2017 09:58:38 +0000 (09:58 +0000)]
Handle connection reset in selftest
Within the selftest framework, catch ConnectionResetError exceptions
and provide a clearer error.
Jeremy Stanley [Thu, 9 Nov 2017 09:54:38 +0000 (09:54 +0000)]
Make new-style facet deletion more robust
When destroying a new-style Element, reuse the delete_facet method
instead of deleting keys from the origin. Within the delete_facet
method, make sure to delete the corresponding key from the facethash
too.
Jeremy Stanley [Thu, 9 Nov 2017 05:29:24 +0000 (05:29 +0000)]
Catch Exception when necessary
In situations where any exception needs to be matched in an except
clause, specify the Exception base class so as to be explicit that
it's an intentional choice and not an accidental omission.
Jeremy Stanley [Tue, 17 Oct 2017 07:55:03 +0000 (07:55 +0000)]
Clearer selftest errors on disconnection
Catch EOFError in the selftest framework and emit a message
indicating what happened.
Jeremy Stanley [Wed, 4 Oct 2017 08:27:25 +0000 (08:27 +0000)]
Use new-style elements for accounts
Switch account elements to the new data model, and fix some
old-style assumptions in Element creation and destruction. Also use
(and coerce to) boolean values for the administrator facet, and be
more clear in logs when accounts authenticating are admins or not.
Jeremy Stanley [Wed, 27 Sep 2017 16:52:45 +0000 (16:52 +0000)]
Fix unhandled exception in show file command
When generating the list of nodes from a file for the "show file"
command output, treat the data attribute as a list rather than a
dict. Previously, use of this command would crash the interpreter on
an unhandled exception attempting to invoke a nonexistent (since the
data model conversion) .keys() method.
While we're here, correct the output preamble to refer to the file
contents as "nodes" instead of "elements since it also includes
non-element nodes. Also correct the error message when a nonexistent
file is requested to say "file" instead of "category" (this was
probably cut-n-pasted from "show categories" and missed getting
updated).
For future safety, add a selftest to exercise the "show files"
command.
Jeremy Stanley [Wed, 27 Sep 2017 16:48:47 +0000 (16:48 +0000)]
Display flags in show files output
When the "show files" command is issued, any optional file flags
such as "private" are displayed after the filename.
Also add a selftest to exercise this command.
Jeremy Stanley [Sat, 16 Sep 2017 17:48:19 +0000 (17:48 +0000)]
Clean up a stray comment in find_file
Remove a long-lived cruft comment line from the data.find_file()
function, obsoleted back when filename normalization was broken out
of the return line into some more explicit earlier calls (prior to
the initial archive import into Git).
Jeremy Stanley [Sat, 16 Sep 2017 17:43:08 +0000 (17:43 +0000)]
Add descriptions to sample datafiles
For improved clarity, add some basic descriptions to the provided
sample datafiles in "_desc" metadata keys.
Jeremy Stanley [Sat, 16 Sep 2017 17:41:02 +0000 (17:41 +0000)]
Move sample datafile copyrights into metadata
Instead of using YAML comments in the provided sample datafiles,
standardize on a "_copy" metadata key for greater extensibility.
Jeremy Stanley [Sat, 16 Sep 2017 17:35:48 +0000 (17:35 +0000)]
Data nodes starting with "_" are metadata
Avoid loading data nodes with a "_" prefix as Universe content.
These are only used as file-local metadata.
Jeremy Stanley [Sat, 16 Sep 2017 17:29:38 +0000 (17:29 +0000)]
Interpret a "." prefix as the startdir
Since daemonization explicitly changes the working directory to "/",
specifying a mudpy.filing.prefix of "." should be taken to refer to
the original starting directory recorded in Universe.startdir rather
than the current directory for the process.
Jeremy Stanley [Sun, 27 Aug 2017 17:07:45 +0000 (17:07 +0000)]
Overhaul data management to get rid of __control__
Remap __control__ subkeys in data as follows:
default_files -> .mudpy.filing.categories
include_dirs -> _load
include_files -> _load
read_only -> _lock
Additionally, obsolete the __control__.private_files key by
switching from raw file/directory names to associative arrays in the
category defaults so that flags such as "private" can be added to
them, and make the category filenames automatically determined so
that they can be omitted unless specific overrides are required.
For the sake of future-proofing, rename the DataFile class to Data
and its "filename" attribute to "source" so that we avoid confusing
renames later when these might instead refer to some other storage
medium such as a table in a database. Similarly rename the Element
class attribute "filename" to "origin" attribute both to make it
more generic and to avoid confusion with "source" (an Element's
origin is a complete Data object, while a Data's source is just a
rooted-anchored file path currently).
Add a Universe.add_category convenience method to handle properly
guessing the corresponding fallback path and copying any declared
flags.
Jeremy Stanley [Mon, 31 Jul 2017 15:14:08 +0000 (15:14 +0000)]
Error if set command is used on read-only element
It is possible for an admin to accidentally attempt to set a facet
on an element from a read-only file. If this happens, trap the
PermissionError exception and return a clear error message to the
user instead of crashing the service. Also add a regression test to
make sure this continues to work as intended, since preventing
alteration of read-only elements is a critical security measure we
need to make certain we preserve going forward.
Jeremy Stanley [Mon, 31 Jul 2017 15:00:33 +0000 (15:00 +0000)]
Refuse to alter read-only elements at runtime
In the Element.set() method, check whether the element being altered
is from a read-only file. That should only ever happen when
(re)loading of files is underway, either at start time or because
the reload command/SIGHUP has been issued. If an attempt is made to
change a read-only element at any other time, raise a
PermissionError exception instead of setting the new value in memory
(altered values were never written to the backing file, but prior to
this it was possible to modify the in-memory copies).
Jeremy Stanley [Mon, 31 Jul 2017 14:56:57 +0000 (14:56 +0000)]
Track whether loading is underway
In preparation for safeguards preventing alteration of elements from
read-only backing files, we need a way to identify that loading
updated files is in progress; that's the only time elements from
read-only files should ever change.
Jeremy Stanley [Mon, 31 Jul 2017 14:54:34 +0000 (14:54 +0000)]
Test the set command
Add a test to make sure the set command works, and use it to alter
the facet we're subsequently checking in the writeable element for
the show element test to make sure it actually worked.
Jeremy Stanley [Mon, 31 Jul 2017 14:49:09 +0000 (14:49 +0000)]
Use writeable element in show element test
In preparation for being able to test the set command, switch the
legacy element being shown to one which is not in a read-only file
so that we'll be able to test altering it in a future change.
Jeremy Stanley [Sun, 30 Jul 2017 15:52:46 +0000 (15:52 +0000)]
Update copyright dates for files changed this year
Bump the copyright date to the present for files which received
significant modification since the beginning of the year.
Jeremy Stanley [Sun, 30 Jul 2017 02:40:25 +0000 (02:40 +0000)]
Rename internal:storage to .mudpy.filing
Convert the old style internal:storage element to a new style
.mudpy.filing element and adjust the find_file() function
accordingly.
Jeremy Stanley [Sat, 29 Jul 2017 18:42:30 +0000 (18:42 +0000)]
Stop unnecessarily stripping quote marks
Since the switch to YAML, quotations around strings are
automatically interpreted an so not included in the parsed result.
Remove legacy code which stripped leading and trailing quotes from
string values as this is no longer needed.
Jeremy Stanley [Sat, 29 Jul 2017 18:34:55 +0000 (18:34 +0000)]
Explicitly configure the root_path in examples
In the example and test configurations, set the root_path value to
"." signifying the current/starting directory. This exercises the
option so we can make sure it doesn't break anything.
Jeremy Stanley [Sat, 29 Jul 2017 18:31:40 +0000 (18:31 +0000)]
Log missing file inclusions as more severe
When another file is included with an inc macro in text, being
unable to load that file could indicate a fairly serious
configuration error. Increase the severity of the log message for
this so that it will be more easily noticed and caught in testing.
Jeremy Stanley [Sat, 29 Jul 2017 18:24:06 +0000 (18:24 +0000)]
Fix file pathing in daemon mode
If run as a daemon, the working directory is reset to "/" for
safety. Make sure that relative file searching takes this into
account and prefixes with the original (pre-chdir) start directory
rather than the current working directory.
Jeremy Stanley [Sat, 29 Jul 2017 16:18:16 +0000 (16:18 +0000)]
Rename internal:time to .mudpy.timing
Convert the old style internal:time element to a new style
.mudpy.timing element and adjust the User.check_idle() method and
on_pulse() function accordingly.
Jeremy Stanley [Sat, 29 Jul 2017 15:27:22 +0000 (15:27 +0000)]
Switch example listening port from 6669 to 4000
As a nod to the legacy of DikuMUD, use 4000/tcp as the example
listening socket instead of 6669/tcp.
Jeremy Stanley [Sat, 29 Jul 2017 15:05:26 +0000 (15:05 +0000)]
Fix facets method to give new-style relative names
For new-style elements correct the facets method to return short
(relative) key names, maintaining parity with old-style elements.
Add a new-style element to the "show element" selftest so that we
can make sure it won't regress.
Jeremy Stanley [Sat, 29 Jul 2017 15:01:08 +0000 (15:01 +0000)]
Use importlib in place of imp
As of Python 3.4, the newer importlib module supports the reload()
function we need. Switch from the deprecated imp module, except
before 3.4 where we will simply pretend imp is importlib for
readability.
Jeremy Stanley [Sat, 29 Jul 2017 14:53:36 +0000 (14:53 +0000)]
Reduce the log message priority for reload calls
It's important to log when the "reload" command is issued, but it's
not an error condition. Log the event at priority 6 rather than 8.
Jeremy Stanley [Sat, 29 Jul 2017 14:51:37 +0000 (14:51 +0000)]
Exercise the reload command in tests
To make sure it doesn't get broken in a coming change, call the
admin command `reload` in the selftest.