def main(): # Add HappyBoom to PYTHONPATH ("../" today, but should be improved) import sys, os file_dir = os.path.dirname(__file__) happyboomdir = os.path.join(file_dir, "../happyboom/trunk") sys.path.append(happyboomdir) # Get user directory from happyboom.common.file import getCreateHomeDir logdir = getCreateHomeDir("boomboom") # Setup log filename from happyboom.common.log import log if logdir != None: logname = os.path.join(logdir, "client-log") log.setFilename(logname) # Read command line arguments val = { "host": "127.0.0.1", \ "port": 12430, \ "max_fps": 50, \ "verbose": False, \ "textmode": False, \ "server-log": False, \ "name": "-", \ "debug": False, \ "item_path": "client/items"} arg = parseArgs(val) textmode = arg["textmode"] # Create the client if not textmode: log.info("Start client with pygame.") import pygame pygame.init() from client import Client run(Client, arg) pygame.quit() else: log.info("Start client with curses.") import curses curses.wrapper(run_curses, arg) log.use_print = True log.info("Quit.")
def main(): # Add HappyBoom to PYTHONPATH import sys, os file_dir = os.path.dirname(__file__) happyboomdir = os.path.join(file_dir, "..", "happyboom", "trunk") sys.path.append(happyboomdir) # Get user directory from happyboom.common.file import getCreateHomeDir logdir = getCreateHomeDir("boomboom") # Setup log filename from happyboom.common.log import log if logdir != None: logname = os.path.join(logdir, "server-log") log.setFilename(logname) # Read command line arguments val = { \ "input_port": 12430, "max_clients": 4, "verbose": False, "debug": False} arg = parseArgs(val) # Create BoomBoom server from server.bb_server import Server from happyboom.common.protocol import loadProtocol protocol = loadProtocol("protocol.xml") server = Server(protocol, arg) # Main loop try: server.start() except KeyboardInterrupt: log.info("Program interrupted (CTRL+C).") pass # Stop the server server.stop()
def init(): global log # Add HappyBoom to PYTHONPATH ("../" today, but should be improved) import sys, os file_dir = os.path.dirname(__file__) happyboomdir = os.path.join(file_dir, "../happyboom/trunk") sys.path.append(happyboomdir) # Get user directory from happyboom.common.file import getCreateHomeDir logdir = getCreateHomeDir("happywarry") # Setup log filename from happyboom.common.log import log if logdir != None: logname = os.path.join(logdir, "server-log") log.setFilename(logname) # Setup gettext localedir = os.path.join(file_dir, "locale") gettext.install('happywarry', localedir, unicode=1)