Esempio n. 1
0
File: op2.py Progetto: joshcc3/PyOP2
def init(**kwargs):
    """Initialise OP2: select the backend and potentially other configuration
    options.

    :arg backend: Set the hardware-specific backend. Current choices
     are ``"sequential"``, ``"openmp"``, ``"opencl"`` and ``"cuda"``.
    :arg debug: The level of debugging output.
    :arg comm: The MPI communicator to use for parallel communication,
               defaults to `MPI_COMM_WORLD`

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    backend = backends.get_backend()
    if backend == 'pyop2.finalised':
        raise RuntimeError("Calling init() after exit() is illegal.")
    if 'backend' in kwargs and backend not in ('pyop2.void', 'pyop2.' + kwargs['backend']):
        raise RuntimeError("Changing the backend is not possible once set.")
    cfg.configure(**kwargs)
    set_log_level(cfg['log_level'])
    if backend == 'pyop2.void':
        backends.set_backend(cfg.backend)
        backends._BackendSelector._backend._setup()
        if 'comm' in kwargs:
            backends._BackendSelector._backend.MPI.comm = kwargs['comm']
        global MPI
        MPI = backends._BackendSelector._backend.MPI  # noqa: backend override
Esempio n. 2
0
 def setUpClass(self):
     logger.set_log_level(logger.DEBUG)
     logger.logfile(logname)
     logger.log('Set up test')
     global cli, stc
     cli = sw_consele()
     cli.login(sw_ip)
     config_sw(cli, num)
     stc = send_packets()
 def setUpClass(self):
     logger.set_log_level(logger.DEBUG)
     logger.logfile(logname)
     logger.log('Set up test')
     global ont, olt, stc
     ont = Ont()
     olt = Olt()
     olt.login()
     ont.login()
     stc = send_packets()
Esempio n. 4
0
 def setUpClass(self):
     logger.set_log_level(logger.DEBUG)
     logger.logfile(logname)
     logger.log('Set up test')
     global cli, old_auto_negotiation, old_speed
     cli = sw_consele()
     cli.login(sw_ip)
     old_auto_negotiation = get_output(cli, cli.p_sw_privilege,
                                       'dis interface GigabitEthernet 0/0/2', r'Negotiation: ([A-Z]{6,7})')
     old_speed = int(get_output(cli, cli.p_sw_privilege,
                                'dis interface GigabitEthernet 0/0/2', r'Speed : ([01]{2,4})'))
     logger.log('Old port rate is {},port auto negotiation is {}'.format(old_speed, old_auto_negotiation))
Esempio n. 5
0
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg backend:   Set the hardware-specific backend. Current choices are
                    ``"sequential"``, ``"openmp"``, ``"opencl"``, ``"cuda"``.
    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    backend = backends.get_backend()
    if backend == 'pyop2.finalised':
        raise RuntimeError("Calling init() after exit() is illegal.")

    if backend != 'pyop2.void' and \
            "backend" in kwargs and \
            backend != "pyop2.%s" % kwargs["backend"]:
        raise RuntimeError("Calling init() for a different backend is illegal.")

    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])
    if backend == 'pyop2.void':
        try:
            backends.set_backend(configuration["backend"])
        except:
            configuration.reset()
            raise

        backends._BackendSelector._backend._setup()
        if 'comm' in kwargs:
            backends._BackendSelector._backend.MPI.comm = kwargs['comm']
        global MPI
        MPI = backends._BackendSelector._backend.MPI  # noqa: backend override

    init_coffee(configuration['simd_isa'], configuration['compiler'],
                configuration['blas'])
Esempio n. 6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('lhspath')
    parser.add_argument('rhspath')
    # TODO(sasiala): rethink argument naming
    parser.add_argument('-v', '--verbose', action='count', default=0, help='Increase Verbosity')
    parser.add_argument('-st', '--save-temp', action='store_true', help='Save all temporary files')
    args = parser.parse_args()

    try:
        loglevel = logger.LogLevel(args.verbose)
    except:
        loglevel = logger.LogLevel.ERROR
    logger.set_log_level(loglevel)

    global save_temp
    save_temp=args.save_temp

    process_xlsx(args.lhspath, args.rhspath)
Esempio n. 7
0
                    default='data.json')
parser.add_argument("--logfile", type=str, help="Log to defined file.")

args = parser.parse_args()

BUCKET = args.bucket

try:
    args.logfile = os.environ[_ENV_LOGGING_FILE]
except KeyError:
    pass

if args.logfile:
    logger.add_file_handler(args.logfile, args.verbosity)

logger.set_log_level(args.verbosity)

try:
    args.token = os.environ[_ENV_TELEGRAM_BOT_TOKEN]
except KeyError as key_error:
    if not args.token:
        LOG.critical(
            'No telegram bot token provided. Please do so using --token argument or %s environment variable.',
            _ENV_TELEGRAM_BOT_TOKEN)
        exit(1)

try:
    args.admin = os.environ[_ENV_TELEGRAM_USER_ALIAS]
except KeyError as key_error:
    if not args.admin:
        LOG.warn(
Esempio n. 8
0
        help='Specifies how many times IFS algorithm will be run.',
        default=20)
    generate_fractal_parser.add_argument('--log_level',
                                         action='store',
                                         choices=['DEBUG', 'INFO', 'ERROR'],
                                         help='Choose log level',
                                         default='INFO')
    return generate_fractal_parser.parse_args()


if __name__ == '__main__':
    try:
        start_time = datetime.now()

        arguments = get_arguments()
        logger.set_log_level(arguments.log_level)
        logger = logger.Logger(__name__)
        logger.debug(start_time)
        logger.info(
            "Fractalator execution started with input arguments [%s]." %
            arguments)

        main(arguments)

        finish_time = datetime.now()
        logger.debug('Execution time: {time}.'.format(time=(finish_time -
                                                            start_time)))
        logger.info('Fractalator ended successfully.')
        sys.exit(0)

    except KeyboardInterrupt as e:  # Ctrl-C