mirror of
https://github.com/golang/go
synced 2024-11-24 22:00:09 -07:00
godashboard: Show packages at launchpad.net
The changes were not tested for real in an App Engine environment, so extra care should be taken. That said, some static testing was done with pyflakes, and a few existent problems were fixed on the way. R=adg CC=golang-dev https://golang.org/cl/4378053
This commit is contained in:
parent
08b0927771
commit
328aac3a49
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
from google.appengine.api import mail
|
from google.appengine.api import mail
|
||||||
from google.appengine.api import memcache
|
from google.appengine.api import memcache
|
||||||
from google.appengine.runtime import DeadlineExceededError
|
|
||||||
from google.appengine.ext import db
|
from google.appengine.ext import db
|
||||||
from google.appengine.ext import webapp
|
from google.appengine.ext import webapp
|
||||||
from google.appengine.ext.webapp import template
|
from google.appengine.ext.webapp import template
|
||||||
@ -219,7 +218,7 @@ class SetHighwater(webapp.RequestHandler):
|
|||||||
q = Commit.all()
|
q = Commit.all()
|
||||||
q.order('-__key__')
|
q.order('-__key__')
|
||||||
recent = q.fetch(N+1)
|
recent = q.fetch(N+1)
|
||||||
for c in head:
|
for c in recent:
|
||||||
if c.node == newhw:
|
if c.node == newhw:
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
@ -384,7 +383,6 @@ class Benchmarks(webapp.RequestHandler):
|
|||||||
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
|
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
|
||||||
self.response.out.write('{"benchmarks": [')
|
self.response.out.write('{"benchmarks": [')
|
||||||
|
|
||||||
first = True
|
|
||||||
sep = "\n\t"
|
sep = "\n\t"
|
||||||
for b in bs:
|
for b in bs:
|
||||||
self.response.out.write('%s"%s"' % (sep, b.name))
|
self.response.out.write('%s"%s"' % (sep, b.name))
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
# It must be run by App Engine.
|
# It must be run by App Engine.
|
||||||
|
|
||||||
from google.appengine.api import memcache
|
from google.appengine.api import memcache
|
||||||
from google.appengine.runtime import DeadlineExceededError
|
|
||||||
from google.appengine.ext import db
|
from google.appengine.ext import db
|
||||||
from google.appengine.ext import webapp
|
from google.appengine.ext import webapp
|
||||||
from google.appengine.ext.webapp import template
|
from google.appengine.ext.webapp import template
|
||||||
@ -14,15 +13,10 @@ from google.appengine.ext.webapp.util import run_wsgi_app
|
|||||||
from google.appengine.api import users
|
from google.appengine.api import users
|
||||||
from google.appengine.api import mail
|
from google.appengine.api import mail
|
||||||
from google.appengine.api import urlfetch
|
from google.appengine.api import urlfetch
|
||||||
import binascii
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
|
||||||
import hmac
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import struct
|
|
||||||
import time
|
|
||||||
import urllib2
|
import urllib2
|
||||||
import sets
|
import sets
|
||||||
|
|
||||||
@ -52,6 +46,8 @@ class Project(db.Model):
|
|||||||
re_bitbucket = re.compile(r'^bitbucket\.org/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
|
re_bitbucket = re.compile(r'^bitbucket\.org/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
|
||||||
re_googlecode = re.compile(r'^[a-z0-9\-]+\.googlecode\.com/(svn|hg)$')
|
re_googlecode = re.compile(r'^[a-z0-9\-]+\.googlecode\.com/(svn|hg)$')
|
||||||
re_github = re.compile(r'^github\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
|
re_github = re.compile(r'^github\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
|
||||||
|
re_launchpad = re.compile(r'^launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?$')
|
||||||
|
|
||||||
|
|
||||||
def vc_to_web(path):
|
def vc_to_web(path):
|
||||||
if re_bitbucket.match(path):
|
if re_bitbucket.match(path):
|
||||||
@ -65,6 +61,8 @@ def vc_to_web(path):
|
|||||||
elif re_googlecode.match(path):
|
elif re_googlecode.match(path):
|
||||||
check_url = 'http://'+path
|
check_url = 'http://'+path
|
||||||
web = 'http://code.google.com/p/' + path[:path.index('.')]
|
web = 'http://code.google.com/p/' + path[:path.index('.')]
|
||||||
|
elif re_launchpad.match(path):
|
||||||
|
check_url = web = 'https://'+path
|
||||||
else:
|
else:
|
||||||
return False, False
|
return False, False
|
||||||
return web, check_url
|
return web, check_url
|
||||||
@ -72,7 +70,8 @@ def vc_to_web(path):
|
|||||||
re_bitbucket_web = re.compile(r'bitbucket\.org/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
|
re_bitbucket_web = re.compile(r'bitbucket\.org/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
|
||||||
re_googlecode_web = re.compile(r'code.google.com/p/([a-z0-9\-]+)')
|
re_googlecode_web = re.compile(r'code.google.com/p/([a-z0-9\-]+)')
|
||||||
re_github_web = re.compile(r'github\.com/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
|
re_github_web = re.compile(r'github\.com/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
|
||||||
re_striphttp = re.compile(r'http://(www\.)?')
|
re_launchpad_web = re.compile(r'launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?')
|
||||||
|
re_striphttp = re.compile(r'https?://(www\.)?')
|
||||||
|
|
||||||
def web_to_vc(url):
|
def web_to_vc(url):
|
||||||
url = re_striphttp.sub('', url)
|
url = re_striphttp.sub('', url)
|
||||||
@ -93,6 +92,9 @@ def web_to_vc(url):
|
|||||||
vcs = 'hg'
|
vcs = 'hg'
|
||||||
except: pass
|
except: pass
|
||||||
return path + vcs
|
return path + vcs
|
||||||
|
m = re_launchpad_web.match(url)
|
||||||
|
if m:
|
||||||
|
return m.group(0)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
MaxPathLength = 100
|
MaxPathLength = 100
|
||||||
@ -136,7 +138,7 @@ class PackagePage(webapp.RequestHandler):
|
|||||||
sep = ','
|
sep = ','
|
||||||
s += '\n]}\n'
|
s += '\n]}\n'
|
||||||
json = s
|
json = s
|
||||||
memcache.set('view-package-json', json, time=CacheTimeoout)
|
memcache.set('view-package-json', json, time=CacheTimeout)
|
||||||
self.response.out.write(json)
|
self.response.out.write(json)
|
||||||
|
|
||||||
def can_get_url(self, url):
|
def can_get_url(self, url):
|
||||||
@ -150,7 +152,8 @@ class PackagePage(webapp.RequestHandler):
|
|||||||
def is_valid_package_path(self, path):
|
def is_valid_package_path(self, path):
|
||||||
return (re_bitbucket.match(path) or
|
return (re_bitbucket.match(path) or
|
||||||
re_googlecode.match(path) or
|
re_googlecode.match(path) or
|
||||||
re_github.match(path))
|
re_github.match(path) or
|
||||||
|
re_launchpad.match(path))
|
||||||
|
|
||||||
def record_pkg(self, path):
|
def record_pkg(self, path):
|
||||||
# sanity check string
|
# sanity check string
|
||||||
|
Loading…
Reference in New Issue
Block a user