Пример #1
0
def check_database():
    """
    Check so the database exists.

    Returns:
        exists (bool): `True` if the database exists, otherwise `False`.
    """
    # Check so a database exists and is accessible
    from django.db import connection

    tables = connection.introspection.get_table_list(connection.cursor())
    if not tables or not isinstance(tables[0], basestring):  # django 1.8+
        tables = [tableinfo.name for tableinfo in tables]
    if tables and u"players_playerdb" in tables:
        # database exists and seems set up. Initialize evennia.
        import evennia

        evennia._init()
    # Try to get Player#1
    from evennia.players.models import PlayerDB

    try:
        PlayerDB.objects.get(id=1)
    except django.db.utils.OperationalError, e:
        print ERROR_DATABASE.format(traceback=e)
        sys.exit()
Пример #2
0
def check_database():
    """
    Check so the database exists.

    Returns:
        exists (bool): `True` if the database exists, otherwise `False`.
    """
    # Check so a database exists and is accessible
    from django.db import connection

    tables = connection.introspection.get_table_list(connection.cursor())
    if not tables or not isinstance(tables[0], basestring):  # django 1.8+
        tables = [tableinfo.name for tableinfo in tables]
    if tables and u"players_playerdb" in tables:
        # database exists and seems set up. Initialize evennia.
        import evennia

        evennia._init()
    # Try to get Player#1
    from evennia.players.models import PlayerDB

    try:
        PlayerDB.objects.get(id=1)
    except django.db.utils.OperationalError as e:
        print(ERROR_DATABASE.format(traceback=e))
        sys.exit()
    except PlayerDB.DoesNotExist:
        # no superuser yet. We need to create it.

        other_superuser = PlayerDB.objects.filter(is_superuser=True)
        if other_superuser:
            # Another superuser was found, but not with id=1. This may
            # happen if using flush (the auto-id starts at a higher
            # value). Wwe copy this superuser into id=1. To do
            # this we must deepcopy it, delete it then save the copy
            # with the new id. This allows us to avoid the UNIQUE
            # constraint on usernames.
            other = other_superuser[0]
            other_id = other.id
            other_key = other.username
            print(WARNING_MOVING_SUPERUSER.format(other_key=other_key, other_id=other_id))
            res = ""
            while res.upper() != "Y":
                # ask for permission
                res = input("Continue [Y]/N: ")
                if res.upper() == "N":
                    sys.exit()
                elif not res:
                    break
            # continue with the
            from copy import deepcopy

            new = deepcopy(other)
            other.delete()
            new.id = 1
            new.save()
        else:
            create_superuser()
            check_database()
    return True
Пример #3
0
 def build_suite(self, test_labels, extra_tests=None, **kwargs):
     """
     Build a test suite for Evennia. test_labels is a list of apps to test.
     If not given, a subset of settings.INSTALLED_APPS will be used.
     """
     import evennia
     evennia._init()
     return super(EvenniaTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs)
Пример #4
0
from __future__ import print_function
from builtins import object
import time
import sys
import os

from twisted.web import static
from twisted.application import internet, service
from twisted.internet import reactor, defer
from twisted.internet.task import LoopingCall

import django
django.setup()

import evennia
evennia._init()

from django.db import connection
from django.conf import settings

from evennia.players.models import PlayerDB
from evennia.scripts.models import ScriptDB
from evennia.server.models import ServerConfig
from evennia.server import initial_setup

from evennia.utils.utils import get_evennia_version, mod_import, make_iter
from evennia.comms import channelhandler
from evennia.server.sessionhandler import SESSIONS

_SA = object.__setattr__
Пример #5
0
"""
import time
import sys
import os

from twisted.web import server, static
from twisted.application import internet, service
from twisted.internet import reactor, defer
from twisted.internet.task import LoopingCall

import django
django.setup()

import evennia
evennia._init()

from django.db import connection
from django.conf import settings

from evennia.players.models import PlayerDB
from evennia.scripts.models import ScriptDB
from evennia.server.models import ServerConfig
from evennia.server import initial_setup

from evennia.utils.utils import get_evennia_version, mod_import, make_iter
from evennia.comms import channelhandler
from evennia.server.sessionhandler import SESSIONS

_SA = object.__setattr__