コード例 #1
0
def main():
    console_type = 'curses'
    if '--pygame' in sys.argv:
        console_type = 'pygame'
    if PLATFORM_SYSTEM == 'Windows':
        console_type = 'pygame'
    #
    # Snake is a good go-to program for testing. Hence, I like to leave this
    # in, commented out.
    '''
    init_network_logging(
        mtu=MTU,
        addr='127.255.255.255',
        port=7789,
        label='snake')
    '''
    #
    engine = Engine(mtu=MTU)
    try:
        engine.default_timeout = 0.01
        init_nearcast(engine=engine, console_type=console_type)
        #
        engine.event_loop()
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #2
0
ファイル: snake.py プロジェクト: Evanerfbdgcn/solent
def main():
    console_type = 'curses'
    if '--pygame' in sys.argv:
        console_type = 'pygame'
    elif sys.platform in ('msys', 'win32', 'win64'):
        b_ok = True
        try:
            import pygame
            console_type = 'pygame'
        except:
            print("[!] On Windows, snake needs pygame. (But, try winsnake!).")
            sys.exit(1)
    #
    engine = Engine(
        mtu=MTU)
    try:
        engine.default_timeout = 0.01
        init_nearcast(
            engine=engine,
            console_type=console_type)
        #
        engine.event_loop()
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #3
0
ファイル: redis_client.py プロジェクト: solent-eng/solent
def main():
    init_logging()
    #
    engine = None
    try:
        engine = Engine(mtu=MTU)
        #
        orb = engine.init_orb(i_nearcast=I_NEARCAST_SCHEMA)
        orb.init_cog(CogLineConsole)
        orb.init_cog(CogInterpreter)
        orb.init_cog(CogRedisClient)
        #
        bridge = orb.init_autobridge()
        bridge.nc_init()
        #
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    except:
        traceback.print_exc()
    finally:
        if engine != None:
            engine.close()
コード例 #4
0
ファイル: weeds.py プロジェクト: mchi/solent
def game(console_type):
    engine = None
    try:
        engine = Engine(
            mtu=MTU)
        engine.set_default_timeout(0.04)
        #engine.debug_eloop_on()
        #
        orb = engine.init_orb(
            i_nearcast=I_CONTAINMENT_NEARCAST_SCHEMA)
        #orb.add_log_snoop()
        orb.init_cog(CogInterpreter)
        orb.init_cog(CogToTerm)
        orb.init_cog(CogToMenu)
        orb.init_cog(CogToRoguebox)
        #
        bridge = orb.init_autobridge()
        bridge.nearcast.prime_console(
            console_type=console_type,
            console_height=CONSOLE_HEIGHT,
            console_width=CONSOLE_WIDTH)
        bridge.nearcast.init()
        #
        engine.event_loop()
    except SolentQuitException:
        pass
    except:
        traceback.print_exc()
    finally:
        if engine != None:
            engine.close()
コード例 #5
0
def main():
    engine = Engine(mtu=MTU)
    try:
        init(engine=engine)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #6
0
ファイル: snake.py プロジェクト: solent-eng/solent
def launch(console_type):
    engine = Engine(mtu=MTU)
    try:
        engine.default_timeout = 0.01
        init_nearcast(engine=engine, console_type=console_type)
        #
        engine.event_loop()
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #7
0
ファイル: mud.py プロジェクト: solent-eng/solent
def main():
    engine = Engine(mtu=MTU)
    try:
        init_nearcast(engine=engine,
                      linetalk_addr=LINETALK_ADDR,
                      linetalk_port=LINETALK_PORT)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #8
0
def main():
    engine = Engine(mtu=MTU)
    try:
        init(engine=engine,
             console_addr=CONSOLE_ADDR,
             console_port=CONSOLE_PORT)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #9
0
def main():
    (_cmd, bulk_addr, bulk_port) = sys.argv
    bulk_port = int(bulk_port)

    engine = Engine(mtu=MTU)
    try:
        bridge = init_nearcast(engine=engine,
                               cons_addr=CONS_ADDR,
                               cons_port=CONS_PORT,
                               bulk_addr=bulk_addr,
                               bulk_port=bulk_port)

        engine.event_loop()
    finally:
        engine.close()
コード例 #10
0
def main():
    engine = Engine(mtu=MTU)
    try:
        orb = engine.init_orb(i_nearcast=I_NEARCAST)
        orb.add_log_snoop()
        orb.init_cog(CogInterpret)
        orb.init_cog(CogToLineConsole)
        bridge = orb.init_cog(CogBridge)
        bridge.nc_init()
        engine.event_loop()
    except SolentQuitException:
        pass
    except KeyboardInterrupt:
        pass
    finally:
        engine.close()
コード例 #11
0
def main():
    engine = Engine(mtu=MTU)
    engine.set_default_timeout(0.0)
    try:
        orb = engine.init_orb(i_nearcast=I_NEARCAST)
        orb.init_cog(CogSdlWorld)
        #
        bridge = orb.init_autobridge()
        bridge.nc_init(title='Game', width=1000, height=600)
        #
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #12
0
def main():
    print("This is stub code to allow us to create a native-Windows console")
    print("At the time of writing, that console is unfinished.")
    print("(Hence, this will crash shortly.)")
    #
    console_type = 'windows'
    #
    engine = Engine(
        mtu=MTU)
    try:
        engine.default_timeout = 0.01
        launch(
            engine=engine,
            console_type=console_type)
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #13
0
def main():
    engine = Engine(mtu=MTU)
    engine.set_default_timeout(0.08)
    #
    try:
        init_nearcast(engine=engine,
                      lc_addr=LC_ADDR,
                      lc_port=LC_PORT,
                      console_width=CONSOLE_WIDTH,
                      console_height=CONSOLE_HEIGHT)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
        log("after engine close")
コード例 #14
0
ファイル: bulk_recv.py プロジェクト: solent-eng/solent
def main():
    (_cmd, dir_save, bulk_addr, bulk_port) = sys.argv
    bulk_port = int(bulk_port)

    if not os.path.exists(dir_save):
        raise Exception("No dir at %s" % (dir_save))
    if not os.path.isdir(dir_save):
        raise Exception("Path at %s is not a directory." % (dir_save))

    engine = Engine(mtu=MTU)
    try:
        bridge = init_nearcast(engine=engine,
                               bulk_addr=bulk_addr,
                               bulk_port=bulk_port,
                               dir_save=dir_save)
        engine.event_loop()
    finally:
        engine.close()
コード例 #15
0
def main():
    if '--help' in sys.argv:
        usage()
    if 3 != len(sys.argv):
        usage()
    (_, addr, port) = sys.argv
    port = int(port)
    #
    engine = Engine(mtu=MTU)
    try:
        init_nearcast(engine=engine, addr=addr, port=port)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #16
0
def main():
    if 3 != len(sys.argv):
        usage()
    #
    engine = Engine(mtu=MTU)
    try:
        net_addr = sys.argv[1]
        net_port = int(sys.argv[2])
        #
        init_nearcast(engine=engine, net_addr=net_addr, net_port=net_port)
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    except:
        traceback.print_exc()
    finally:
        engine.close()
コード例 #17
0
ファイル: gollop_box.py プロジェクト: solent-eng/solent
def main():
    init_logging()
    #
    engine = None
    try:
        engine = Engine(
            mtu=MTU)
        engine.default_timeout = 0.04
        #
        orb = engine.init_orb(
            i_nearcast=I_NEARCAST_SCHEMA)
        orb.init_cog(CogInterpreter)
        orb.init_cog(CogTerm)
        engine.event_loop()
    except SolentQuitException:
        pass
    except:
        traceback.print_exc()
    finally:
        if engine != None:
            engine.close()
コード例 #18
0
def main():
    engine = Engine(
        mtu=MTU)
    try:
        orb = engine.init_orb(
            i_nearcast=I_NEARCAST)
        orb.add_log_snoop()
        orb.init_cog(CogInterpret)
        orb.init_cog(CogToLinetalk)
        bridge = orb.init_autobridge()
        bridge.nc_prime(
            username='******',
            password='******')
        bridge.nc_init()
        engine.event_loop()
    except SolentQuitException:
        pass
    except KeyboardInterrupt:
        pass
    finally:
        engine.close()
コード例 #19
0
ファイル: weeds.py プロジェクト: solent-eng/solent
def main():
    console_type = 'curses'
    init_network_logging(
        mtu=1490,
        addr=get_broadcast(),
        port=4999,
        label=__name__)
    log("Log opened.")

    engine = None
    try:
        engine = Engine(
            mtu=MTU)
        engine.set_default_timeout(0.04)
        #engine.debug_eloop_on()
        #
        orb = engine.init_orb(
            i_nearcast=I_CONTAINMENT_NEARCAST_SCHEMA)
        orb.add_log_snoop()
        orb.init_cog(CogInterpreter)
        orb.init_cog(CogToTerm)
        orb.init_cog(CogToMenu)
        orb.init_cog(CogToRoguebox)
        #
        bridge = orb.init_autobridge()
        bridge.nearcast.prime_console(
            console_type=console_type,
            console_height=CONSOLE_HEIGHT,
            console_width=CONSOLE_WIDTH)
        bridge.nearcast.init()
        #
        engine.event_loop()
    except SolentQuitException:
        pass
    except:
        traceback.print_exc()
    finally:
        if engine != None:
            engine.close()
コード例 #20
0
ファイル: winsnake.py プロジェクト: solent-eng/solent
def main():
    p = sys.platform
    #
    if p not in ('msys', 'win32', 'win64'):
        m = ' '.join([
            "ERROR: winsnake only works on windows.",
            "Try solent.demo.snake for other platforms.",
            "(sys.platform: |%s|)" % (p)
        ])
        print(m)
        sys.exit(1)
    #
    engine = Engine(mtu=MTU)
    engine.default_timeout = 0.01
    #
    try:
        init_nearcast(engine=engine, game_name=GAME_NAME)
        engine.event_loop()
    except SolentQuitException:
        pass
    finally:
        engine.close()
コード例 #21
0
def main():
    print('''test this with
        echo "Hello" | socat - UDP-DATAGRAM:%s:%s,broadcast
    Or
        python3 -m solent.tools.qd_poll 127.255.255.255 50000
    ''' % (NET_ADDR, NET_PORT))
    #
    engine = Engine(mtu=MTU)
    try:
        init(engine=engine, net_addr=NET_ADDR, net_port=NET_PORT)
        #
        # You can use this to print more info about the event loop. This would be
        # useful if you had a flailing event loop and could not work out what was
        # causing the activity.
        engine.debug_eloop_on()
        engine.event_loop()
    except KeyboardInterrupt:
        pass
    except SolentQuitException:
        pass
    finally:
        engine.close()