<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from builtins import input , range <EOL> import os <EOL> import sys <EOL> import signal <EOL> import shutil <EOL> import importlib <EOL> from argparse import ArgumentParser <EOL> from subprocess import Popen , check_output , call , CalledProcessError , STDOUT <EOL> import twisted <EOL> import django <EOL> SIG = signal . SIGINT <EOL> EVENNIA_ROOT = os . path . dirname ( os . path . dirname ( os . path . dirname ( os . path . abspath ( __file__ ) ) ) ) <EOL> import evennia <EOL> EVENNIA_LIB = os . path . join ( os . path . dirname ( os . path . abspath ( evennia . __file__ ) ) ) <EOL> EVENNIA_SERVER = os . path . join ( EVENNIA_LIB , "<STR_LIT>" ) <EOL> EVENNIA_RUNNER = os . path . join ( EVENNIA_SERVER , "<STR_LIT>" ) <EOL> EVENNIA_TEMPLATE = os . path . join ( EVENNIA_LIB , "<STR_LIT>" ) <EOL> EVENNIA_PROFILING = os . path . join ( EVENNIA_SERVER , "<STR_LIT>" ) <EOL> EVENNIA_DUMMYRUNNER = os . path . join ( EVENNIA_PROFILING , "<STR_LIT>" ) <EOL> TWISTED_BINARY = "<STR_LIT>" <EOL> SETTINGFILE = "<STR_LIT>" <EOL> SERVERDIR = "<STR_LIT>" <EOL> CONFDIR = os . path . join ( SERVERDIR , "<STR_LIT>" ) <EOL> SETTINGS_PATH = os . path . join ( CONFDIR , SETTINGFILE ) <EOL> SETTINGS_DOTPATH = "<STR_LIT>" <EOL> CURRENT_DIR = os . getcwd ( ) <EOL> GAMEDIR = CURRENT_DIR <EOL> SERVER_LOGFILE = None <EOL> PORTAL_LOGFILE = None <EOL> HTTP_LOGFILE = None <EOL> SERVER_PIDFILE = None <EOL> PORTAL_PIDFILE = None <EOL> SERVER_RESTART = None <EOL> PORTAL_RESTART = None <EOL> SERVER_PY_FILE = None <EOL> PORTAL_PY_FILE = None <EOL> PYTHON_MIN = '<STR_LIT>' <EOL> TWISTED_MIN = '<STR_LIT>' <EOL> DJANGO_MIN = '<STR_LIT>' <EOL> DJANGO_REC = '<STR_LIT>' <EOL> sys . path [ <NUM_LIT:1> ] = EVENNIA_ROOT <EOL> CREATED_NEW_GAMEDIR = """<STR_LIT>""" <EOL> ERROR_INPUT = """<STR_LIT>""" <EOL> ERROR_NO_GAMEDIR = """<STR_LIT>""" <EOL> WARNING_MOVING_SUPERUSER = """<STR_LIT>""" <EOL> WARNING_RUNSERVER = """<STR_LIT>""" <EOL> ERROR_SETTINGS = """<STR_LIT>""" . format ( settingsfile = SETTINGFILE , settingspath = SETTINGS_PATH ) <EOL> ERROR_DATABASE = """<STR_LIT>""" <EOL> ERROR_WINDOWS_WIN32API = """<STR_LIT>""" <EOL> INFO_WINDOWS_BATFILE = """<STR_LIT>""" <EOL> CMDLINE_HELP = """<STR_LIT>""" <EOL> VERSION_INFO = """<STR_LIT>""" <EOL> ABOUT_INFO = """<STR_LIT>""" <EOL> HELP_ENTRY = """<STR_LIT>""" <EOL> MENU = """<STR_LIT>""" <EOL> ERROR_LOGDIR_MISSING = """<STR_LIT>""" <EOL> ERROR_PYTHON_VERSION = """<STR_LIT>""" <EOL> ERROR_TWISTED_VERSION = """<STR_LIT>""" <EOL> ERROR_NOTWISTED = """<STR_LIT>""" <EOL> ERROR_DJANGO_MIN = """<STR_LIT>""" <EOL> NOTE_DJANGO_MIN = """<STR_LIT>""" <EOL> NOTE_DJANGO_NEW = """<STR_LIT>""" <EOL> ERROR_NODJANGO = """<STR_LIT>""" <EOL> NOTE_KEYBOARDINTERRUPT = """<STR_LIT>""" <EOL> def evennia_version ( ) : <EOL> """<STR_LIT>""" <EOL> version = "<STR_LIT>" <EOL> try : <EOL> import evennia <EOL> version = evennia . __version__ <EOL> except ImportError : <EOL> pass <EOL> try : <EOL> rev = check_output ( <EOL> "<STR_LIT>" , <EOL> shell = True , cwd = EVENNIA_ROOT , stderr = STDOUT ) . strip ( ) <EOL> version = "<STR_LIT>" % ( version , rev ) <EOL> except ( IOError , CalledProcessError ) : <EOL> pass <EOL> return version <EOL> EVENNIA_VERSION = evennia_version ( ) <EOL> def check_main_evennia_dependencies ( ) : <EOL> """<STR_LIT>""" <EOL> error = False <EOL> pversion = "<STR_LIT:.>" . join ( str ( num ) for num in sys . version_info if type ( num ) == int ) <EOL> if pversion < PYTHON_MIN : <EOL> print ( ERROR_PYTHON_VERSION . format ( pversion = pversion , python_min = PYTHON_MIN ) ) <EOL> error = True <EOL> try : <EOL> import twisted <EOL> tversion = twisted . version . short ( ) <EOL> if tversion < TWISTED_MIN : <EOL> print ( ERROR_TWISTED_VERSION . format ( <EOL> tversion = tversion , twisted_min = TWISTED_MIN ) ) <EOL> error = True <EOL> except ImportError : <EOL> print ( ERROR_NOTWISTED ) <EOL> error = True <EOL> try : <EOL> dversion = "<STR_LIT:.>" . join ( str ( num ) for num in django . VERSION if type ( num ) == int ) <EOL> dversion_main = "<STR_LIT:.>" . join ( dversion . split ( "<STR_LIT:.>" ) [ : <NUM_LIT:2> ] ) <EOL> if dversion < DJANGO_MIN : <EOL> print ( ERROR_DJANGO_MIN . format ( <EOL> dversion = dversion_main , django_min = DJANGO_MIN ) ) <EOL> error = True <EOL> elif DJANGO_MIN <= dversion < DJANGO_REC : <EOL> print ( NOTE_DJANGO_MIN . format ( <EOL> dversion = dversion_main , django_rec = DJANGO_REC ) ) <EOL> elif DJANGO_REC < dversion_main : <EOL> print ( NOTE_DJANGO_NEW . format ( <EOL> dversion = dversion_main , django_rec = DJANGO_REC ) ) <EOL> except ImportError : <EOL> print ( ERROR_NODJANGO ) <EOL> error = True <EOL> if error : <EOL> sys . exit ( ) <EOL> return not error <EOL> def set_gamedir ( path ) : <EOL> """<STR_LIT>""" <EOL> global GAMEDIR <EOL> if os . path . exists ( os . path . join ( path , SETTINGS_PATH ) ) : <EOL> GAMEDIR = os . path . abspath ( path ) <EOL> elif os . path . exists ( os . path . join ( path , os . path . pardir , SETTINGS_PATH ) ) : <EOL> GAMEDIR = os . path . dirname ( path ) <EOL> elif os . path . exists ( os . path . join ( path , os . path . pardir , os . path . pardir , SETTINGS_PATH ) ) : <EOL> GAMEDIR = os . path . dirname ( os . path . dirname ( path ) ) <EOL> elif os . path . exists ( os . path . join ( path , os . path . pardir , os . path . pardir , os . path . pardir , SETTINGS_PATH ) ) : <EOL> GAMEDIR = os . path . dirname ( os . path . dirname ( os . path . dirname ( path ) ) ) <EOL> else : <EOL> print ( ERROR_NO_GAMEDIR ) <EOL> sys . exit ( ) <EOL> def create_secret_key ( ) : <EOL> """<STR_LIT>""" <EOL> import random <EOL> import string <EOL> secret_key = list ( ( string . letters + <EOL> string . digits + string . punctuation ) . replace ( "<STR_LIT:\\>" , "<STR_LIT>" ) . replace ( "<STR_LIT:'>" , '<STR_LIT:">' ) ) <EOL> random . shuffle ( secret_key ) <EOL> secret_key = "<STR_LIT>" . join ( secret_key [ : <NUM_LIT> ] ) <EOL> return secret_key <EOL> def create_settings_file ( ) : <EOL> """<STR_LIT>""" <EOL> settings_path = os . path . join ( GAMEDIR , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> with open ( settings_path , '<STR_LIT:r>' ) as f : <EOL> settings_string = f . read ( ) <EOL> setting_dict = { <EOL> "<STR_LIT>" : os . path . join ( EVENNIA_LIB , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : "<STR_LIT>" % GAMEDIR . rsplit ( os . path . sep , <NUM_LIT:1> ) [ <NUM_LIT:1> ] . capitalize ( ) , <EOL> "<STR_LIT>" : "<STR_LIT>" % create_secret_key ( ) } <EOL> settings_string = settings_string . format ( ** setting_dict ) <EOL> with open ( settings_path , '<STR_LIT:w>' ) as f : <EOL> f . write ( settings_string ) <EOL> def create_game_directory ( dirname ) : <EOL> """<STR_LIT>""" <EOL> global GAMEDIR <EOL> GAMEDIR = os . path . abspath ( os . path . join ( CURRENT_DIR , dirname ) ) <EOL> if os . path . exists ( GAMEDIR ) : <EOL> print ( "<STR_LIT>" % dirname ) <EOL> sys . exit ( ) <EOL> shutil . copytree ( EVENNIA_TEMPLATE , GAMEDIR ) <EOL> create_settings_file ( ) <EOL> def create_superuser ( ) : <EOL> """<STR_LIT>""" <EOL> print ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> django . core . management . call_command ( "<STR_LIT>" , interactive = True ) <EOL> def check_database ( ) : <EOL> """<STR_LIT>""" <EOL> from django . db import connection <EOL> tables = connection . introspection . get_table_list ( connection . cursor ( ) ) <EOL> if not tables or not isinstance ( tables [ <NUM_LIT:0> ] , basestring ) : <EOL> tables = [ tableinfo . name for tableinfo in tables ] <EOL> if tables and u'<STR_LIT>' in tables : <EOL> import evennia <EOL> evennia . _init ( ) <EOL> from evennia . players . models import PlayerDB <EOL> try : <EOL> PlayerDB . objects . get ( id = <NUM_LIT:1> ) <EOL> except django . db . utils . OperationalError as e : <EOL> print ( ERROR_DATABASE . format ( traceback = e ) ) <EOL> sys . exit ( ) <EOL> except PlayerDB . DoesNotExist : <EOL> other_superuser = PlayerDB . objects . filter ( is_superuser = True ) <EOL> if other_superuser : <EOL> other = other_superuser [ <NUM_LIT:0> ] <EOL> other_id = other . id <EOL> other_key = other . username <EOL> print ( WARNING_MOVING_SUPERUSER . format ( <EOL> other_key = other_key , other_id = other_id ) ) <EOL> res = "<STR_LIT>" <EOL> while res . upper ( ) != "<STR_LIT:Y>" : <EOL> res = input ( "<STR_LIT>" ) <EOL> if res . upper ( ) == "<STR_LIT:N>" : <EOL> sys . exit ( ) <EOL> elif not res : <EOL> break <EOL> from copy import deepcopy <EOL> new = deepcopy ( other ) <EOL> other . delete ( ) <EOL> new . id = <NUM_LIT:1> <EOL> new . save ( ) <EOL> else : <EOL> create_superuser ( ) <EOL> check_database ( ) <EOL> return True <EOL> def getenv ( ) : <EOL> """<STR_LIT>""" <EOL> sep = "<STR_LIT:;>" if os . name == '<STR_LIT>' else "<STR_LIT::>" <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = sep . join ( sys . path ) <EOL> return env <EOL> def get_pid ( pidfile ) : <EOL> """<STR_LIT>""" <EOL> pid = None <EOL> if os . path . exists ( pidfile ) : <EOL> f = open ( pidfile , '<STR_LIT:r>' ) <EOL> pid = f . read ( ) <EOL> return pid <EOL> def del_pid ( pidfile ) : <EOL> """<STR_LIT>""" <EOL> if os . path . exists ( pidfile ) : <EOL> os . remove ( pidfile ) <EOL> def kill ( pidfile , signal = SIG , succmsg = "<STR_LIT>" , errmsg = "<STR_LIT>" , <EOL> restart_file = SERVER_RESTART , restart = False ) : <EOL> """<STR_LIT>""" <EOL> pid = get_pid ( pidfile ) <EOL> if pid : <EOL> if os . name == '<STR_LIT>' : <EOL> os . remove ( pidfile ) <EOL> if restart : <EOL> django . core . management . call_command ( <EOL> '<STR_LIT>' , interactive = False , verbosity = <NUM_LIT:0> ) <EOL> with open ( restart_file , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> else : <EOL> with open ( restart_file , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> try : <EOL> os . kill ( int ( pid ) , signal ) <EOL> except OSError : <EOL> print ( "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" % { '<STR_LIT>' : pid , '<STR_LIT>' : pidfile } ) <EOL> return <EOL> print ( "<STR_LIT>" , succmsg ) <EOL> return <EOL> print ( "<STR_LIT>" , errmsg ) <EOL> def show_version_info ( about = False ) : <EOL> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import twisted <EOL> import django <EOL> return VERSION_INFO . format ( <EOL> version = EVENNIA_VERSION , about = ABOUT_INFO if about else "<STR_LIT>" , <EOL> os = os . name , python = sys . version . split ( ) [ <NUM_LIT:0> ] , <EOL> twisted = twisted . version . short ( ) , <EOL> django = django . get_version ( ) ) <EOL> def error_check_python_modules ( ) : <EOL> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> def imp ( path , split = True ) : <EOL> mod , fromlist = path , "<STR_LIT:None>" <EOL> if split : <EOL> mod , fromlist = path . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) <EOL> __import__ ( mod , fromlist = [ fromlist ] ) <EOL> imp ( settings . COMMAND_PARSER ) <EOL> imp ( settings . SEARCH_AT_RESULT ) <EOL> imp ( settings . CONNECTION_SCREEN_MODULE ) <EOL> for path in settings . LOCK_FUNC_MODULES : <EOL> imp ( path , split = False ) <EOL> deprstring = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % ( <EOL> "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if settings . WEBSERVER_ENABLED and not isinstance ( settings . WEBSERVER_PORTS [ <NUM_LIT:0> ] , tuple ) : <EOL> raise DeprecationWarning ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % ( <EOL> "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % ( <EOL> "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> deprstring = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % "<STR_LIT>" ) <EOL> if hasattr ( settings , "<STR_LIT>" ) : <EOL> raise DeprecationWarning ( deprstring % "<STR_LIT>" ) <EOL> from evennia . commands import cmdsethandler <EOL> if not cmdsethandler . import_cmdset ( settings . CMDSET_UNLOGGEDIN , None ) : <EOL> print ( "<STR_LIT>" ) <EOL> if not cmdsethandler . import_cmdset ( settings . CMDSET_CHARACTER , None ) : <EOL> print ( "<STR_LIT>" ) <EOL> if not cmdsethandler . import_cmdset ( settings . CMDSET_PLAYER , None ) : <EOL> print ( "<STR_LIT>" ) <EOL> imp ( settings . BASE_PLAYER_TYPECLASS ) <EOL> imp ( settings . BASE_OBJECT_TYPECLASS ) <EOL> imp ( settings . BASE_CHARACTER_TYPECLASS ) <EOL> imp ( settings . BASE_ROOM_TYPECLASS ) <EOL> imp ( settings . BASE_EXIT_TYPECLASS ) <EOL> imp ( settings . BASE_SCRIPT_TYPECLASS ) <EOL> def init_game_directory ( path , check_db = True ) : <EOL> """<STR_LIT>""" <EOL> set_gamedir ( path ) <EOL> sys . path . insert ( <NUM_LIT:0> , GAMEDIR ) <EOL> if sys . argv [ <NUM_LIT:1> ] == '<STR_LIT:test>' : <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> os . environ [ '<STR_LIT>' ] = SETTINGS_DOTPATH <EOL> django . setup ( ) <EOL> try : <EOL> from django . conf import settings <EOL> except Exception as ex : <EOL> if not str ( ex ) . startswith ( "<STR_LIT>" ) : <EOL> import traceback <EOL> print ( traceback . format_exc ( ) . strip ( ) ) <EOL> print ( ERROR_SETTINGS ) <EOL> sys . exit ( ) <EOL> if check_db : <EOL> check_database ( ) <EOL> global SERVER_PY_FILE , PORTAL_PY_FILE <EOL> global SERVER_LOGFILE , PORTAL_LOGFILE , HTTP_LOGFILE <EOL> global SERVER_PIDFILE , PORTAL_PIDFILE <EOL> global SERVER_RESTART , PORTAL_RESTART <EOL> global EVENNIA_VERSION <EOL> SERVER_PY_FILE = os . path . join ( EVENNIA_LIB , "<STR_LIT>" , "<STR_LIT>" ) <EOL> PORTAL_PY_FILE = os . path . join ( EVENNIA_LIB , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> SERVER_PIDFILE = os . path . join ( GAMEDIR , SERVERDIR , "<STR_LIT>" ) <EOL> PORTAL_PIDFILE = os . path . join ( GAMEDIR , SERVERDIR , "<STR_LIT>" ) <EOL> SERVER_RESTART = os . path . join ( GAMEDIR , SERVERDIR , "<STR_LIT>" ) <EOL> PORTAL_RESTART = os . path . join ( GAMEDIR , SERVERDIR , "<STR_LIT>" ) <EOL> SERVER_LOGFILE = settings . SERVER_LOG_FILE <EOL> PORTAL_LOGFILE = settings . PORTAL_LOG_FILE <EOL> HTTP_LOGFILE = settings . HTTP_LOG_FILE <EOL> logdirs = [ logfile . rsplit ( os . path . sep , <NUM_LIT:1> ) <EOL> for logfile in ( SERVER_LOGFILE , PORTAL_LOGFILE , HTTP_LOGFILE ) ] <EOL> if not all ( os . path . isdir ( pathtup [ <NUM_LIT:0> ] ) for pathtup in logdirs ) : <EOL> errstr = "<STR_LIT>" . join ( "<STR_LIT>" % ( pathtup [ <NUM_LIT:0> ] , pathtup [ <NUM_LIT:1> ] ) for pathtup in logdirs <EOL> if not os . path . isdir ( pathtup [ <NUM_LIT:0> ] ) ) <EOL> print ( ERROR_LOGDIR_MISSING . format ( logfiles = errstr ) ) <EOL> sys . exit ( ) <EOL> if os . name == '<STR_LIT>' : <EOL> global TWISTED_BINARY <EOL> server_path = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> TWISTED_BINARY = os . path . join ( server_path , "<STR_LIT>" ) <EOL> sys . path . insert ( <NUM_LIT:1> , os . path . join ( GAMEDIR , SERVERDIR ) ) <EOL> try : <EOL> importlib . import_module ( "<STR_LIT>" ) <EOL> except ImportError : <EOL> print ( ERROR_WINDOWS_WIN32API ) <EOL> sys . exit ( ) <EOL> batpath = os . path . join ( EVENNIA_SERVER , TWISTED_BINARY ) <EOL> if not os . path . exists ( batpath ) : <EOL> twistd = importlib . import_module ( "<STR_LIT>" ) <EOL> twistd_dir = os . path . dirname ( twistd . __file__ ) <EOL> twistd_path = os . path . abspath ( <EOL> os . path . join ( twistd_dir , os . pardir , os . pardir , os . pardir , <EOL> os . pardir , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> with open ( batpath , '<STR_LIT:w>' ) as bat_file : <EOL> bat_file . write ( "<STR_LIT>" % ( <EOL> sys . executable , twistd_path ) ) <EOL> print ( INFO_WINDOWS_BATFILE . format ( twistd_path = twistd_path ) ) <EOL> def run_dummyrunner ( number_of_dummies ) : <EOL> """<STR_LIT>""" <EOL> number_of_dummies = str ( int ( number_of_dummies ) ) if number_of_dummies else <NUM_LIT:1> <EOL> cmdstr = [ sys . executable , EVENNIA_DUMMYRUNNER , "<STR_LIT>" , number_of_dummies ] <EOL> config_file = os . path . join ( SETTINGS_PATH , "<STR_LIT>" ) <EOL> if os . path . exists ( config_file ) : <EOL> cmdstr . extend ( [ "<STR_LIT>" , config_file ] ) <EOL> try : <EOL> call ( cmdstr , env = getenv ( ) ) <EOL> except KeyboardInterrupt : <EOL> pass <EOL> def list_settings ( keys ) : <EOL> """<STR_LIT>""" <EOL> from importlib import import_module <EOL> from evennia . utils import evtable <EOL> evsettings = import_module ( SETTINGS_DOTPATH ) <EOL> if len ( keys ) == <NUM_LIT:1> and keys [ <NUM_LIT:0> ] . upper ( ) == "<STR_LIT>" : <EOL> table = evtable . EvTable ( ) <EOL> confs = [ key for key in sorted ( evsettings . __dict__ ) if key . isupper ( ) ] <EOL> for i in range ( <NUM_LIT:0> , len ( confs ) , <NUM_LIT:4> ) : <EOL> table . add_row ( * confs [ i : i + <NUM_LIT:4> ] ) <EOL> else : <EOL> table = evtable . EvTable ( width = <NUM_LIT> ) <EOL> keys = [ key . upper ( ) for key in keys ] <EOL> confs = dict ( ( key , var ) for key , var in evsettings . __dict__ . items ( ) <EOL> if key in keys ) <EOL> for key , val in confs . items ( ) : <EOL> table . add_row ( key , str ( val ) ) <EOL> print ( table ) <EOL> def run_menu ( ) : <EOL> """<STR_LIT>""" <EOL> while True : <EOL> print ( MENU ) <EOL> inp = input ( "<STR_LIT>" ) <EOL> if inp . lower ( ) == '<STR_LIT:q>' : <EOL> return <EOL> elif inp . lower ( ) == '<STR_LIT:h>' : <EOL> print ( HELP_ENTRY ) <EOL> input ( "<STR_LIT>" ) <EOL> continue <EOL> elif inp . lower ( ) in ( '<STR_LIT:v>' , '<STR_LIT:i>' , '<STR_LIT:a>' ) : <EOL> print ( show_version_info ( about = True ) ) <EOL> input ( "<STR_LIT>" ) <EOL> continue <EOL> try : <EOL> inp = int ( inp ) <EOL> except ValueError : <EOL> print ( "<STR_LIT>" ) <EOL> continue <EOL> if inp == <NUM_LIT:1> : <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT:all>" , False , False ) <EOL> elif inp == <NUM_LIT:2> : <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT:all>" , True , False ) <EOL> elif inp == <NUM_LIT:3> : <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT>" , False , False ) <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT>" , True , False ) <EOL> elif inp == <NUM_LIT:4> : <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT>" , True , False ) <EOL> server_operation ( "<STR_LIT:start>" , "<STR_LIT>" , True , False ) <EOL> elif inp == <NUM_LIT:5> : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT>" , None , None ) <EOL> elif inp == <NUM_LIT:6> : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT>" , None , None ) <EOL> elif inp == <NUM_LIT:7> : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT:all>" , None , None ) <EOL> elif inp == <NUM_LIT:8> : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT>" , None , None ) <EOL> elif inp == <NUM_LIT:9> : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT>" , None , None ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> continue <EOL> return <EOL> def server_operation ( mode , service , interactive , profiler , logserver = False ) : <EOL> """<STR_LIT>""" <EOL> cmdstr = [ sys . executable , EVENNIA_RUNNER ] <EOL> errmsg = "<STR_LIT>" <EOL> if mode == '<STR_LIT:start>' : <EOL> error_check_python_modules ( ) <EOL> if service == '<STR_LIT>' : <EOL> if profiler : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> if interactive : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> if logserver : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> elif service == '<STR_LIT>' : <EOL> if profiler : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> if interactive : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> django . core . management . call_command ( <EOL> '<STR_LIT>' , verbosity = <NUM_LIT:1> , interactive = False ) <EOL> else : <EOL> if profiler : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> if interactive : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> if logserver : <EOL> cmdstr . append ( '<STR_LIT>' ) <EOL> django . core . management . call_command ( <EOL> '<STR_LIT>' , verbosity = <NUM_LIT:1> , interactive = False ) <EOL> cmdstr . extend ( [ <EOL> GAMEDIR , TWISTED_BINARY , SERVER_LOGFILE , <EOL> PORTAL_LOGFILE , HTTP_LOGFILE ] ) <EOL> process = Popen ( cmdstr , env = getenv ( ) ) <EOL> if interactive : <EOL> try : <EOL> process . wait ( ) <EOL> except KeyboardInterrupt : <EOL> server_operation ( "<STR_LIT>" , "<STR_LIT>" , False , False ) <EOL> return <EOL> finally : <EOL> print ( NOTE_KEYBOARDINTERRUPT ) <EOL> elif mode == '<STR_LIT>' : <EOL> if os . name == '<STR_LIT>' : <EOL> print ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return <EOL> if service == '<STR_LIT>' : <EOL> kill ( SERVER_PIDFILE , SIG , "<STR_LIT>" , <EOL> errmsg % '<STR_LIT>' , SERVER_RESTART , restart = True ) <EOL> elif service == '<STR_LIT>' : <EOL> print ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> kill ( PORTAL_PIDFILE , SIG , <EOL> "<STR_LIT>" , <EOL> errmsg % '<STR_LIT>' , PORTAL_RESTART , restart = True ) <EOL> else : <EOL> kill ( SERVER_PIDFILE , SIG , <EOL> "<STR_LIT>" , <EOL> errmsg % '<STR_LIT>' , SERVER_RESTART , restart = True ) <EOL> elif mode == '<STR_LIT>' : <EOL> if service == '<STR_LIT>' : <EOL> kill ( SERVER_PIDFILE , SIG , <EOL> "<STR_LIT>" , errmsg % '<STR_LIT>' , SERVER_RESTART ) <EOL> elif service == '<STR_LIT>' : <EOL> kill ( PORTAL_PIDFILE , SIG , <EOL> "<STR_LIT>" , errmsg % '<STR_LIT>' , PORTAL_RESTART ) <EOL> else : <EOL> kill ( PORTAL_PIDFILE , SIG , <EOL> "<STR_LIT>" , errmsg % '<STR_LIT>' , PORTAL_RESTART ) <EOL> kill ( SERVER_PIDFILE , SIG , <EOL> "<STR_LIT>" , errmsg % '<STR_LIT>' , SERVER_RESTART ) <EOL> def main ( ) : <EOL> """<STR_LIT>""" <EOL> parser = ArgumentParser ( description = CMDLINE_HELP ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> dest = "<STR_LIT>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store>' , dest = "<STR_LIT>" , metavar = "<STR_LIT:name>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , nargs = '<STR_LIT:+>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , metavar = "<STR_LIT:key>" , <EOL> help = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , nargs = <NUM_LIT:1> , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> metavar = "<STR_LIT:N>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , nargs = <NUM_LIT:1> , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , <EOL> default = None , metavar = "<STR_LIT>" , <EOL> help = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , nargs = '<STR_LIT:?>' , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , metavar = "<STR_LIT>" , nargs = '<STR_LIT:?>' , default = "<STR_LIT:all>" , <EOL> help = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> parser . epilog = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> args , unknown_args = parser . parse_known_args ( ) <EOL> option , service = args . option , args . service <EOL> check_main_evennia_dependencies ( ) <EOL> if not args : <EOL> print ( CMDLINE_HELP ) <EOL> sys . exit ( ) <EOL> elif args . init : <EOL> create_game_directory ( args . init ) <EOL> print ( CREATED_NEW_GAMEDIR . format ( <EOL> gamedir = args . init , <EOL> settings_path = os . path . join ( args . init , SETTINGS_PATH ) ) ) <EOL> sys . exit ( ) <EOL> if args . show_version : <EOL> print ( show_version_info ( option == "<STR_LIT>" ) ) <EOL> sys . exit ( ) <EOL> if args . altsettings : <EOL> sfile = args . altsettings [ <NUM_LIT:0> ] <EOL> global SETTINGSFILE , SETTINGS_DOTPATH <EOL> SETTINGSFILE = sfile <EOL> SETTINGS_DOTPATH = "<STR_LIT>" % sfile . rstrip ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" % ( <EOL> SETTINGSFILE , SETTINGS_DOTPATH ) ) <EOL> if args . dummyrunner : <EOL> init_game_directory ( CURRENT_DIR , check_db = True ) <EOL> run_dummyrunner ( args . dummyrunner [ <NUM_LIT:0> ] ) <EOL> elif args . listsetting : <EOL> init_game_directory ( CURRENT_DIR , check_db = False ) <EOL> list_settings ( args . listsetting ) <EOL> elif option == '<STR_LIT>' : <EOL> init_game_directory ( CURRENT_DIR , check_db = True ) <EOL> run_menu ( ) <EOL> elif option in ( '<STR_LIT:start>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> init_game_directory ( CURRENT_DIR , check_db = True ) <EOL> server_operation ( option , service , args . interactive , args . profiler , args . logserver ) <EOL> elif option != "<STR_LIT>" : <EOL> check_db = False <EOL> if option in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> print ( WARNING_RUNSERVER ) <EOL> if option == "<STR_LIT>" : <EOL> check_db = True <EOL> init_game_directory ( CURRENT_DIR , check_db = check_db ) <EOL> args = [ option ] <EOL> kwargs = { } <EOL> if service not in ( "<STR_LIT:all>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> args . append ( service ) <EOL> if unknown_args : <EOL> for arg in unknown_args : <EOL> if arg . startswith ( "<STR_LIT>" ) : <EOL> print ( "<STR_LIT>" , arg ) <EOL> if "<STR_LIT:=>" in arg : <EOL> arg , value = [ p . strip ( ) for p in arg . split ( "<STR_LIT:=>" , <NUM_LIT:1> ) ] <EOL> else : <EOL> value = True <EOL> kwargs [ arg . lstrip ( "<STR_LIT>" ) ] = [ value ] <EOL> else : <EOL> args . append ( arg ) <EOL> try : <EOL> django . core . management . call_command ( * args , ** kwargs ) <EOL> except django . core . management . base . CommandError as exc : <EOL> args = "<STR_LIT:U+002CU+0020>" . join ( args ) <EOL> kwargs = "<STR_LIT:U+002CU+0020>" . join ( [ "<STR_LIT>" % kw for kw in kwargs ] ) <EOL> print ( ERROR_INPUT . format ( traceback = exc , args = args , kwargs = kwargs ) ) <EOL> else : <EOL> print ( ABOUT_INFO ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
