Esempio n. 1
0
def main():
    start_time = datetime.datetime.now()

    # first initialize the logger
    logging.addLevelName(utils_log.TRACE_LEVEL, 'TRACE')
    logging.config.fileConfig(
        os.path.join(os.path.dirname(__file__), LOG_CFG_FILE))
    log = logging.getLogger("motu-client-python")

    logging.getLogger().setLevel(logging.INFO)

    try:
        # we prepare options we want
        (_options, args) = load_options()

        if _options.log_level != None:
            logging.getLogger().setLevel(int(_options.log_level))

        motu_api.execute_request(_options)
    except Exception as e:
        log.error("Execution failed: %s", e)
        if hasattr(e, 'reason'):
            log.info(' . reason: %s', e.reason)
        if hasattr(e, 'code'):
            log.info(' . code  %s: ', e.code)
        if hasattr(e, 'read'):
            log.log(utils_log.TRACE_LEVEL, ' . detail:\n%s', e.read())

        log.debug('-' * 60)
        log.debug("Stack trace exception is detailed herafter:")
        exc_type, exc_value, exc_tb = sys.exc_info()
        x = traceback.format_exception(exc_type, exc_value, exc_tb)
        for stack in x:
            log.debug(' . %s', stack.replace('\n', ''))
        log.debug('-' * 60)
        log.log(utils_log.TRACE_LEVEL, 'System info is provided hereafter:')
        system, node, release, version, machine, processor = platform.uname()
        log.log(utils_log.TRACE_LEVEL, ' . system   : %s', system)
        log.log(utils_log.TRACE_LEVEL, ' . node     : %s', node)
        log.log(utils_log.TRACE_LEVEL, ' . release  : %s', release)
        log.log(utils_log.TRACE_LEVEL, ' . version  : %s', version)
        log.log(utils_log.TRACE_LEVEL, ' . machine  : %s', machine)
        log.log(utils_log.TRACE_LEVEL, ' . processor: %s', processor)
        log.log(utils_log.TRACE_LEVEL, ' . python   : %s', sys.version)
        log.log(utils_log.TRACE_LEVEL, ' . client   : %s',
                get_client_version())
        log.log(utils_log.TRACE_LEVEL, '-' * 60)

        sys.exit(ERROR_CODE_EXIT)

    finally:
        log.debug("Elapsed time : %s",
                  str(datetime.datetime.now() - start_time))
Esempio n. 2
0
def runMotuTest(name, round, data):
   try: 
       os.makedirs(name)
   except OSError:
       if not os.path.isdir(name):
          raise
   target = os.path.join(name,str(round)+".json")
   print "running",name,round
   if os.path.exists(target):
      return
   conf = MotuConf()
   conf.update(data)
   execute_request(conf)
   results = summary.getResults()
   ret = {
      "size": results.fileSize,
      "download": results.downloading.total_seconds(),
      "processing": results.processing.total_seconds(),
      "total": (results.processing + results.downloading).total_seconds(),
   }
   json.dump(ret ,open(target,"w"))
Esempio n. 3
0
    # first initialize the logger
    logging.addLevelName(utils_log.TRACE_LEVEL, 'TRACE')
    logging.config.fileConfig(
        os.path.join(os.path.dirname(__file__), LOG_CFG_FILE))
    log = logging.getLogger("motu-client-python")

    logging.getLogger().setLevel(logging.INFO)

    try:
        # we prepare options we want
        (_options, args) = load_options()

        if _options.log_level != None:
            logging.getLogger().setLevel(int(_options.log_level))

        motu_api.execute_request(_options)
    except Exception, e:
        log.error("Execution failed: %s", e)
        if hasattr(e, 'reason'):
            log.info(' . reason: %s', e.reason)
        if hasattr(e, 'code'):
            log.info(' . code  %s: ', e.code)
        if hasattr(e, 'read'):
            log.log(utils_log.TRACE_LEVEL, ' . detail:\n%s', e.read())

        log.debug('-' * 60)
        log.debug("Stack trace exception is detailed herafter:")
        exc_type, exc_value, exc_tb = sys.exc_info()
        x = traceback.format_exception(exc_type, exc_value, exc_tb)
        for stack in x:
            log.debug(' . %s', stack.replace('\n', ''))
    
    # first initialize the logger
    logging.addLevelName(utils_log.TRACE_LEVEL, 'TRACE')
    logging.config.fileConfig(  os.path.join(os.path.dirname(__file__),LOG_CFG_FILE) )
    log = logging.getLogger("motu-client-python")
        
    logging.getLogger().setLevel(logging.INFO)
    
    try:
        # we prepare options we want
        (_options, args) = load_options()    

        if _options.log_level != None:
            logging.getLogger().setLevel(int(_options.log_level))
                   
        motu_api.execute_request(_options)       
    except Exception, e:
        log.error( "Execution failed: %s", e )
        if hasattr(e, 'reason'):
          log.info( ' . reason: %s', e.reason )
        if hasattr(e, 'code'):
          log.info( ' . code  %s: ', e.code )
        if hasattr(e, 'read'):
          log.log( utils_log.TRACE_LEVEL, ' . detail:\n%s', e.read() )
        
        log.debug( '-'*60 )
        log.debug( "Stack trace exception is detailed herafter:" )
        exc_type, exc_value, exc_tb = sys.exc_info()
        x = traceback.format_exception(exc_type, exc_value, exc_tb)
        for stack in x:
            log.debug( ' . %s', stack.replace('\n', '') )