def configure(**kargs): from amoco.config import conf_proxy conf = conf_proxy('x86') or dict() conf.update(kargs) # asm format: if conf.get('format',None) in ('AT&T','at&t','ATT','att'): instruction_x86.set_formatter(IA32_ATT) else: instruction_x86.set_formatter(IA32_Intel)
# -*- coding: utf-8 -*- try: from cStringIO import StringIO except ImportError: from io import BytesIO as StringIO from amoco.config import conf_proxy conf = conf_proxy('ui') from amoco.logger import Log logger = Log(__name__) import re try: from pygments.token import Token from pygments.style import Style from pygments.lexer import RegexLexer from pygments.formatters import * except ImportError: logger.info("pygments package not found, no renderer defined") has_pygments = False # metaclass definition, with a syntax compatible with python2 and python3 class TokenType(type): def __getattr__(cls, key): return key Token_base = TokenType('Token_base', (), {}) class Token(Token_base):
# -*- coding: utf-8 -*- try: from builtins import bytes except ImportError: pass from amoco.config import conf_proxy conf = conf_proxy('block') from amoco.logger import Log logger = Log(__name__) from amoco.cas.expressions import regtype from amoco.ui.graphics import Engine from amoco.ui.render import Token, vltable class View(Engine): _is_block = False _is_map = False _is_func = False _is_xfunc = False def __init__(self, of=None): self.of = of @property def obj(self): try: return self._obj except AttributeError:
# Copyright (C) 2016 Axel Tillequin ([email protected]) # published under GPLv2 license """ db.py ===== This module implements all amoco's database facilities using the `sqlalchemy`_ package, allowing to store many analysis results and pickled objects. .. _sqlalchemy: http://www.sqlalchemy.org/ """ from amoco.config import conf_proxy conf = conf_proxy(__name__) from amoco.logger import Log, logging logger = Log(__name__) try: import sqlalchemy as sql from sqlalchemy import orm from sqlalchemy.ext.declarative import declarative_base has_sql = True Session = orm.scoped_session(orm.sessionmaker()) Base = declarative_base() if conf['log']: for l in ('sqlalchemy.engine', 'sqlalchemy.orm'): alog = logging.getLogger(l) for h in logger.handlers:
Note that amoco loggers are configured to log both to *stderr* with selected level and to a temporary file with ``'DEBUG'`` level. """ import logging VERBOSE = 15 logging.addLevelName(VERBOSE,u'VERBOSE') #logging.captureWarnings(True) default_format = logging.Formatter(u"[%(levelname)s] %(name)s: %(message)s") from amoco.config import conf_proxy conf = conf_proxy('log') default_level = conf['level'] if conf['file']: logfilename = conf['file'] elif conf['tempfile']: import tempfile logfilename = tempfile.mkstemp('.log',prefix="amoco-")[1] else: logfilename = None if logfilename: logfile = logging.FileHandler(logfilename,mode='w') logfile.setFormatter(default_format) logfile.setLevel(VERBOSE)