#!/usr/bin/env python # # brozzler-new-job - takes a yaml brozzler job configuration file, creates # job, sites, and pages objects in rethinkdb, which brozzler-workers will look # at and start crawling # # Copyright (C) 2014-2016 Internet Archive # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import argparse import os import sys import logging import brozzler import yaml import json import rethinkstuff import warnings import requests arg_parser = argparse.ArgumentParser(prog=os.path.basename(__file__), description="brozzler-new-job - queue new job with brozzler", formatter_class=argparse.ArgumentDefaultsHelpFormatter) arg_parser.add_argument('job_conf_file', metavar='JOB_CONF_FILE', help='brozzler job configuration file in yaml') arg_parser.add_argument('--rethinkdb-servers', dest='rethinkdb_servers', default="localhost", help='rethinkdb servers, e.g. db0.foo.org,db0.foo.org:38015,db1.foo.org') arg_parser.add_argument('--rethinkdb-db', dest='rethinkdb_db', default="brozzler", help='rethinkdb database name') arg_parser.add_argument("-v", "--verbose", dest="log_level", action="store_const", default=logging.INFO, const=logging.DEBUG) arg_parser.add_argument("--version", action="version", version="brozzler {} - {}".format(brozzler.__version__, os.path.basename(__file__))) args = arg_parser.parse_args(args=sys.argv[1:]) logging.basicConfig(stream=sys.stdout, level=args.log_level, format="%(asctime)s %(process)d %(levelname)s %(threadName)s %(name)s.%(funcName)s(%(filename)s:%(lineno)d) %(message)s") logging.getLogger("requests.packages.urllib3").setLevel(logging.WARN) warnings.simplefilter("ignore", category=requests.packages.urllib3.exceptions.InsecureRequestWarning) warnings.simplefilter("ignore", category=requests.packages.urllib3.exceptions.InsecurePlatformWarning) r = rethinkstuff.Rethinker(args.rethinkdb_servers.split(","), args.rethinkdb_db) frontier = brozzler.RethinkDbFrontier(r) brozzler.job.new_job_file(frontier, args.job_conf_file)