Merge branch 'feature/add-jupyter-notebook-support' of https://github.com/duysqubix/evennia into duysqubix-feature/add-jupyter-notebook-support

This commit is contained in:
Griatch 2020-12-20 13:38:16 +01:00
commit 358fc8ff0e
5 changed files with 37 additions and 4 deletions

View file

@ -38,10 +38,38 @@ That is, enter `evennia.` and press the `<TAB>` key. This will show you all the
available at the top level of Evennia's "flat API". See the [flat API](../Evennia-API) page for more
info on how to explore it efficiently.
#### Jupyter Notebook Support
You can now explore evennia interactively with jupyter notebooks. There are a few extra steps that must be taken in order for this to work:
# [open a new console/terminal]
# [activate your evennia virtualenv in this console/terminal]
cd evennia
pip install -r requirements_extra.txt # this installs optional, but necessary modules for this to work.
cd mygame # make sure you are in root of your grame
evennia shell_plus --notebook& # this will start the notebook in the background
Open an existing, or create, a notebook and in the first cell you must run:
```python
import evennia
evennia._init()
```
This will initialize all module level variables located in `evennia.__init__`.
Now you have the same support as `evennia shell`, but in a more visual and persistent form.
*It is important to remember, everytime the kernel restarts within a notebook you must first run
`evennia._init()`*
You can complement your exploration by peeking at the sections of the much more detailed
[Evennia Component overview](../Components/Components-Overview). The [Tutorials](../Howto/Howto-Overview) section also contains a growing collection
of system- or implementation-specific help.
### Use a python syntax checker
Evennia works by importing your own modules and running them as part of the server. Whereas Evennia

View file

@ -373,7 +373,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
puppet (Object): The matching puppeted object, if any.
"""
return session.puppet
return session.puppet if session else None
def get_all_puppets(self):
"""

View file

@ -999,7 +999,7 @@ class CmdQuell(COMMAND_DEFAULT_CLASS):
self.msg("Already quelling Account %s permissions." % permstr)
return
account.attributes.add("_quell", True)
puppet = self.session.puppet
puppet = self.session.puppet if self.session else None
if puppet:
cpermstr = "(%s)" % ", ".join(puppet.permissions.all())
cpermstr = "Quelling to current puppet's permissions %s." % cpermstr

View file

@ -2259,7 +2259,7 @@ def main():
if option in ("makemessages", "compilemessages"):
# some commands don't require the presence of a game directory to work
need_gamedir = False
if option in ("shell", "check", "makemigrations", "createsuperuser"):
if option in ("shell", "check", "makemigrations", "createsuperuser", "shell_plus"):
# some django commands requires the database to exist,
# or evennia._init to have run before they work right.
check_db = True

View file

@ -14,3 +14,8 @@ service_identity >= 18.1.0
# AWS-storage contrib
boto3 >= 1.4.4
botocore >= 1.15
# Jupyter Notebook support
jupyter >= 1.0.0
ipython >= 7.19.0
django-extensions >= 3.1.0