Exemplo n.º 1
0
def exitCleanly(
        *args
):  #args may contain SIGnumber and other info when called from atexit
    if oscServerThread:
        print("stopping the heartbeat")
        OSCserver.heartbeat = False
        heartbeatThread.join()
        print("closing the OSC server")
        OSCserver.runServer = False
    if peakDetector:
        print("closing the peak detector")
        peakDetector.isListening = False
        peakDetector.stopListening()
    print("exiting jack client ...")
    audio.close()

    raise SystemExit
Exemplo n.º 2
0
def start_basic():
    """ Load & run programs and commands and hand over to interactive mode. """
    import program
    import run
    import error
    import state
    import devices
    import disk
    import cassette
    import reset
    import sound
    import audio
    do_reset = False
    backend, console = None, None
    exit_error = ''
    try:
        # resume from saved emulator state if requested and available
        resume = config.get('resume') and state.load()
        # choose the video and sound backends
        backend, console = prepare_console()
        # greet, load and run only if not resuming
        if resume:
            # override selected settings from command line
            cassette.override()
            disk.override()
            # suppress double prompt
            if not state.basic_state.execute_mode:
                state.basic_state.prompt = False
            run.start('', False, config.get('quit'))
        else:
            # load/run program
            config.options['run'] = config.get(1) or config.get('run')
            prog = config.get('run') or config.get('load')
            if prog:
                # on load, accept capitalised versions and default extension
                with open_native_or_dos_filename(prog) as progfile:
                    program.load(progfile)
                reset.clear()
            print_greeting(console)
            # start the interpreter (and get out if we ran with -q)
            run.start(config.get('exec'), config.get('run'), config.get('quit'))
    except error.RunError as e:
        exit_error = error.get_message(e.err)
    except error.Exit:
        # pause before exit if requested
        if config.get('wait'):
            backend.video_queue.put(backend.Event(backend.VIDEO_SET_CAPTION, 'Press a key to close window'))
            backend.video_queue.put(backend.Event(backend.VIDEO_SHOW_CURSOR, False))
            state.console_state.keyb.pause = True
            # this performs a blocking keystroke read if in pause state
            backend.check_events()
    except error.Reset:
        do_reset = True
    except KeyboardInterrupt:
        if config.get('debug'):
            raise
    except Exception as e:
        print traceback.print_exc()
        exit_error = "Unhandled exception\n%s" % traceback.format_exc()
    finally:
        try:
            audio.close()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing audio: %s', e)
        try:
            # fix the terminal on exit (important for ANSI terminals)
            # and save display interface state into screen state
            state.console_state.screen.close()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing screen: %s', e)
        # delete state if resetting
        if do_reset:
            state.delete()
            if plat.system == 'Android':
                shutil.rmtree(plat.temp_dir)
        else:
            state.save()
        try:
            # close files if we opened any
            devices.close_files()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing files: %s', e)
        try:
            devices.close_devices()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing devices: %s', e)
        if exit_error:
            logging.error(exit_error)
Exemplo n.º 3
0
#!/usr/local/bin/kivy
from kivy.clock import Clock

import audio
import network
import gui
import control

if __name__ == '__main__':
    audio.init()
    network.init()
    control.init()

    Clock.schedule_interval(control.run, 0.0002)
    Clock.schedule_interval(network.run, 0.0002)
    gui.run()

    control.close()
    network.close()
    audio.close()
Exemplo n.º 4
0
def close():
    audio.close()
Exemplo n.º 5
0
def start_basic():
    """ Load & run programs and commands and hand over to interactive mode. """
    import program
    import run
    import error
    import state
    import devices
    import disk
    import cassette
    import reset
    import sound
    import audio
    do_reset = False
    backend, console = None, None
    exit_error = ''
    try:
        # resume from saved emulator state if requested and available
        resume = config.get('resume') and state.load()
        # choose the video and sound backends
        backend, console = prepare_console()
        # greet, load and run only if not resuming
        if resume:
            # override selected settings from command line
            cassette.override()
            disk.override()
            # suppress double prompt
            if not state.basic_state.execute_mode:
                state.basic_state.prompt = False
            run.start('', False, config.get('quit'))
        else:
            # load/run program
            config.options['run'] = config.get(0) or config.get('run')
            prog = config.get('run') or config.get('load')
            if prog:
                # on load, accept capitalised versions and default extension
                with open_native_or_dos_filename(prog) as progfile:
                    program.load(progfile)
                reset.clear()
            print_greeting(console)
            # start the interpreter (and get out if we ran with -q)
            run.start(config.get('exec'), config.get('run'),
                      config.get('quit'))
    except error.RunError as e:
        exit_error = e.message
    except error.Exit:
        # pause before exit if requested
        if config.get('wait'):
            backend.video_queue.put(
                backend.Event(backend.VIDEO_SET_CAPTION,
                              'Press a key to close window'))
            backend.video_queue.put(
                backend.Event(backend.VIDEO_SHOW_CURSOR, False))
            state.console_state.keyb.pause = True
            # this performs a blocking keystroke read if in pause state
            backend.check_events()
    except error.Reset:
        do_reset = True
    except KeyboardInterrupt:
        if config.get('debug'):
            raise
    except Exception as e:
        exit_error = "Unhandled exception\n%s" % traceback.format_exc()
    finally:
        try:
            audio.close()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing audio: %s', e)
        try:
            # fix the terminal on exit (important for ANSI terminals)
            # and save display interface state into screen state
            state.console_state.screen.close()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing screen: %s', e)
        # delete state if resetting
        if do_reset:
            state.delete()
            if plat.system == 'Android':
                shutil.rmtree(plat.temp_dir)
        else:
            state.save()
        try:
            # close files if we opened any
            devices.close_files()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing files: %s', e)
        try:
            devices.close_devices()
        except (NameError, AttributeError) as e:
            logging.debug('Error on closing devices: %s', e)
        if exit_error:
            logging.error(exit_error)