def main(argv=sys.argv): parser = create_karl_argparser( description='Sync users to external data source.' ) parser.add_argument('--username', '-U', default=None, help='Username for BASIC Auth') parser.add_argument('--password', '-P', default=None, help='Password for BASIC Auth') parser.add_argument('--password-file', '-F', default=None, help='Read password for BASIC Auth from file') parser.add_argument('url', help="URL of data source.") args = parser.parse_args(argv[1:]) env = args.bootstrap(args.config_uri) root, closer, registry = env['root'], env['closer'], env['registry'] if args.password and args.password_file: args.parser.error('cannot set both --password and --password-file') if args.password_file: with open(args.password_file) as f: password = f.read().strip('\n') else: password = args.password log.info("Syncing users at %s" % args.url) sync = UserSync(root) only_one(sync, registry, 'usersync')(args.url, args.username, password) transaction.commit() closer()
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)
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.
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)
def mailin(args, env, parser): log.info('Processing mailin') root, registry = env['root'], env['registry'] settings = registry.settings zodb_path = settings.get('postoffice.zodb_path', '/postoffice') queue = settings.get('postoffice.queue') if 'zodbconn.uri.postoffice' not in settings: parser.error("zodbconn.uri.postoffice must be set in config file") if queue is None: parser.error("postoffice.queue must be set in config file") request = env['request'] only_one(go, registry, 'mailin')(root, request, zodb_path, queue)
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()