Exemplo n.º 1
0
    context = daemon.DaemonContext(working_directory=args['data_dir'],
                                   pidfile=lock,
                                   stderr=sys.stderr)

    context.signal_map = {
        signal.SIGTERM: 'terminate',
        signal.SIGHUP: 'terminate'
    }

    if args['no_text']:
        args['password'] = ""

    if args['password'] is None:
        args['password'] = get_password(verify=check_with_encrypter)

    encrypter = make_encrypter(args['password'])

    if not check_password.check(args['data_dir'], encrypter):
        print 'Password failed'
        sys.exit(1)

    with context:
        astore = ActivityStore(os.path.join(args['data_dir'], DBNAME),
                               encrypter,
                               store_text=(not args['no_text']))

        try:
            astore.run()
        except SystemExit:
            astore.close()