예제 #1
0
파일: cli.py 프로젝트: jedie/DragonPy
    def setup_logging(self):
        handler = logging.StreamHandler()

        # Setup root logger
        setup_logging(
            level=self.verbosity,
            logger_name=None, # Use root logger
            handler=handler,
            log_formatter=self.log_formatter
        )

        if self.log is None:
            return

        # Setup given loggers
        for logger_cfg in self.log:
            logger_name, level = logger_cfg.rsplit(",", 1)
            level = int(level)

            setup_logging(
                level=level,
                logger_name=logger_name,
                handler=handler,
                log_formatter=self.log_formatter
            )
예제 #2
0
파일: basic.py 프로젝트: 6809/dragonlib
def _test_reformat():
    from dragonlib.utils.logging_utils import setup_logging

    setup_logging(
#        level=1 # hardcore debug ;)
#         level=10  # DEBUG
#         level=20  # INFO
#         level=30  # WARNING
#         level=40 # ERROR
#         level=50 # CRITICAL/FATAL
        level=99
    )

    from dragonlib.api import Dragon32API
    api = Dragon32API()

    # filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),
    #     # "..", "BASIC examples", "hex_view01.bas"
    #     "..", "..", "BASIC games", "INVADER.bas"
    # )
    #
    # with open(filepath, "r") as f:
    #     listing_ascii = f.read()

    listing_ascii="""\
10 ONPOINT(Y,K)GOTO250,250'ONPOINT(Y,K)GOTO250,250
20 FORT=479TO 542:T(T)=0:Y(T)=28:NEXT
30 I=I+1:PRINT"FORX=1TO 2:Y(Y)=0:NEXT"
730 CLS:PRINT"FIXME: PLEASE WAIT [           ]";
"""

    print(
        api.reformat_ascii_listing(listing_ascii)
    )
예제 #3
0
파일: cli.py 프로젝트: stahta01/DragonPy
    def setup_logging(self):
        handler = logging.StreamHandler()

        # Setup root logger
        setup_logging(
            level=self.verbosity,
            logger_name=None,  # Use root logger
            handler=handler,
            log_formatter=self.log_formatter)

        if self.log is None:
            return

        # Setup given loggers
        for logger_cfg in self.log:
            logger_name, level = logger_cfg.rsplit(",", 1)
            level = int(level)

            setup_logging(level=level,
                          logger_name=logger_name,
                          handler=handler,
                          log_formatter=self.log_formatter)
예제 #4
0
def cli():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--log_level', dest="log_level", type=int, choices=LOG_LEVELS, default=logging.INFO,
        help="Logging level: 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL/FATAL"
    )
    parser.add_argument('--filepath', dest="filepath", required=True)
    args = parser.parse_args()

    setup_logging(level=args.log_level)

    log.debug("Given path: %r", args.filepath)
    path = os.path.split(args.filepath)[0]

    if args.log_level <= 10:
        print_listing = True
    else:
        print_listing = False

    content = get_content(path, print_listing)
    log.debug("Send %i Bytes back so server process.", len(content))
    sys.stdout.buffer.write(content)
예제 #5
0
파일: editor.py 프로젝트: stahta01/DragonPy
def test():
    from dragonlib.utils.logging_utils import setup_logging

    setup_logging(
        #        level=1 # hardcore debug ;)
        #         level=10  # DEBUG
        #         level=20  # INFO
        #         level=30  # WARNING
        #         level=40 # ERROR
        level=50  # CRITICAL/FATAL
    )

    CFG_DICT = {
        "verbosity": None,
        "display_cycle": False,
        "trace": None,
        "max_ops": None,
        "bus_socket_host": None,
        "bus_socket_port": None,
        "ram": None,
        "rom": None,
        "use_bus": False,
    }
    from dragonpy.Dragon32.config import Dragon32Cfg

    cfg = Dragon32Cfg(CFG_DICT)

    filepath = os.path.join(
        os.path.abspath(os.path.dirname(__file__)),
        # "..", "BASIC examples", "hex_view01.bas"
        "..",
        "BASIC games",
        "INVADER.bas")

    with open(filepath, "r") as f:
        listing_ascii = f.read()

    run_basic_editor(cfg, default_content=listing_ascii)
예제 #6
0
파일: editor.py 프로젝트: ctodobom/DragonPy
def test():
    from dragonlib.utils.logging_utils import setup_logging

    setup_logging(
#        level=1 # hardcore debug ;)
#         level=10  # DEBUG
#         level=20  # INFO
#         level=30  # WARNING
#         level=40 # ERROR
        level=50 # CRITICAL/FATAL
    )

    CFG_DICT = {
        "verbosity": None,
        "display_cycle": False,
        "trace": None,
        "max_ops": None,
        "bus_socket_host": None,
        "bus_socket_port": None,
        "ram": None,
        "rom": None,
        "use_bus": False,
    }
    from dragonpy.Dragon32.config import Dragon32Cfg

    cfg = Dragon32Cfg(CFG_DICT)

    filepath = os.path.join(os.path.abspath(os.path.dirname(__file__)),
        # "..", "BASIC examples", "hex_view01.bas"
        "..", "BASIC games", "INVADER.bas"
    )

    with open(filepath, "r") as f:
        listing_ascii = f.read()

    run_basic_editor(cfg, default_content=listing_ascii)
예제 #7
0
def register_post_hook(op_code):
    def inner(func):
        DW_HOOKS.register_post_hook(op_code, func)
        return func
    return inner

def register_request_start_hook():
    def inner(func):
        DW_HOOKS.register_request_start_hook(func)
        return func
    return inner


if __name__ == '__main__':
    from dragonlib.utils.logging_utils import setup_logging

    setup_logging(
        level=1 # hardcore debug ;)
        #         level=10  # DEBUG
        #         level=20  # INFO
        #         level=30  # WARNING
        #         level=40 # ERROR
        #         level=50 # CRITICAL/FATAL
        #         level=99
    )

    filepath = os.path.expanduser("~/dwload-files/AUTOLOAD.DWL")

    backup_rename(filepath)
    backup_rename(filepath)
    backup_rename(filepath)
예제 #8
0
def test_run(path):
    setup_logging(level=logging.DEBUG)
    log.critical("\n\n *** DISABLE THIS TEST RUN !!! *** \n")
    content = get_content(path, print_listing=True)
예제 #9
0
    def run(self):
        self.args = self.parser.parse_args()
        setup_logging(level=self.args.log_level)

        log.debug("run func: %s", self.args.func.__name__)
        self.args.func()