Пример #1
0
def main(inargs=None):
    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=(__doc__ or '').strip())
    parser.add_argument(
        '-d', '--dryrun',
        action='store_true',
        dest='dryrun',
        default=False,
        help='Run in "dryrun" mode')
    parser.add_argument(
        '-f', '--config-file',
        metavar='<filename>',
        type=six.text_type,
        default=None,
        dest='alternative_config',
        help='Alternative configuration file for %(prog)s')
    Cerebrum.logutils.options.install_subparser(parser)
    args = parser.parse_args(inargs)
    Cerebrum.logutils.autoconf('cronjob', args)

    logger.info('Start of script %s', parser.prog)
    logger.debug("args: %r", args)

    db = Utils.Factory.get('Database')()

    notifier = PasswordNotifier.get_notifier(args.alternative_config)(
        db=db,
        dryrun=args.dryrun)
    notifier.process_accounts()

    logger.info('Done with script %s', parser.prog)
def main(inargs=None):
    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=(__doc__ or '').strip())
    parser.add_argument('-d',
                        '--dryrun',
                        action='store_true',
                        dest='dryrun',
                        default=False,
                        help='Run in "dryrun" mode')
    parser.add_argument('-f',
                        '--config-file',
                        metavar='<filename>',
                        type=six.text_type,
                        default=None,
                        dest='alternative_config',
                        help='Alternative configuration file for %(prog)s')
    Cerebrum.logutils.options.install_subparser(parser)
    args = parser.parse_args(inargs)
    Cerebrum.logutils.autoconf('cronjob', args)

    logger.info('Start of script %s', parser.prog)
    logger.debug("args: %r", args)

    db = Utils.Factory.get('Database')()

    notifier = PasswordNotifier.get_notifier(args.alternative_config)(
        db=db, dryrun=args.dryrun)
    notifier.process_accounts()

    logger.info('Done with script %s', parser.prog)
Пример #3
0
def main():
    try:
        progname, arg = sys.argv
    except ValueError:
        usage(sys.argv[0])

    logger = Factory.get_logger("console")
    try:
        fil = open(arg, "r")
        m = cPickle.loads(fil.read())
        fil.close()
    except:
        logger.exception("Could not read file")
        usage(progname)

    db = Factory.get('Database')()
    co = Factory.get('Constants')(db)
    account = Factory.get('Account')(db)
    # account.find_by_name("bootstrap_account")
    db.cl_init(change_program="pw_migrate")
    pw = PasswordNotifier.get_notifier()
    trait = co.EntityTrait(pw.config.trait)
    for account_id, info in m.iteritems():
        account.clear()
        account.find(account_id)
        logger.info("Handling %s", account.account_name)
        times = [time.localtime(info['first'])[:3]]
        logger.info(" first = %4d-%2d-%2d", *times[0])
        if 'reminder' in info:
            times.append(time.localtime(info['reminder'])[:3])
            logger.info(" rem   = %4d-%2d-%2d", *times[0])
        strval = ", ".join(
            [dt.DateTime(*x).strftime("%Y-%m-%d") for x in times])
        logger.info(" str   = %s", strval)
        t = {
            'code': trait,
            'date': db.Date(*times[0]),
            'numval': len(times),
            'strval': strval
        }
        account.populate_trait(**t)
        account.write_db()
    db.commit()
Пример #4
0
def main():
    try:
        progname, arg = sys.argv
    except ValueError:
        usage(sys.argv[0])

    logger = Factory.get_logger("console")
    try:
        fil = open(arg, "r")
        m = cPickle.loads(fil.read())
        fil.close()
    except:
        logger.exception("Could not read file")
        usage(progname)

    db = Factory.get('Database')()
    co = Factory.get('Constants')(db)
    account = Factory.get('Account')(db)
    # account.find_by_name("bootstrap_account")
    db.cl_init(change_program="pw_migrate")
    pw = PasswordNotifier.get_notifier()
    trait = co.EntityTrait(pw.config.trait)
    for account_id, info in m.iteritems():
        account.clear()
        account.find(account_id)
        logger.info("Handling %s", account.account_name)
        times = [time.localtime(info['first'])[:3]]
        logger.info(" first = %4d-%2d-%2d", *times[0])
        if 'reminder' in info:
            times.append(time.localtime(info['reminder'])[:3])
            logger.info(" rem   = %4d-%2d-%2d", *times[0])
        strval = ", ".join(
            [dt.DateTime(*x).strftime("%Y-%m-%d") for x in times])
        logger.info(" str   = %s", strval)
        t = {
            'code': trait,
            'date': db.Date(*times[0]),
            'numval': len(times),
            'strval': strval
            }
        account.populate_trait(**t)
        account.write_db()
    db.commit()
Пример #5
0
import sys

import cereconf

from Cerebrum import Utils
from Cerebrum.modules.password_notifier.notifier import PasswordNotifier

logger = Utils.Factory.get_logger("cronjob")
db = Utils.Factory.get('Database')()

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='The following options are available')
    parser.add_argument('-d',
                        '--dryrun',
                        action='store_true',
                        dest='dryrun',
                        default=False,
                        help='Run in "dryrun" mode')
    parser.add_argument('-f',
                        '--config-file',
                        metavar='<filename>',
                        type=str,
                        default=None,
                        dest='alternative_config',
                        help='Alternative configuration file for %(prog)s')
    args = parser.parse_args()
    notifier = PasswordNotifier.get_notifier(args.alternative_config)(
        db=db, logger=logger, dryrun=args.dryrun)
    notifier.process_accounts()
Пример #6
0
from Cerebrum import Utils
from Cerebrum.modules.password_notifier.notifier import PasswordNotifier

logger = Utils.Factory.get_logger("cronjob")
db = Utils.Factory.get('Database')()


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='The following options are available')
    parser.add_argument(
        '-d', '--dryrun',
        action='store_true',
        dest='dryrun',
        default=False,
        help='Run in "dryrun" mode')
    parser.add_argument(
        '-f', '--config-file',
        metavar='<filename>',
        type=str,
        default=None,
        dest='alternative_config',
        help='Alternative configuration file for %(prog)s')
    args = parser.parse_args()
    notifier = PasswordNotifier.get_notifier(args.alternative_config)(
        db=db,
        logger=logger,
        dryrun=args.dryrun)
    notifier.process_accounts()