Exemple #1
0
def main(argv=sys.argv):
    default_interval = 300
    parser = create_karl_argparser(description='Process incoming mail.')
    parser.add_argument('-d',
                        '--daemon',
                        action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i',
                        '--interval',
                        type=int,
                        default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)

    args = parser.parse_args(sys.argv[1:])

    env = args.bootstrap(args.config_uri)

    if not is_normal_mode(env['registry']):
        log.info("Cannot run mailin: Running in maintenance mode.")
        sys.exit(2)

    try:
        if args.daemon:
            daemonize_function(mailin, args.interval)(args, env, parser)
        else:
            mailin(args, env, parser)
    finally:
        env['closer']()
Exemple #2
0
def main(argv=sys.argv):
    default_interval = 120
    parser = create_karl_argparser(
        description='Sync staff profiles and login to OSI GSA.'
        )
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)
    parser.add_argument('-u', '--user', help='Login username for GSA.')
    parser.add_argument('-p', '--password', help='Password for GSA.')
    parser.add_argument('-x', '--check-last-sync',
                        default=None,
                        help='Check that last sync w/ GSA happened w/in a'
                             'given interval (in minutes).  If not, exit with '
                             'a non-zero status code;  if os, exit normally.')
    parser.add_argument('url', help='URL of GSA datasource.')
    parser.add_argument('-t', '--timeout',
                        default=90,
                        help='Timeout for GSA request (default 15 sec).')

    args = parser.parse_args(sys.argv[1:])

    env = args.bootstrap(args.config_uri)
    
    if not is_normal_mode(env['registry']):
        log.info("Cannot run mailin: Running in maintenance mode.")
        sys.exit(2)

    f = only_one(_sync, env['registry'], 'gsa_sync')
    if args.daemon:
        daemonize_function(f, args.interval)(args, env)
    else:
        f(args, env)
Exemple #3
0
def main(argv=sys.argv):
    default_interval = 6 * 3600  # 6 hours
    parser = create_karl_argparser(description='Send digest emails.')
    parser.add_argument('-d',
                        '--daemon',
                        action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i',
                        '--interval',
                        type=int,
                        default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)
    parser.add_argument('-f',
                        '--frequency',
                        dest='frequency',
                        default='daily',
                        help='Digest frequency:  daily/weekly/biweekly.')
    args = parser.parse_args(argv[1:])
    env = args.bootstrap(args.config_uri)
    root, closer, registry = env['root'], env['closer'], env['registry']
    if args.daemon:
        f = daemonize_function(digest, args.interval)
        only_one(f, registry, 'digest')(root, closer, registry, args.frequency)
    else:
        only_one(digest, registry, 'digest')(root, closer, registry,
                                             args.frequency)
    closer()
    import gc
    gc.collect()  # Work around relstorage cache bug.
Exemple #4
0
def main(argv=sys.argv):
    default_interval = 300

    parser = create_karl_argparser(description='Send outgoing mail.')
    parser.add_argument('--server', '-s', default="localhost", metavar='HOST',
                        help='SMTP server host name.  Default is localhost.', )
    parser.add_argument('--port', '-P', type=int, default=25, metavar='PORT',
                        help='Port of SMTP server.  Default is 25.', )
    parser.add_argument('--username', '-u',
                        help='Username, if authentication is required')
    parser.add_argument('--password', '-p',
                        help='Password, if authentication is required')
    parser.add_argument('--force-tls', '-f', action='store_true',
                        help='Require that TLS be used.')
    parser.add_argument('--no-tls', '-n', action='store_true',
                        help='Require that TLS not be used.')
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                             "daemon mode.  Default is %d." % default_interval)

    args = parser.parse_args(sys.argv[1:])

    env = args.bootstrap(args.config_uri)

    if args.daemon:
        f = daemonize_function(mailout, args.interval)
        only_one(f, env['registry'], 'mailout')(args, env)
    else:
        only_one(mailout, env['registry'], 'mailout')(args, env)
Exemple #5
0
def main(argv=sys.argv):
    default_interval = 300

    parser = create_karl_argparser(description='Send outgoing mail.')
    parser.add_argument('--server', '-s', default="localhost", metavar='HOST',
                        help='SMTP server host name.  Default is localhost.', )
    parser.add_argument('--port', '-P', type=int, default=25, metavar='PORT',
                        help='Port of SMTP server.  Default is 25.', )
    parser.add_argument('--username', '-u',
                        help='Username, if authentication is required')
    parser.add_argument('--password', '-p',
                        help='Password, if authentication is required')
    parser.add_argument('--force-tls', '-f', action='store_true',
                        help='Require that TLS be used.')
    parser.add_argument('--no-tls', '-n', action='store_true',
                        help='Require that TLS not be used.')
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)

    args = parser.parse_args(sys.argv[1:])

    env = args.bootstrap(args.config_uri)

    if args.daemon:
        f = daemonize_function(mailout, args.interval)
        only_one(f, env['registry'], 'mailout')(args, env)
    else:
        only_one(mailout, env['registry'], 'mailout')(args, env)
Exemple #6
0
def update_feeds(argv=sys.argv):
    default_interval = 1800  # 30 minutes
    parser = create_karl_argparser(
        description='Get new entries from feeds.'
        )
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)
    parser.add_argument('-f', '--force', action='store_true',
                        help='Force reload of feed entries.')
    args = parser.parse_args(argv[1:])
    env = args.bootstrap(args.config_uri)
    
    if args.daemon:
        daemonize_function(_update_feeds, args.interval)(args, env)
    else:
        _update_feeds(args, env)
Exemple #7
0
def main(argv=sys.argv):
    default_interval = 300
    parser = create_karl_argparser(description='Process incoming mail.')
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)

    args = parser.parse_args(sys.argv[1:])

    env = args.bootstrap(args.config_uri)

    if not is_normal_mode(env['registry']):
        log.info("Cannot run mailin: Running in maintenance mode.")
        sys.exit(2)

    try:
        if args.daemon:
            daemonize_function(mailin, args.interval)(args, env, parser)
        else:
            mailin(args, env, parser)
    finally:
        env['closer']()
Exemple #8
0
def main(argv=sys.argv):
    default_interval = 6 * 3600  # 6 hours
    parser =  create_karl_argparser(
        description='Send digest emails.'
        )
    parser.add_argument('-d', '--daemon', action='store_true',
                        help="Run in daemon mode.")
    parser.add_argument('-i', '--interval', type=int, default=default_interval,
                        help="Interval in seconds between executions in "
                        "daemon mode.  Default is %d." % default_interval)
    parser.add_argument('-f', '--frequency', dest='frequency', default='daily',
                      help='Digest frequency:  daily/weekly/biweekly.')
    args = parser.parse_args(argv[1:])
    env = args.bootstrap(args.config_uri)
    root, closer, registry = env['root'], env['closer'], env['registry']
    if args.daemon:
        f = daemonize_function(digest, args.interval)
        only_one(f, registry, 'digest')(root, closer, registry, args.frequency)
    else:
        only_one(digest, registry, 'digest')(
            root, closer, registry, args.frequency)
    closer()