当前位置: 首页>>代码示例>>Python>>正文


Python Output.save_stats方法代码示例

本文整理汇总了Python中output.Output.save_stats方法的典型用法代码示例。如果您正苦于以下问题:Python Output.save_stats方法的具体用法?Python Output.save_stats怎么用?Python Output.save_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在output.Output的用法示例。


在下文中一共展示了Output.save_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import save_stats [as 别名]
def main():
    # initialize global settings
    settings.init()

    # parse command line options and arguments:
    modes=['a','g','generate','h','harvest','m','map','v','validate','c','convert','u','upload','h-m','m-u','h-u', 'h-d', 'd','delete']
    p = options_parser(modes)
    global options
    options,arguments = p.parse_args()
    
    # check option 'mode' and generate process list:
    (mode, pstat) = pstat_init(p,modes,options.mode,options.source,options.iphost)
    
    # set now time and process id
    now = time.strftime("%Y-%m-%d %H:%M:%S")
    jid = os.getpid()

    # Output instance
    OUT = Output(pstat,now,jid,options)

    ## logger
    global logger 
    logger = OUT.setup_custom_logger('root',options.verbose)

    ## logger = logging.getLogger('root')
    ##HEW-D logging.basicConfig(format=log_format, level=log_level) ### logging.DEBUG)
    # print out general info:
    logger.info('B2FIND Version:  \t%s' % settings.B2FINDVersion)
    logger.info('Run mode:   \t%s' % pstat['short'][mode])
    logger.info('Process ID:\t%s' % str(jid))
    logger.debug('Processing modes (to be done):\t')

    for key in pstat['status']:
        if  pstat['status'][key] == 'tbd':
            logger.debug(" %s\t%s" % (key, pstat['status'][key]))

    # check options:
    if ( pstat['status']['u'] == 'tbd'):
    
        # checking given options:
        if (options.iphost):
          if (not options.auth):
             from os.path import expanduser
             home = expanduser("~")
             if(not os.path.isfile(home+'/.netrc')):
                logger.critical('Can not access job host authentification file %s/.netrc ' % home )
                exit()
             f = open(home+'/.netrc','r')
             lines=f.read().splitlines()
             f.close()

             l = 0
             for host in lines:
                if(options.iphost == host.split()[0]):
                   options.auth = host.split()[1]
                   break
             logger.debug(
                'NOTE : For upload mode write access to %s by API key must be allowed' % options.iphost
             )
             if (not options.auth):
                logger.critical('API key is neither given by option --auth nor can retrieved from %s/.netrc' % home )
                exit()
        else:
            logger.critical(
                "\033[1m [CRITICAL] " +
                    "For upload mode valid URL of CKAN instance (option -i) and API key (--auth) must be given" + "\033[0;0m"
            )
            sys.exit(-1)
            
    # check options:
    if (not(options.handle_check) and pstat['status']['u'] == 'tbd'):
        logger.warning("You are going to upload datasets to %s without checking handles !" % (options.iphost))

    # write in HTML results file:
    OUT.HTML_print_begin()
    
    ## START PROCESSING:
    logger.info("Start : \t%s\n" % now)
    logger.info("Loop over processes and related requests :\n")
    logger.debug('|- <Process> started : %s' % "<Time>")
    logger.debug(' |- Joblist: %s' % "<Filename of request list>")
    logger.debug('\n   |# %-15s : %-30s \n\t|- %-10s |@ %-10s |' % ('<ReqNo.>','<Request description>','<Status>','<Time>'))

    OUT.save_stats('#Start','subset','StartTime',0)
    
    try:
        # start the process:
        process(options,pstat,OUT)
        sys.exit()
    except Exception as err :
        logging.critical("%s" % err)
        logging.error("%s" % traceback.format_exc())
        sys.exit()
    finally:
        # exit the program and open results HTML file:
        exit_program(OUT)
        now = time.strftime("%Y-%m-%d %H:%M:%S")
        logger.info("End of processing :\t\t%s" % now)
开发者ID:EUDAT-B2FIND,项目名称:md-ingestion,代码行数:100,代码来源:manager.py


注:本文中的output.Output.save_stats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。