예제 #1
0
def countSubscriptionRequests(logPath, counts):
  regexp = re.compile(r'"GET \/getSubscription\?([^" ]*) ')
  f = GzipFile(logPath, 'rb')
  for line in f:
    matches = re.search(regexp, line)
    if matches:
      query = matches.group(1)
      params = parse_qs(query)
      if not 'version' in params or compareVersions(params['version'][0], '1.3.5') < 0:
        continue
      if not 'url' in params:
        continue
      url = params['url'][0]
      if re.match(r'^https?:[\x00-\x7F]+$', url):
        if not url in counts:
          counts[url] = 1
        else:
          counts[url] += 1
  f.close()
예제 #2
0
def getDownloadLink(repo):
  """
  gets the download link to the most current version of an extension
  """
  galleryURL = None
  galleryVersion = None
  if repo.type == "gecko" and repo.galleryID:
    (galleryURL, galleryVersion) = getMozillaDownloadLink(repo.galleryID)
  elif repo.type == "chrome" and repo.galleryID:
    (galleryURL, galleryVersion) = getGoogleDownloadLink(repo.galleryID)
  elif repo.type == "opera" and repo.galleryID:
    (galleryURL, galleryVersion) = getOperaDownloadLink(repo.galleryID)

  (downloadsURL, downloadsVersion) = getLocalLink(repo)
  if galleryVersion == None or (downloadsVersion != None and
                                compareVersions(galleryVersion, downloadsVersion) < 0):
    return (downloadsURL, downloadsVersion)
  else:
    return (galleryURL, galleryVersion)
예제 #3
0
def countSubscriptionRequests(logPath, counts):
    regexp = re.compile(r'"GET \/getSubscription\?([^" ]*) ')
    f = GzipFile(logPath, 'rb')
    for line in f:
        matches = re.search(regexp, line)
        if matches:
            query = matches.group(1)
            params = parse_qs(query)
            if not 'version' in params or compareVersions(
                    params['version'][0], '1.3.5') < 0:
                continue
            if not 'url' in params:
                continue
            url = params['url'][0]
            if re.match(r'^https?:[\x00-\x7F]+$', url):
                if not url in counts:
                    counts[url] = 1
                else:
                    counts[url] += 1
    f.close()
예제 #4
0
def getLocalLink(repo):
  """
  gets the link for the newest download of an add-on in the local downloads
  repository
  """
  url = repo.downloadsURL

  highestURL = None
  highestVersion = None
  prefix = os.path.basename(repo.repository) + '-'
  suffix = repo.packageSuffix

  # go through the downloads repository looking for downloads matching this extension
  command = ['hg', 'locate', '-R', repo.downloadsRepo, '-r', 'default']
  result = subprocess.check_output(command)
  for fileName in result.splitlines():
    if fileName.startswith(prefix) and fileName.endswith(suffix):
      version = fileName[len(prefix):len(fileName) - len(suffix)]
      if highestVersion == None or compareVersions(version, highestVersion) > 0:
        highestURL = urlparse.urljoin(url, fileName)
        highestVersion = version
  return (highestURL, highestVersion)