def get_url(url): try: return url_cache[url] except KeyError: pass try: data = urllib.urlopen(url) except IOError, e: debug('Unable to open URL: %s, %s' % (url, e.strerror)) return []
def run (self): # Get Tanglu version if self.package.source in pkgs_tanglu: self.package.tanglu_version = pkgs_tanglu[self.package.source].version else: debug ("Package %s not found in Tanglu!" % (self.package.source)) # Get Debian version try: debian_source = debian_naming_translation.get (self.package.source, self.package.source) if debian_source in pkgs_debian_unstable: self.package.debian_version = pkgs_debian_unstable[debian_source].version else: self.package.debian_version = "0~" if debian_source in pkgs_debian_experimental: self.package.debian_version = self.max_version (self.package.debian_version, pkgs_debian_experimental[debian_source].version); self.package.debian_version = self.max_version (self.package.debian_version, self.get_svn_version ('experimental', debian_source)); self.package.debian_version = self.max_version (self.package.debian_version, self.get_svn_version ('unstable', debian_source)); except: debug (traceback.format_exc ()) # Get upstream versions try: (self.package.upstream_version, self.package.upstream_unstable_version) = self.get_upstream_version () except: debug (traceback.format_exc ()) self.queue.put (self)
def write_page (name, section_label, tags = [], invert = False): html, foot_html = generate_page (tags, invert) render_template("package-watch/pkgwatch.html", name, page_name="pkg-watch", content=html, extra_footer=foot_html, section_label=section_label) debug('Wrote %s' % name)
def generate_page (tags = [], invert = False): html = '''<table class="table"> <tr> <th><b>Package</b></th> <th><b>Tanglu</b></th> <th><b>Debian</b></th> <th><b>Upstream version</b></th> <th><b>Status</b></th> </tr> ''' debug('Building table...') style_total = 0 style_count = {} for source in sources: package = packages[source] have_tag = False for tag in tags: if tag in package.tags: have_tag = True if invert: have_tag = not have_tag if not have_tag: continue try: style_count[package.style] += 1 except KeyError: style_count[package.style] = 1 style_total += 1 html += '<tr class="%s">\n' % package.style status = "" # TODO: Adjust for Tanglu bugs! #if len(package.lp_bugs) > 0: #bug_text = [] #for (number, importance, assignee, fix_committed) in package.lp_bugs: #img = 'https://launchpad.net/@@/bug-%s' % importance.lower() #if fix_committed: #color_link = 'style="color:grey"' #else: #color_link = '' #text = '<a href="https://launchpad.net/bugs/%s" %s>' % (number, color_link) #text += '<img alt="" src="%s" />%s</a>' % (img, number) #if assignee is not None: #text += '<br/><a href="https://launchpad.net/~%s" %s>' % (assignee, color_link) #text += '<img alt="" src="https://launchpad.net/@@/person" />%s' % assignee #text += '</a>' #bug_text.append(text) #status += ', '.join(bug_text) #elif package.tanglu_version == '': #status += '<a href="https://launchpad.net/ubuntu/+filebug?field.title=[needs-packaging] %s&field.tags=needs-packaging&no-redirect">' % package.source #status += 'Open Bug...' #status += '</a>' #elif package.is_upstream_newer: #status += '<a href="https://launchpad.net/ubuntu/+source/%s/+filebug?field.title=Update to %s&field.tags=upgrade-software-version&no-redirect">' % (package.source,package.upstream_version) #status += 'Open Bug...' #status += '</a>' #elif package.is_debian_newer: #status += '<a href="https://launchpad.net/ubuntu/+source/%s/+filebug?field.title=Merge with Debian %s&field.tags=upgrade-software-version&no-redirect">' % (package.source,package.debian_version) #status += 'Open Bug...' #status += '</a>' html += ' <td>\n' html += ' <img alt="" src="https://launchpad.net/@@/package-source" />\n' html += ' <a href="http://packages.tanglu.org/source/%s">%s</a>\n' % (package.source, package.source) html += ' </td>\n' # version = '<a class="versionlink" href="http://launchpad.net/ubuntu/+source/%s/%s">%s</a>' % (package.source, package.tanglu_version, package.tanglu_version) # FIXME: Add Tanglu PTS link instead! version = '<a class="versionlink" href="http://buildd.tanglu.org/source/default/%s/%s/">%s</a>' % (package.source, package.tanglu_version, package.tanglu_version) if package.in_queue: version = '%s Q' % version for (arch, url) in package.build_failures: version += '<img src="https://launchpad.net/@@/build-failed"/><a href="%s">%s</a>' % (url, arch) for merge in package.merges: version += '<a href="%s"><img src="https://launchpad.net/@@/branch"/></a>' % merge html += ' <td>%s</td>\n' % version #FIXME: Doesn't correct things like iceweasel and gdm3 html += ' <td><a class="versionlink" href="http://ftp-master.metadata.debian.org/changelogs/main/%c/%s/%s_%s_changelog">%s</a>' % (package.source[0], package.source, package.source, package.debian_version, package.debian_version) html += ' (<a href="https://tracker.debian.org/pkg/%s">PTS</a>)</td>\n' % (package.source) version = package.upstream_version if package.upstream_version_link is not None: version = '<a class="versionlink" href="%s">%s</a>' % (package.upstream_version_link, version) if package.upstream_unstable_version is not None: unstable_version = package.upstream_unstable_version if package.upstream_unstable_version_link is not None: unstable_version = '<a class="versionlink" href="%s">%s</a>' % (package.upstream_unstable_version_link, unstable_version) version = '%s / %s' % (version, unstable_version) html += ' <td>%s</td>\n' % version html += ' <td>%s</td>\n' % status html += """ <tr class='spacing'><td><br></td> <tr class='untracked'><td colspan='5'>Untracked packages</td> <tr class='uptodate'><td colspan='5'>Tanglu package is latest upstream</td> <tr class='newunstable'><td colspan='5'>New unstable version available</td> <tr class='newdebian'><td colspan='5'>Newer version available in Debian</td> <tr class='syncnewupstream'><td colspan='5'>Synchronised with Debian but newer version available upstream</td> <tr class='newupstream'><td colspan='5'>Unsynchronised and newer version available upstream</td> <tr class='newboth'><td colspan='5'>Newer upstream and Debian versions available</td> <tr class='spacing'><td><br></td> <tr class='newboth' style="color:grey"><td colspan='5'>Associated bug in "Fix Committed" state</td> <tr class='spacing'><td><br></td> </table> """ # Pie chart of status SIZE = 200 offset = 0 styles = [('uptodate', '#bcfc7e'), ('newunstable', '#ddfd7f'), ('newdebian', '#ffff80'), ('syncnewupstream', '#ffd280'), ('newupstream', '#ffb97f'), ('newboth', '#ffa17e'), ('untracked', '#e0e0e0')] html += '<svg with="%d" height="%d">\n' % (SIZE, SIZE) for (name, color) in styles: r = SIZE * 0.5 if not style_count.has_key (name): continue step = style_count[name] a0 = 2 * math.pi * offset / style_total a1 = 2 * math.pi * (offset + step) / style_total large_arc = 0 if a1 - a0 > math.pi: large_arc = 1 x0 = r + r * math.sin (a0) y0 = r + r * math.cos (a0) x1 = r + r * math.sin (a1) y1 = r + r * math.cos (a1) html += '<path d="M%f,%f L%f,%f A%f,%f 0 %d,0 %r,%r" fill="%s"/>\n' % (r, r, x0, y0, r, r, large_arc, x1, y1, color) offset += step html += '</svg>\n' # Warn about packages without tags untagged_packages = [] for p in packages: if len (packages[p].tags) == 0: untagged_packages.append (packages[p].source) untagged_packages.sort () if len (untagged_packages) > 0: html += '<p>\n' html += '<a href="untagged.html">Untagged packages</a> (%d):<br>\n' % len (untagged_packages) for (n, p) in enumerate (untagged_packages): if n != 0: html += ', ' html += '<a href="http://packages.tanglu.org/source/%s">%s</a>' % (p, p) html += '</p>\n' foot_html = '<p>\n' foot_html += 'Last updated: %s, took %d minutes, %d seconds<br>\n' % (time.strftime('%A %B %d %Y %H:%M:%S %z'), n_minutes, n_seconds) foot_html += '</p>\n' foot_html += '<p style="font-size: xx-small;">These pages are generated by pkgcheck (part of Rapidumo) (<a href="https://gitlab.com/tanglu/rapidumo">sources</a>). It contains code originally written for Ubuntu.\n' foot_html += '</p>\n' return html, foot_html
import apt_pkg apt_pkg.init_system() from packages import package_info, package_sets, DEBIAN, TANGLU, UNTRACKED, germinate_tags from utils import compare_versions, load_germinate from rapidumo.utils import debug if 'PACKAGE_SET' in os.environ: PACKAGE_SET = os.environ['PACKAGE_SET'] else: PACKAGE_SET = 'all' # this is a limited list of packages for quicker testing # PACKAGE_SET = 'dummy' debug ('Starting') from rapidumo.pkginfo import * from rapidumo.config import * from rapidumo.utils import render_template class Package: def __init__(self, name, stable_url, unstable_url): self.source = name self.tags = [] self.on_cd = False self.stable_url = stable_url self.unstable_url = unstable_url self.is_debian_newer = False self.is_upstream_newer = False self.is_upstream_unstable_newer = False