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()
评论列表
文章目录