示例#1
0
 def run(self, args=None):
     self.args = self.parser.parse_args(args=args)
     if self.args.insecure:
         requests.packages.urllib3.disable_warnings(
             requests.packages.urllib3.exceptions.InsecureRequestWarning)
         ssl_verify = False
     elif self.args.ca_cert:
         ssl_verify = self.args.ca_cert
     else:
         ssl_verify = None
     self.client = pdc_client.PDCClient(self.args.server,
                                        page_size=self.args.page_size,
                                        ssl_verify=ssl_verify)
     try:
         self.args.func(self.args)
     except beanbag.BeanBagException as exc:
         self.print_error_header(exc)
         json = None
         try:
             json = exc.response.json()
             pretty_print(json, file=sys.stderr)
         except ValueError:
             # Response was not JSON
             print('Failed to parse error response.', file=sys.stderr)
         except TypeError as e:
             # Failed to pretty print.
             print(
                 'Failed to correctly display error message. Please file a bug.',
                 file=sys.stderr)
             self.logger.info(json, exc_info=e)
         sys.exit(1)
示例#2
0
    def __init__(self,
                 cache_path,
                 tagger_url=None,
                 bodhi_url=None,
                 mdapi_url=None,
                 icons_url=None,
                 pdc_url=None,
                 pagure_url=None):

        self.cache_path = cache_path
        self.dbpath = join(cache_path, 'search')
        self.icons_path = join(cache_path, 'icons')
        self.default_icon = 'package_128x128.png'
        self.tagger_url = tagger_url or "https://apps.fedoraproject.org/tagger"
        self.bodhi_url = bodhi_url or "https://bodhi.fedoraproject.org"
        self.mdapi_url = mdapi_url or "https://apps.fedoraproject.org/mdapi"
        self.icons_url = icons_url or "https://alt.fedoraproject.org/pub/alt/screenshots"
        self.pagure_url = pagure_url or "https://src.fedoraproject.org/api/0"
        self.icon_cache = {}
        pdc_url = pdc_url or "https://pdc.fedoraproject.org/rest_api/v1"
        self.pdc = pdc_client.PDCClient(pdc_url, develop=True, page_size=100)

        self.active_fedora_releases = self._get_active_fedora_releases()

        self.create_index()
示例#3
0
    def consume(self, msg):
        msg = msg['body']  # Remove envelope
        idx = msg.get('msg_id', None)
        topic = msg.get('topic', None)
        self.log.debug("Received %r, %r" % (idx, topic))

        pdc = pdc_client.PDCClient(**self.pdc_config)
        pdcupdater.utils.handle_message(pdc, self.handlers, msg)
示例#4
0
def retry():
    config = fedmsg.config.load_config()
    logging.config.dictConfig(config['logging'])
    msg_ids = sys.argv[1:]
    if msg_ids:
        messages = [pdcupdater.utils.get_fedmsg(idx) for idx in msg_ids]
    else:
        log.info("No msg_ids supplied.  Reading message payload from stdin.")
        messages = [fedmsg.encoding.loads(sys.stdin.read())]

    pdc = pdc_client.PDCClient(**config['pdcupdater.pdc'])
    handlers = pdcupdater.handlers.load_handlers(config)
    for msg in messages:
        pdcupdater.utils.handle_message(pdc, handlers, msg, verbose=True)
示例#5
0
def audit():
    config = fedmsg.config.load_config()
    logging.config.dictConfig(config['logging'])
    pdc = pdc_client.PDCClient(**config['pdcupdater.pdc'])
    handlers = pdcupdater.handlers.load_handlers(config)

    results = {}
    for handler in handlers:
        name = type(handler).__name__
        log.info('Performing audit for %s' % name)
        results[name] = handler.audit(pdc)

    verbose = False
    retval = _print_audit_report(results, verbose)
    sys.exit(retval)
示例#6
0
def initialize():
    config = fedmsg.config.load_config()
    logging.config.dictConfig(config['logging'])
    pdc = pdc_client.PDCClient(**config['pdcupdater.pdc'])
    pdc.set_comment("Initialized by pdc-updater.")
    _initialize_basics(pdc)
    handlers = pdcupdater.handlers.load_handlers(config)
    for handler in handlers:
        log.info("Calling .initialize() on %r" % handler)
        pdc.set_comment("Initialized via %r" % handler)
        try:
            handler.initialize(pdc)
        except beanbag.bbexcept.BeanBagException as e:
            log.exception(e.response.text)
            #raise  # TODO - eventually raise here.  While in dev, leave it out
    log.info("Done initializing.")
示例#7
0
    def consume(self, envelope):
        # Remove the envelope
        headers = envelope.get('headers', {})  # https://github.com/mokshaproject/moksha/pull/35
        topic, msg = envelope['topic'], envelope['body']

        # Stuff topic and headers back into the message body, for convenience.
        msg['topic'] = topic
        msg['headers'] = headers

        # If the message is internal, the message id is in the headers
        if 'message-id' in msg['headers']:
            msg['msg_id'] = msg['headers']['message-id']

        self.log.debug("Received %r, %r" % (msg['msg_id'], topic))

        pdc = pdc_client.PDCClient(**self.pdc_config)
        pdcupdater.utils.handle_message(pdc, self.handlers, msg)
示例#8
0
 def run(self, args=None):
     self.args = self.parser.parse_args(args=args)
     self.client = pdc_client.PDCClient(self.args.server)
     try:
         self.args.func(self.args)
     except beanbag.BeanBagException as exc:
         self.print_error_header(exc)
         json = None
         try:
             json = exc.response.json()
             pretty_print(json, file=sys.stderr)
         except ValueError:
             # Response was not JSON
             print('Failed to parse error response.', file=sys.stderr)
         except TypeError as e:
             # Failed to pretty print.
             print(
                 'Failed to correctly display error message. Please file a bug.',
                 file=sys.stderr)
             self.logger.info(json, exc_info=e)
         sys.exit(1)
示例#9
0
    def __init__(self, cache_path,
                 bodhi_url=None,
                 mdapi_url=None,
                 icons_url=None,
                 pdc_url=None,
                 pagure_url=None):

        self.cache_path = cache_path
        self.dbpath = join(cache_path, 'search')
        self.icons_path = join(cache_path, 'icons')
        self.default_icon = 'package_128x128.png'
        self.bodhi_url = bodhi_url or "https://bodhi.fedoraproject.org"
        self.mdapi_url = mdapi_url or "https://mdapi.fedoraproject.org"
        self.icons_url = icons_url or "https://dl.fedoraproject.org/pub/alt/screenshots/"
        self.pagure_url = pagure_url or "https://src.fedoraproject.org/api/0"
        self.icon_cache = {}
        pdc_url = pdc_url or "https://pdc.fedoraproject.org/rest_api/v1"
        self.pdc = pdc_client.PDCClient(pdc_url, develop=True, page_size=100)
        retries = Retry(connect=10, total=15, backoff_factor=1)
        self.pdc.session.mount('https://', HTTPAdapter(max_retries=retries))

        self.active_fedora_releases = self._get_active_fedora_releases()

        self.create_index()