main.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:sdic 作者: percolate 项目源码 文件源码
def main():
    args = docopt(__doc__,
                  version="sdic {}".format(VERSION))

    # Check that the given directory exists
    if not isdir(args['<directory>']):
        error("The folder {} does not exist".format(args['<directory>']))

    # Try to get the config of the servers we are gonna use
    servers = get_servers_from_config(args['<directory>'])

    # Check that we are not already running
    program_name = os.path.basename(sys.argv[0])
    lock = FileLock("/tmp/{}.lock".format(program_name))
    if lock.is_locked():
        error("{} is already running. Delete {} if it's a mistake.".format(
            program_name, lock.path))

    # Everything's ok, run the main program
    with lock:
        syslog.openlog('sdic')

        has_output = False
        if not args['<server>']:
            for server in servers:
                if launch_queries(args['<directory>'], server):
                    has_output = True
        else:
            for server in servers:
                if server['name'] == args['<server>']:
                    if launch_queries(args['<directory>'], server):
                        has_output = True
        if has_output:
            return 1

        syslog.closelog()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号