Exemplo n.º 1
0
 def __init__(self):
     logging.basicConfig(format="[%(levelname)s]%(message)s",
                                     filename="world_master.log",
                                     level=logging.DEBUG)
     self.logger = logging.getLogger("Logon")
     conflevel = Config()
     conflevel.initialize()
     self.logger.setLevel(conflevel.get_loggin_level())
Exemplo n.º 2
0
class Main:
    def __init__(self):
        self.log = Logging()
        self.config = Config()
        self.console = Console()
        self.console.clear()

    def start(self):
        #  ======================================================
        #  start message

        def clear():
            return os.system('cls')

        clear()

        def wel():
            welmsg = [
                58 * '─', '|  0.01  |' + 12 * ' ' +
                'pyCestra -  World Server' + 11 * ' ' + '|', 58 * "─"
            ]
            for x in welmsg:
                print(bcolors.blue + x + bcolors.cend)

        wel()

        #  ======================================================
        #  connection test

        self.log.info('Connection Test...')
        database = dataSource.Database()
        if database.get_connection():
            self.log.info('Connection Successfully')
        else:
            self.log.warning('Connection ERROR')
            sys.exit(0)

        #  ======================================================
        #  world class test
        world = World()
        world.createWorld()
        #  ======================================================
        #  exchange client test

        exchangeTransferList = []
        exClient = ExchangeClient()
        exClient.initialize(self.config.get_exchange_ip(),
                            self.config.get_exchange_port(),
                            exchangeTransferList)

        self.log.debug('Game Server Start')
        GameServer().initialize(self.config.get_world_ip(),
                                self.config.get_world_port(),
                                exchangeTransferList, world)
Exemplo n.º 3
0
    def get_connection(self):
        config = Config()
        config.initialize()
        try:
            connection = pymysql.connect(
                host=config.get_host(),
                port=config.get_port(),
                user=config.get_user(),
                password=config.get_pass(),
                db=config.get_database_name(),
                cursorclass=pymysql.cursors.DictCursor)
            return connection

        except pymysql.Error as Error:
            self.log.warning('Database - initialize_connection\n' +
                             'Config: ' + str(config.get_host()) + ' - ' +
                             str(config.get_port()) + ' - ' +
                             str(config.get_user()) + ' - ' +
                             str(config.get_pass()) + ' - ' +
                             str(config.get_database_name()) +
                             '\nDatabase - inicon - Something went wrong: {}'.
                             format(str(Error)))
            return False
Exemplo n.º 4
0
 def __init__(self):
     self.log = Logging()
     self.config = Config()
     self.console = Console()
     self.console.clear()
Exemplo n.º 5
0
    def get_connection(self):
        config = Config()
        config.initialize()
        try:
            connection = mysql.connector.connect(
                host=config.get_world_db_host(),
                port=config.get_world_db_port(),
                user=config.get_world_db_user(),
                password=config.get_world_db_passwo(),
                db=config.get_world_db_name(),
                auth_plugin='mysql_native_password')
            return connection

        except mysql.connector.Error as Error:
            self.log.warning(
                'Database - initialize_connection\n' + 'Config: ' +
                str(config.get_world_db_host()) + ' - ' +
                str(config.get_world_db_port()) + ' - ' +
                str(config.get_world_db_user()) + ' - ' +
                str(config.get_world_db_passwo()) + ' - ' +
                str(config.get_world_db_name()) +
                '\nDatabase - Something went wrong: {}'.format(str(Error)))
            return False
Exemplo n.º 6
0
def main():
    #  ======================================================
    #  start message

    log = Logging()
    console = Console()
    console.clear()

    def wel():
        welmsg = [
            58 * '─', '|  0.01  |' + 12 * ' ' + 'pyCestra - Logon Server' +
            12 * ' ' + '|', 58 * "─"
        ]
        for x in welmsg:
            print(bcolors.blue + x + bcolors.cend)

    wel()

    # ======================================================
    # preload data

    config = Config()
    config.initialize()

    log.info('Connection Test...')
    database = dataSource.Database()
    if database.get_connection():
        log.info('Connection Successfully')
    else:
        log.warning('Connection ERROR')
        sys.exit(0)

    hostList = dataSource.ServerData()
    hostList.load()
    hostList = hostList.get_server_data()
    log.info('ServerData were loaded')

    accountData = dataSource.AccountData()
    accountData.load()
    accountDataDic = accountData.get_account_data()
    log.info('AccountData were loaded')

    ipbans = dataSource.IpBans().load()
    log.info('IP Bans were loaded')

    dataSource.DatabaseUpdateService().start(accountDataDic,
                                             config.get_update_time())

    # ======================================================
    # socket tests

    print(58 * '-')

    game_client_dic = {}

    LoginServer(config.get_login_ip(), config.get_login_port(),
                game_client_dic, accountDataDic, hostList, ipbans)

    ExchangeServer().start(config.get_exchange_ip(),
                           config.get_exchange_port(), hostList)

    while True:
        time.sleep(15)
        if game_client_dic:
            log.warning('---- game_client_dic ----')
            for x in game_client_dic:
                log.warning(str(x))
            log.warning('-------------------------')