More fixes

This commit is contained in:
Griatch 2021-02-27 14:13:42 +01:00
parent aefe2b070f
commit 4cefba6e3b
5 changed files with 31 additions and 18 deletions

View file

@ -1,5 +1,5 @@
# Toc
- [API root](api/evennia-api.rst)
- [./A voice operated elevator using events](./A-voice-operated-elevator-using-events)
- [./API refactoring](./API-refactoring)
- [./Accounts](./Accounts)

View file

@ -26,6 +26,7 @@ import evennia
evennia._init()
from django.db import connection
from django.db.utils import OperationalError
from django.conf import settings
from evennia.accounts.models import AccountDB
@ -205,7 +206,10 @@ class Evennia(object):
self.start_time = time.time()
# initialize channelhandler
channelhandler.CHANNELHANDLER.update()
try:
channelhandler.CHANNELHANDLER.update()
except OperationalError:
print("channelhandler couldn't update - db not set up")
# wrap the SIGINT handler to make sure we empty the threadpool
# even when we reload and we have long-running requests in queue.
@ -616,7 +620,11 @@ class Evennia(object):
# Tell the system the server is starting up; some things are not available yet
ServerConfig.objects.conf("server_starting_mode", True)
try:
ServerConfig.objects.conf("server_starting_mode", True)
except OperationalError:
print("Server server_starting_mode couldn't be set - database not set up.")
# twistd requires us to define the variable 'application' so it knows
# what to execute from.
@ -728,4 +736,7 @@ for plugin_module in SERVER_SERVICES_PLUGIN_MODULES:
print(f"Could not load plugin module {plugin_module}")
# clear server startup mode
ServerConfig.objects.conf("server_starting_mode", delete=True)
try:
ServerConfig.objects.conf("server_starting_mode", delete=True)
except OperationalError:
print("Server server_starting_mode couldn't unset - db not set up.")

View file

@ -1,8 +1,8 @@
"""
ANSI - Gives colour to text.
Use the codes defined in ANSIPARSER in your text
to apply colour to text according to the ANSI standard.
Use the codes defined in ANSIPARSER in your text to apply colour to text
according to the ANSI standard.
Examples:
@ -10,10 +10,9 @@ Examples:
"This is |rRed text|n and this is normal again."
```
Mostly you should not need to call `parse_ansi()` explicitly;
it is run by Evennia just before returning data to/from the
user. Depreciated example forms are available by extending
the ansi mapping.
Mostly you should not need to call `parse_ansi()` explicitly; it is run by
Evennia just before returning data to/from the user. Depreciated example forms
are available by extending the ansi mapping.
"""
import functools
@ -81,11 +80,9 @@ _COLOR_NO_DEFAULT = settings.COLOR_NO_DEFAULT
class ANSIParser(object):
"""
A class that parses ANSI markup
to ANSI command sequences
A class that parses ANSI markup to ANSI command sequences.
We also allow to escape colour codes
by prepending with an extra |.
We also allow to escape colour codes by prepending with an extra `|`.
"""

View file

@ -96,16 +96,16 @@ def create_object(
location itself or during unittests.
attributes (list): Tuples on the form (key, value) or (key, value, category),
(key, value, lockstring) or (key, value, lockstring, default_access).
to set as Attributes on the new object.
to set as Attributes on the new object.
nattributes (list): Non-persistent tuples on the form (key, value). Note that
adding this rarely makes sense since this data will not survive a reload.
adding this rarely makes sense since this data will not survive a reload.
Returns:
object (Object): A newly created object of the given typeclass.
Raises:
ObjectDB.DoesNotExist: If trying to create an Object with
`location` or `home` that can't be found.
`location` or `home` that can't be found.
"""
global _ObjectDB

View file

@ -10,6 +10,7 @@ import time
from calendar import monthrange
from datetime import datetime, timedelta
from django.db.utils import OperationalError
from django.conf import settings
from evennia import DefaultScript
from evennia.server.models import ServerConfig
@ -23,7 +24,11 @@ IGNORE_DOWNTIMES = settings.TIME_IGNORE_DOWNTIMES
# Only set if gametime_reset was called at some point.
GAME_TIME_OFFSET = ServerConfig.objects.conf("gametime_offset", default=0)
try:
GAME_TIME_OFFSET = ServerConfig.objects.conf("gametime_offset", default=0)
except OperationalError:
print("Gametime offset could not load - db not set up.")
GAME_TIME_OFFSET = 0
# Common real-life time measure, in seconds.
# You should not change this.