def _send_msg(self, msg, subject, recipients, from_addr=None): '''Send an email from the packagedb.''' if not from_addr: from_addr = self.MAILFROM if config.get('mail.on', False): for person in recipients: email = turbomail.Message(from_addr, person, '[pkgdb] %s' % (subject,)) email.plain = msg turbomail.enqueue(email) else: LOG.debug(_('Would have sent: %(subject)s') % { 'subject': subject.encode('ascii', 'replace')}) LOG.debug('To: %s' % recipients) LOG.debug('From: %s %s' % (from_addr[0].encode('ascii', 'replace'), from_addr[1].encode('ascii', 'replace'))) LOG.debug('%s' % msg.encode('ascii', 'replace'))
def _send_msg(self, msg, subject, recipients, from_addr=None): '''Send an email from the packagedb.''' if not from_addr: from_addr = self.MAILFROM if config.get('mail.on', False): for person in recipients: email = turbomail.Message(from_addr, person, '[pkgdb] %s' % (subject, )) email.plain = msg turbomail.enqueue(email) else: LOG.debug( _('Would have sent: %(subject)s') % {'subject': subject.encode('ascii', 'replace')}) LOG.debug('To: %s' % recipients) LOG.debug('From: %s %s' % (from_addr[0].encode( 'ascii', 'replace'), from_addr[1].encode('ascii', 'replace'))) LOG.debug('%s' % msg.encode('ascii', 'replace'))
def default(self, package_name, *args, **kwargs): """Display a list of Fedora bugs against a given package.""" # Nasty, nasty hack. The packagedb, via bugz.fp.o is getting sent # requests to download files. These refused to go away even when # we fixed up the apache redirects. Send them to download.fp.o # manually. if args or kwargs: if args: url = ( "http://download.fedoraproject.org/" + quote(package_name) + "/" + "/".join([quote(a) for a in args]) ) elif kwargs: url = ( "http://mirrors.fedoraproject.org/" + quote(package_name) + "?" + "&".join([quote(q) + "=" + quote(v) for (q, v) in kwargs.items()]) ) LOG.warning(_("Invalid URL: redirecting: %(url)s") % {"url": url}) raise redirect(url) query = { "product": ("Fedora", "Fedora EPEL"), "component": package_name, "bug_status": ( "ASSIGNED", "NEW", "MODIFIED", "ON_DEV", "ON_QA", "VERIFIED", "FAILS_QA", "RELEASE_PENDING", "POST", ), } # :E1101: python-bugzilla monkey patches this in try: bugzilla = get_bz() except xmlrpclib.ProtocolError: error = dict( status=False, title=_("%(app)s -- Unable to contact bugzilla") % {"app": self.app_title}, message=_("Bugzilla is unavailable. Unable to determine" " bugs for %(pkg)s") % {"pkg": package_name}, ) if request_format() != "json": error["tg_template"] = "pkgdb.templates.errors" return error raw_bugs = bugzilla.query(query) # pylint: disable-msg=E1101 bugs = BugList(self.bzQueryUrl, self.bzUrl) for bug in raw_bugs: bugs.append(bug) if not bugs: # Check that the package exists try: # pylint: disable-msg=E1101 Package.query.filter_by(name=package_name).one() except InvalidRequestError: error = dict( status=False, title=_("%(app)s -- Not a Valid Package Name") % {"app": self.app_title}, message=_("No such package %(pkg)s") % {"pkg": package_name}, ) if request_format() != "json": error["tg_template"] = "pkgdb.templates.errors" return error return dict( title=_("%(app)s -- Open Bugs for %(pkg)s") % {"app": self.app_title, "pkg": package_name}, package=package_name, bugs=bugs, )
def default(self, package_name, *args, **kwargs): '''Display a list of Fedora bugs against a given package.''' # Nasty, nasty hack. The packagedb, via bugz.fp.o is getting sent # requests to download files. These refused to go away even when # we fixed up the apache redirects. Send them to download.fp.o # manually. if args or kwargs: if args: url = 'http://download.fedoraproject.org/' \ + quote(package_name) \ + '/' + '/'.join([quote(a) for a in args]) elif kwargs: url = 'http://mirrors.fedoraproject.org/' \ + quote(package_name) \ + '?' + '&'.join([quote(q) + '=' + quote(v) for (q, v) in kwargs.items()]) LOG.warning( _('Invalid URL: redirecting: %(url)s') % {'url': url}) raise redirect(url) query = { 'product': ('Fedora', 'Fedora EPEL'), 'component': package_name, 'bug_status': ('ASSIGNED', 'NEW', 'MODIFIED', 'ON_DEV', 'ON_QA', 'VERIFIED', 'FAILS_QA', 'RELEASE_PENDING', 'POST') } # :E1101: python-bugzilla monkey patches this in try: bugzilla = get_bz() except xmlrpclib.ProtocolError: error = dict( status=False, title=_('%(app)s -- Unable to contact bugzilla') % {'app': self.app_title}, message=_('Bugzilla is unavailable. Unable to determine' ' bugs for %(pkg)s') % {'pkg': package_name}) if request_format() != 'json': error['tg_template'] = 'pkgdb.templates.errors' return error raw_bugs = bugzilla.query(query) # pylint: disable-msg=E1101 bugs = BugList(self.bzQueryUrl, self.bzUrl) for bug in raw_bugs: bugs.append(bug) if not bugs: # Check that the package exists try: # pylint: disable-msg=E1101 Package.query.filter_by(name=package_name).one() except InvalidRequestError: error = dict(status=False, title=_('%(app)s -- Not a Valid Package Name') % {'app': self.app_title}, message=_('No such package %(pkg)s') % {'pkg': package_name}) if request_format() != 'json': error['tg_template'] = 'pkgdb.templates.errors' return error return dict(title=_('%(app)s -- Open Bugs for %(pkg)s') % { 'app': self.app_title, 'pkg': package_name }, package=package_name, bugs=bugs)