summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Dartiguelongue <eva@gentoo.org>2010-10-23 13:53:35 +0200
committerGilles Dartiguelongue <eva@gentoo.org>2010-10-23 13:53:35 +0200
commit8a43e7460fcb23dc1bfc8f903824639f218ad0c0 (patch)
tree7151b149842734ef8bde22c88f11c9637d0211bc
parentFix sys.path alteration to allow invocation from any directory (diff)
downloadgentoo-bumpchecker-8a43e7460fcb23dc1bfc8f903824639f218ad0c0.tar.gz
gentoo-bumpchecker-8a43e7460fcb23dc1bfc8f903824639f218ad0c0.tar.bz2
gentoo-bumpchecker-8a43e7460fcb23dc1bfc8f903824639f218ad0c0.zip
Fix various style issues
* Remove trailing whitespaces * Add some whitespace per PEP8 * Replace tabs by spaces in x-modular per PEP * Make Status class in package_module a new style object since it uses property methods
-rwxr-xr-xgnome-bumpchecker.py4
-rw-r--r--modules/clioptions_module.py8
-rw-r--r--modules/ftp_module.py55
-rw-r--r--modules/gnome_module.py48
-rw-r--r--modules/gnome_output.py36
-rw-r--r--modules/package_module.py26
-rw-r--r--modules/portage_module.py22
-rw-r--r--modules/simple_cache_module.py36
-rw-r--r--modules/xmodular_module.py300
-rw-r--r--modules/xmodular_output.py42
-rwxr-xr-xx-modular-bumpchecker.py6
11 files changed, 293 insertions, 290 deletions
diff --git a/gnome-bumpchecker.py b/gnome-bumpchecker.py
index 66fa102..4ddb3d5 100755
--- a/gnome-bumpchecker.py
+++ b/gnome-bumpchecker.py
@@ -3,7 +3,7 @@
# Copyright Daniel Gryniewicz <dang@gentoo.org>
# LICENSE - GPL2
-import os,sys
+import os, sys
sys.path.append(os.path.sep.join([os.path.dirname(sys.argv[0]), 'modules']))
@@ -44,7 +44,7 @@ if __name__ == '__main__':
comparison_result_packages = gnome_module.compare_packages(release_packages, \
latest_packages, \
packages_in_portage)
-
+
# output these results to a nice html document
import gnome_output
gnome_output.Output(comparison_result_packages, True).generate_html()
diff --git a/modules/clioptions_module.py b/modules/clioptions_module.py
index 0020f7f..1175ac8 100644
--- a/modules/clioptions_module.py
+++ b/modules/clioptions_module.py
@@ -5,14 +5,14 @@
from optparse import OptionParser
class Options:
-
+
def __init__(self):
usage = "usage: %prog [-qkn] -o <filename> -r <release_number>"
self.parser = OptionParser(usage=usage)
self.setup_parser()
-
+
self.options = self.parser.parse_args()[0]
-
+
def setup_parser(self):
self.parser.add_option("-o", "--output", dest="output",
help="write report to FILE", metavar="FILE")
@@ -37,7 +37,7 @@ class Options:
self.parser.add_option("-a", "--overlay", metavar="OVERLAY",
action="append", dest="overlays", default=None,
help="Overlay to scan in addition to PORTDIR. Specify multiple times to scan more than one overlay.")
-
+
def get_arguments(self):
if (self.options.output == None):
self.parser.error("No output file")
diff --git a/modules/ftp_module.py b/modules/ftp_module.py
index b712e53..837624c 100644
--- a/modules/ftp_module.py
+++ b/modules/ftp_module.py
@@ -8,15 +8,15 @@
################
# my ftp module that should be easier to understand.
-import os,ftplib
+import os, ftplib
DEBUG = False
class FTPWalker:
def __init__(self, site, user, passwd):
- self.ftp = ftplib.FTP(site,user,passwd)
+ self.ftp = ftplib.FTP(site, user, passwd)
if DEBUG: print "logged into ftp"
-
- def cd(self,path):
+
+ def cd(self, path):
try:
self.ftp.cwd(path)
#sys.stdout.write(".")
@@ -25,21 +25,21 @@ class FTPWalker:
except:
print "Directory does not exist " + path
return False
-
+
def pwd(self):
return self.ftp.pwd()
-
- def ls( self, cwd ):
+
+ def ls(self, cwd):
lines = []
- self.ftp.retrlines( "LIST", lines.append )
- return map( lambda x: self.extract_info( cwd, x ), lines )
-
- def str2perm( self,str ):
+ self.ftp.retrlines("LIST", lines.append)
+ return map(lambda x: self.extract_info(cwd, x), lines)
+
+ def str2perm(self, str):
return str[0] == 'd', str[0] == 'l'
def extract_info( self, cwd, line ):
- fullmode, links, owner, group, size, rest = line.split( None, 5 )
- isdir, islink = self.str2perm( fullmode )
+ fullmode, links, owner, group, size, rest = line.split(None, 5)
+ isdir, islink = self.str2perm(fullmode)
name = rest[13:]
#if 0 < string.find(name,"->"):
if islink:
@@ -47,47 +47,48 @@ class FTPWalker:
name = name.strip()
symbolic = symbolic.strip()
if DEBUG: print "Name of the file is: " + name
-
+
return FileInformation(name, isdir)
class FileInformation:
def __init__(self, name, isdirectory):
self.name = name
self.isdir = isdirectory
-
-def pattern( p, v ): return fnmatch.fnmatch( v, p )
-def dropslashes( str ):
+def pattern(p, v):
+ return fnmatch.fnmatch(v, p)
+
+def dropslashes( str ):
i, n = 0, len( str )
while i < n and str[i] == '/': i += 1
return str[i:]
-def excluded( exclude_patterns, dir ):
+def excluded(exclude_patterns, dir):
for exclude_pattern in exclude_patterns:
- if pattern( exclude_pattern, dir ):
+ if pattern(exclude_pattern, dir):
return True
return False
-def listSiteGen( walker, dir, excluded_names):
+def listSiteGen(walker, dir, excluded_names):
path = walker.pwd()
#if not excluded( excluded_names, dir ) and walker.cd( dir ):
if walker.cd(dir):
- newpath = dropslashes( os.path.join( path, dir ) )
- lsresult = walker.ls( newpath )
+ newpath = dropslashes(os.path.join(path, dir))
+ lsresult = walker.ls(newpath)
for info in lsresult:
if info.isdir:
- for rec_info in listSiteGen( walker, info.name, excluded_names):
+ for rec_info in listSiteGen(walker, info.name, excluded_names):
yield rec_info
else:
yield info
- walker.cd( path )
+ walker.cd(path)
def find_files(walker, dir, excluded_names, excluded_suffixes):
file_listing = []
-
- for fileinfo in listSiteGen( walker, dir, excluded_names):
+
+ for fileinfo in listSiteGen(walker, dir, excluded_names):
#if not excluded( excluded_suffixes, fileinfo):
if DEBUG: print "Appending: " + str(fileinfo.name)
file_listing.append(fileinfo.name)
-
+
return file_listing
diff --git a/modules/gnome_module.py b/modules/gnome_module.py
index 1eb2198..1caee1d 100644
--- a/modules/gnome_module.py
+++ b/modules/gnome_module.py
@@ -8,12 +8,12 @@ import clioptions_module
-DEBUG=False
+DEBUG = False
class GNOME:
def __init__(self, nextrev=False):
options = clioptions_module.Options()
args = options.get_arguments()
-
+
self.nextrev = nextrev;
self.major_release = ".".join( args.release_number.split(".")[:2] )
self.full_release = args.release_number
@@ -67,21 +67,21 @@ class GNOME:
def generate_data_ftp(self):
# Deprecated: connect to ftp and get the list of all the packages in the release directories
walker = ftp_module.FTPWalker(self.ftpserver,"anonymous","test@test.com")
-
+
files = []
for directory in self.release_directories:
f_files = ftp_module.find_files(walker, directory,"","")
files.extend(f_files)
-
+
# filter out bad files
files = self.filter_files(files)
-
+
# create package objects for the files
release_packages = [] # the packages that are required for a release
for package_name in files:
release_package = package_module.Package(package_name)
release_packages.append(release_package)
-
+
# while connected, find out the latest version of the packages that we found in the
# release directories
latest_packages = [] # the latest versions of packages on the gnome ftp.
@@ -114,15 +114,15 @@ class GNOME:
# make sure we don't try to do this on directories with no files,
# or on directories that don't exist
-
+
# create package objects for the files
if len(file_list) > 0:
latest = self.filter_latest_only(file_list)
latest_package = package_module.Package(package.name + "-" + latest)
latest_packages.append(latest_package)
-
+
# disconnect from the ftp
-
+
# cache the results
cache = simple_cache_module.SimpleCache()
for release_package in release_packages:
@@ -132,7 +132,7 @@ class GNOME:
else:
print "No matching latest package!" + str(release_package.name)
cache.flush_queue()
-
+
return (release_packages, latest_packages)
"""
@@ -141,27 +141,27 @@ class GNOME:
newfiles = []
for file in files:
# only keep files with .tar.bz2 ending.
- if ( 0 < file.find(".tar.") and 0 < file.find(".bz2") ):
- file = string.replace(file,".tar.bz2","")
+ if 0 < file.find(".tar.") and 0 < file.find(".bz2"):
+ file = string.replace(file, ".tar.bz2", "")
newfiles.append(file)
-
+
return newfiles
-
+
# this needs to be fixed so that if a directory doesn't have LATEST-IS-, it returns an error
def filter_latest_only(self, lines):
latest_string = "LATEST-IS-"
latest = ""
for item in lines:
- if 0 <= string.rfind(item,latest_string):
+ if 0 <= string.rfind(item, latest_string):
latest = item
-
+
try:
return_latest = latest[10:]
except:
return_latest = ""
-
+
return return_latest
-
+
import portage_module
def compare_packages(release_packages, latest_packages, packages_in_portage):
# we care about 5 cases
@@ -170,7 +170,7 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
# 3. portage version is equal to the release version and the latest version. (GREEN)
# 4. portage version is greater than the release version (GREEN)
# 5. package does not exist in portage (GREY)
-
+
# again, we choose release_packages as the enumerator for the package names
# since it will have ALL packages ( for example, if we used portage_packages, we
# might miss the packages that do not exist in portage )
@@ -183,7 +183,7 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
print "Warning: latest packages set does not have an entry for %s, using release set version %s." % (package.name, package.version)
latest_package = package
portage_package = portage_module.findpackage(package.name, packages_in_portage)
-
+
if portage_package == None:
status = package_module.Status.NotFound
# we need to create a phony package since findpackage
@@ -193,11 +193,11 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
elif portage_module.best_version_test(portage_package.name_plus_version, \
release_package.name_plus_version) == 2:
status = package_module.Status.NeedUpdate
-
+
elif portage_module.best_version_test(portage_package.name_plus_version, \
latest_package.name_plus_version) == 2:
status = package_module.Status.NewerVersion
-
+
else:
status = package_module.Status.Compliant
@@ -207,7 +207,7 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
if latest_package == None:
print "No latest version known for %s, FIXME!" % release_package.name
latest_package = release_package
-
+
if DEBUG:
print "package: " + str(release_package.name) + \
" | pp: " + str(portage_package.version) + \
@@ -216,5 +216,5 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
" | status: " + str(status)
status_packages.append(package_module.PackageStatus(release_package.name, str(portage_package.version), str(release_package.version), str(latest_package.version), status))
-
+
return status_packages
diff --git a/modules/gnome_output.py b/modules/gnome_output.py
index f985a85..9859a6f 100644
--- a/modules/gnome_output.py
+++ b/modules/gnome_output.py
@@ -1,7 +1,7 @@
# Copyright John N. Laliberte <allanonjl@gentoo.org>
# LICENSE - GPL2
-import package_module,time,clioptions_module,gnome_module,os
+import package_module, time, clioptions_module, gnome_module, os
class Output:
@@ -10,7 +10,7 @@ class Output:
if to_calculate:
self.calculate_stats()
-
+
def calculate_stats(self):
# Variables for holding stats
total_packs = len(self.packages)
@@ -25,13 +25,13 @@ class Output:
for package in self.packages:
if package.status == package_module.Status.Compliant:
- self.compliant +=1
+ self.compliant += 1
elif package.status == package_module.Status.NewerVersion:
- self.newer +=1
+ self.newer += 1
elif package.status == package_module.Status.NotFound:
- self.not_found +=1
+ self.not_found += 1
elif package.status == package_module.Status.NeedUpdate:
- self.update_needed +=1
+ self.update_needed += 1
if total_packs == 0:
return
@@ -41,15 +41,15 @@ class Output:
self.notfound_percent = 100 * self.not_found / float(total_packs)
def generate_html(self):
-
+
# now we have all the results in the results list.
# just time to generate some kind of "useful" output.
# for now, lets just make a crappy html file. ( this should use css and the like )
# name, portage_version, gnome_version, status <-- is whats in the PackageUpdate object
current_time = str(time.asctime(time.localtime()))
-
+
lines = []
-
+
# header
lines.append('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">')
lines.append("<html>")
@@ -63,19 +63,19 @@ class Output:
lines.append("Generated date: " + current_time + "<br>")
lines.append("<a href=\"" + gnome_module.GNOME().latest_versions_url \
+ "\">Upstream versions list</a> <br>")
-
+
# stats
lines.append("<br>")
lines.append("Compliant Packages: %d (%0.2f%%)<br />" % (self.compliant, self.compliant_percent))
lines.append("Packages requiring update: %d (%0.2f%%)<br />" % (self.update_needed, self.update_percent))
lines.append("Packages missing from tree: %d (%0.2f%%)<br />" % (self.not_found, self.notfound_percent))
lines.append("<br>")
-
+
lines.append('<table cellpadding="3">')
lines.append('<tr>')
lines.append("<th>Package Name</th><th>Portage Version</th><th>Official Version</th><th>Latest Version</th>")
lines.append('</tr>')
-
+
# data
for package in self.packages:
if package.status == package_module.Status.NeedUpdate:
@@ -86,23 +86,23 @@ class Output:
lines.append('<tr bgcolor="#EBEBEB">') # "grey"
elif package.status == package_module.Status.NewerVersion:
lines.append('<tr bgcolor="#FFFF95">') # "yellow"
-
+
lines.append("<td>" + str(package.name) + "</td>")
lines.append("<td>" + str(package.portage_version) + "</td>")
lines.append("<td>" + str(package.gnome_version) + "</td>")
lines.append("<td>" + str(package.latest_version) + "</td>")
-
+
lines.append("</tr>")
-
+
lines.append("</table>")
-
+
# footer
lines.append("<br>Official Version: GNOME release teams blessed version for the whole GNOME-%s set" % clioptions_module.Options().get_arguments().release_number)
lines.append("<br>Latest Version: Latest available version release of the same GNOME release cycle")
lines.append("</html>")
-
+
self.write_file(lines, clioptions_module.Options().get_arguments().output)
-
+
print "Generated html output."
def generate_keywords(self):
diff --git a/modules/package_module.py b/modules/package_module.py
index 442bdcd..73c789d 100644
--- a/modules/package_module.py
+++ b/modules/package_module.py
@@ -29,17 +29,19 @@ class Package(object):
def __init__(self, raw_data):
self.raw_string = raw_data
-
+
self.name = None
self.version = None
self.revision = None
self.major_minor = None
self.raw_name = None
-
+
+ self.package_version = None
+
self.category = None
-
+
self.parse_raw_string(raw_data)
-
+
self.handle_special_cases()
@property
@@ -58,24 +60,24 @@ class Package(object):
split_string = portage_module.split_package_into_parts(raw_string)
if None != split_string:
#[cat, pkgname, version, rev ]
- self.category,self.name,self.version,self.revision = split_string
+ self.category, self.name, self.version, self.revision = split_string
self.raw_name = self.name
self.major_minor = self.parse_mm(self.version)
# else:
# print "Error, " + raw_string + " is not a valid package!"
-
+
def parse_mm(self, version):
return '.'.join(version.split('.')[0:2])
-
+
def print_info(self):
print "Name: " + str(self.name)
print "Version: " + str(self.package_version)
print "Name+Version: " + str(self.name_plus_version)
print "Raw: " + str(self.raw_string)
-
+
def __repr__(self):
return self.name_plus_version
-
+
class PackageStatus:
def __init__(self, name, portage_version, gnome_version, latest_version, status, stable_version = False):
self.name = name
@@ -85,8 +87,8 @@ class PackageStatus:
self.gnome_version = gnome_version
self.latest_version = latest_version
self.status = status
-
-class Status:
+
+class Status(object):
def Compliant(self):
return 0
def NeedUpdate(self):
@@ -97,7 +99,7 @@ class Status:
return 2
def StableNeedUpdate(self):
return 3
-
+
property(Compliant)
property(NeedUpdate)
property(NotFound)
diff --git a/modules/portage_module.py b/modules/portage_module.py
index 82c4cf1..f41e4a0 100644
--- a/modules/portage_module.py
+++ b/modules/portage_module.py
@@ -4,10 +4,10 @@
# the portage module.
import os, sys, shutil
-import string,signal,re,pickle,tempfile
+import string, signal, re, pickle, tempfile
import package_module
-sys.path = ["/usr/lib/portage/pym"]+sys.path
-os.environ["PORTAGE_CALLER"]="depchecker"
+sys.path = ["/usr/lib/portage/pym"] + sys.path
+os.environ["PORTAGE_CALLER"] = "depchecker"
import portage
import portage.util
@@ -25,7 +25,7 @@ def split_package_into_parts(package_name):
# This will return None if you do not give it a version.
def find_category(package_name):
package = portage.cpv_expand(package_name, mydb=portage.db["/"][get_dbtree()].dbapi, use_cache=1)
-
+
# catsplit returns ['category', 'packagename']
package = portage.catsplit(package)
return package[0]
@@ -55,9 +55,9 @@ def findpackage(name, packages):
# returns 0 for equal
# 1 for package1
# 2 for package2
-def best_version_test(package1,package2):
- best_package = portage.best([package1,package2])
-
+def best_version_test(package1, package2):
+ best_package = portage.best([package1, package2])
+
if best_package == package1 and best_package == package2:
return 0
elif best_package == package1:
@@ -81,7 +81,7 @@ def find_latest_package_in_tree(package_name, portdbapi=None):
def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overlay_list=None, stable=False):
# this value needs to be configurable from cl
#overlays = ["/home/allanon/cvs/gnome"]
-
+
portage_versions = []
portdbsettings = portage.db['/'][get_dbtree()].settings
portdbapi = portage.db['/'][get_dbtree()].dbapi
@@ -128,7 +128,7 @@ def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overla
if None != best_package and "" != best_package:
# Need to account for slotted packages here
portage_versions.append(package_module.Package(best_package))
-
+
# Restore portdb trees list
if all_overlays is False:
portdbapi.porttrees = oldporttrees
@@ -137,7 +137,7 @@ def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overla
portage.dbapi = olddbapi_kw
if old_dbapi is not None:
portage.dbapi = old_dbapi
-
+
return portage_versions
def tests():
@@ -145,4 +145,4 @@ def tests():
print split_package_into_parts("media-gfx/gimp-3.5")
print find_category("gimp")
print find_category("gimp-2.0")
- print best_version(["gimp-2.0","gimp-2.0-r1","gimp-3.0"])
+ print best_version(["gimp-2.0", "gimp-2.0-r1", "gimp-3.0"])
diff --git a/modules/simple_cache_module.py b/modules/simple_cache_module.py
index aca3453..3f622fe 100644
--- a/modules/simple_cache_module.py
+++ b/modules/simple_cache_module.py
@@ -8,14 +8,14 @@
# of this program.
class SimpleCache:
-
+
def __init__(self):
self.filename = "cache.txt"
self.write_queue = []
-
+
def write_to_queue(self, release_version, latest_version):
self.write_queue.append(release_version + "," + latest_version)
-
+
def append(self, list_of_lines):
try:
# open file stream
@@ -23,33 +23,33 @@ class SimpleCache:
except IOError:
print "There was an error writing to"+self.filename
sys.exit()
-
+
for line in list_of_lines:
file.write(line+"\n")
-
+
file.close()
-
+
def flush_queue(self):
self.append(self.write_queue)
-
-
+
+
class FileStuff:
def __init__(self, filename):
self.filename = filename
self.lines = []
-
+
def read(self):
file = self.open("r")
# read the file in line by line, and then return it
for line in file.readlines():
# replace the newline characters
- line = string.replace(line,'\n','')
+ line = string.replace(line, '\n', '')
# add it to the collection
self.lines.append(line)
file.close()
-
+
return self.lines
-
+
def write(self, list_of_lines):
try:
# open file stream
@@ -57,12 +57,12 @@ class FileStuff:
except IOError:
print "There was an error writing to"+self.filename
sys.exit()
-
+
for line in list_of_lines:
file.write(line+"\n")
-
+
file.close()
-
+
def append(self, list_of_lines):
try:
# open file stream
@@ -70,12 +70,12 @@ class FileStuff:
except IOError:
print "There was an error writing to"+self.filename
sys.exit()
-
+
for line in list_of_lines:
file.write(line+"\n")
-
+
file.close()
-
+
def open(self, type):
try:
file = open(self.filename, type)
diff --git a/modules/xmodular_module.py b/modules/xmodular_module.py
index e570aa6..abd8de8 100644
--- a/modules/xmodular_module.py
+++ b/modules/xmodular_module.py
@@ -7,154 +7,154 @@ import urllib2, package_module, string, simple_cache_module
import clioptions_module
import ftp_module
-DEBUG=False
+DEBUG = False
class X_modular:
- def __init__(self):
- options = clioptions_module.Options()
- args = options.get_arguments()
- self.ftpserver = "ftp.x.org"
- #self.release_directories = [ "pub/current/src/app/", "pub/current/src/data/", "pub/current/src/doc/",
- # "pub/current/src/driver/", "pub/current/src/font/", "pub/current/src/lib/", "pub/current/src/proto/",
- # "pub/current/src/util/", "pub/current/src/xserver/" ]
- self.latest_directories = [ "pub/individual/app/", "pub/individual/data/", "pub/individual/doc/",
- "pub/individual/driver/", "pub/individual/font/", "pub/individual/lib/", "pub/individual/proto/",
- "pub/individual/util/", "pub/individual/xserver/" ]
-
- def generate_data_ftp(self):
- walker = ftp_module.FTPWalker(self.ftpserver,"anonymous","test@test.com")
- #files = []
- #for directory in self.release_directories:
- # f_files = ftp_module.find_files(walker, directory,"","")
- # files.extend(f_files)
- # remove everything expect the tar.bz2
- #files = self.filter_files(files)
-
- individual_files = []
- for directory in self.latest_directories:
- #print "working in: "+directory
- f_files = ftp_module.find_files(walker, directory,"","")
- individual_files.extend(f_files)
- individual_files = self.filter_files(individual_files)
-
- # create package objects for the files
- #release_packages = [] # the packages that are required for a release
- #for package_name in files:
- # release_package = package_module.Package(package_name)
- # release_packages.append(release_package)
-
- individual_packages = []
- for individual_package_name in individual_files:
- individual_package = package_module.Package(individual_package_name)
- individual_packages.append(individual_package)
-
- # searching for formated packages
- #for ip in individual_packages:
- # if ip.name=="xkeyboard-config":
- # print ip.name+"-"+ip.version
-
- latest_packages = [] # the latest versions
- package_in_use = [] # checker so we dont repeat packages
- for package in individual_packages:
- # i am lazy so lets do just one way sort. Should be rewritten into something faster :]
- used = "false"
- for packname in package_in_use:
- if packname == package.name:
- used = "true"
- break
- if used == "true":
- continue
-
- package_in_use.append(package.name)
- latest = self.get_latest(individual_packages, package.name, package.version)
-
- latest_packages.append(package_module.Package(package.name + "-" + latest))
-
- snapshot_packages = []
- for package in latest_packages:
- latest = self.get_latest(individual_packages, package.name, package.version, "true")
- snapshot_packages.append(package_module.Package(package.name + "-" + latest))
-
- return (latest_packages, snapshot_packages)
-
- def get_latest(self, rel_packages, name, version, snapshots="false"):
- length = len(version.split("."))
- major = int(version.split(".")[0])
- minor = int(version.split(".")[1])
- if length < 3:
- latest = str(major)+"."+str(minor)
- subminor = 0
- else:
- subminor = int(version.split(".")[2]) # usually the lovely .99.
- if length < 4:
- latest = str(major)+"."+str(minor)+"."+str(subminor)
- subsubminor = 0
- else:
- subsubminor = int(version.split(".")[3])
- if length >= 4:
- latest = str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
- #rel_packages.sort()
- for paclist in rel_packages:
- if name == paclist.name: # we have the correct package name
- length = len(paclist.version.split("."))
- loc_major = int(paclist.version.split(".")[0])
- loc_minor = int(paclist.version.split(".")[1])
- if length < 3:
- loc_subminor = 0
- else:
- loc_subminor = int(paclist.version.split(".")[2])
- if length < 4:
- loc_subsubminor = 0
- else:
- loc_subsubminor = int(paclist.version.split(".")[3])
-
- if snapshots == "false" and ( ( loc_major > 98 or loc_minor > 98 or loc_subminor > 98 or loc_subsubminor > 98 ) or ( name == "pixman" and self.is_prvocislo(loc_minor) == True ) ):
- continue
- # Debuging why some package does not show correct version...
- #if name == "xkeyboard-config":
- # print "Vychozi: "+str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
- # print "Lokalni: "+str(loc_major)+"."+str(loc_minor)+"."+str(loc_subminor)+"."+str(loc_subsubminor)
- if loc_major < major:
- continue
- if loc_major == major and loc_minor < minor:
- continue
- if loc_major == major and loc_minor == minor and loc_subminor < subminor:
- continue
- if loc_major == major and loc_minor == minor and loc_subminor == subminor and loc_subsubminor < subsubminor:
- continue
-
- major = loc_major
- minor = loc_minor
- subminor = loc_subminor
- subsubminor = loc_subsubminor
- if length < 3:
- latest = str(major)+"."+str(minor)
- elif length < 4:
- latest = str(major)+"."+str(minor)+"."+str(subminor)
- else:
- latest = str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
- else:
- continue
- return latest
-
- def is_prvocislo(self, number):
- #print number
- if number % 2 == 1:
- return True
- else:
- return False
-
- def filter_files(self, files):
- # we want to filter out all the bad files.
- newfiles = []
- for file in files:
- # only keep files with .tar.bz2 or .tar.gz ending.
- if ( ( ( 0 < file.find(".tar.") and 0 < file.find(".bz2") ) or ( 0 < file.find(".tar.") and 0 < file.find(".gz") ) ) and 0 > file.find(".asc") and 0 > file.find(".sha") ):
- file = string.replace(file,".tar.gz","")
- file = string.replace(file,".tar.bz2","")
- newfiles.append(file)
-
- return newfiles
-
+ def __init__(self):
+ options = clioptions_module.Options()
+ args = options.get_arguments()
+ self.ftpserver = "ftp.x.org"
+ #self.release_directories = [ "pub/current/src/app/", "pub/current/src/data/", "pub/current/src/doc/",
+ # "pub/current/src/driver/", "pub/current/src/font/", "pub/current/src/lib/", "pub/current/src/proto/",
+ # "pub/current/src/util/", "pub/current/src/xserver/" ]
+ self.latest_directories = [ "pub/individual/app/", "pub/individual/data/", "pub/individual/doc/",
+ "pub/individual/driver/", "pub/individual/font/", "pub/individual/lib/", "pub/individual/proto/",
+ "pub/individual/util/", "pub/individual/xserver/" ]
+
+ def generate_data_ftp(self):
+ walker = ftp_module.FTPWalker(self.ftpserver, "anonymous", "test@test.com")
+ #files = []
+ #for directory in self.release_directories:
+ # f_files = ftp_module.find_files(walker, directory, "", "")
+ # files.extend(f_files)
+ # remove everything expect the tar.bz2
+ #files = self.filter_files(files)
+
+ individual_files = []
+ for directory in self.latest_directories:
+ #print "working in: "+directory
+ f_files = ftp_module.find_files(walker, directory, "", "")
+ individual_files.extend(f_files)
+ individual_files = self.filter_files(individual_files)
+
+ # create package objects for the files
+ #release_packages = [] # the packages that are required for a release
+ #for package_name in files:
+ # release_package = package_module.Package(package_name)
+ # release_packages.append(release_package)
+
+ individual_packages = []
+ for individual_package_name in individual_files:
+ individual_package = package_module.Package(individual_package_name)
+ individual_packages.append(individual_package)
+
+ # searching for formated packages
+ #for ip in individual_packages:
+ # if ip.name=="xkeyboard-config":
+ # print ip.name+"-"+ip.version
+
+ latest_packages = [] # the latest versions
+ package_in_use = [] # checker so we dont repeat packages
+ for package in individual_packages:
+ # i am lazy so lets do just one way sort. Should be rewritten into something faster :]
+ used = "false"
+ for packname in package_in_use:
+ if packname == package.name:
+ used = "true"
+ break
+ if used == "true":
+ continue
+
+ package_in_use.append(package.name)
+ latest = self.get_latest(individual_packages, package.name, package.version)
+
+ latest_packages.append(package_module.Package(package.name + "-" + latest))
+
+ snapshot_packages = []
+ for package in latest_packages:
+ latest = self.get_latest(individual_packages, package.name, package.version, "true")
+ snapshot_packages.append(package_module.Package(package.name + "-" + latest))
+
+ return (latest_packages, snapshot_packages)
+
+ def get_latest(self, rel_packages, name, version, snapshots="false"):
+ length = len(version.split("."))
+ major = int(version.split(".")[0])
+ minor = int(version.split(".")[1])
+ if length < 3:
+ latest = str(major)+"."+str(minor)
+ subminor = 0
+ else:
+ subminor = int(version.split(".")[2]) # usually the lovely .99.
+ if length < 4:
+ latest = str(major)+"."+str(minor)+"."+str(subminor)
+ subsubminor = 0
+ else:
+ subsubminor = int(version.split(".")[3])
+ if length >= 4:
+ latest = str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
+ #rel_packages.sort()
+ for paclist in rel_packages:
+ if name == paclist.name: # we have the correct package name
+ length = len(paclist.version.split("."))
+ loc_major = int(paclist.version.split(".")[0])
+ loc_minor = int(paclist.version.split(".")[1])
+ if length < 3:
+ loc_subminor = 0
+ else:
+ loc_subminor = int(paclist.version.split(".")[2])
+ if length < 4:
+ loc_subsubminor = 0
+ else:
+ loc_subsubminor = int(paclist.version.split(".")[3])
+
+ if snapshots == "false" and ( ( loc_major > 98 or loc_minor > 98 or loc_subminor > 98 or loc_subsubminor > 98 ) or ( name == "pixman" and self.is_prvocislo(loc_minor) == True ) ):
+ continue
+ # Debuging why some package does not show correct version...
+ #if name == "xkeyboard-config":
+ # print "Vychozi: "+str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
+ # print "Lokalni: "+str(loc_major)+"."+str(loc_minor)+"."+str(loc_subminor)+"."+str(loc_subsubminor)
+ if loc_major < major:
+ continue
+ if loc_major == major and loc_minor < minor:
+ continue
+ if loc_major == major and loc_minor == minor and loc_subminor < subminor:
+ continue
+ if loc_major == major and loc_minor == minor and loc_subminor == subminor and loc_subsubminor < subsubminor:
+ continue
+
+ major = loc_major
+ minor = loc_minor
+ subminor = loc_subminor
+ subsubminor = loc_subsubminor
+ if length < 3:
+ latest = str(major)+"."+str(minor)
+ elif length < 4:
+ latest = str(major)+"."+str(minor)+"."+str(subminor)
+ else:
+ latest = str(major)+"."+str(minor)+"."+str(subminor)+"."+str(subsubminor)
+ else:
+ continue
+ return latest
+
+ def is_prvocislo(self, number):
+ #print number
+ if number % 2 == 1:
+ return True
+ else:
+ return False
+
+ def filter_files(self, files):
+ # we want to filter out all the bad files.
+ newfiles = []
+ for file in files:
+ # only keep files with .tar.bz2 or .tar.gz ending.
+ if ( ( ( 0 < file.find(".tar.") and 0 < file.find(".bz2") ) or ( 0 < file.find(".tar.") and 0 < file.find(".gz") ) ) and 0 > file.find(".asc") and 0 > file.find(".sha") ):
+ file = string.replace(file, ".tar.gz", "")
+ file = string.replace(file, ".tar.bz2", "")
+ newfiles.append(file)
+
+ return newfiles
+
import portage_module
def compare_packages(release_packages, latest_packages, packages_in_portage, stable_packages_in_portage):
# we care about 5 cases
@@ -163,7 +163,7 @@ def compare_packages(release_packages, latest_packages, packages_in_portage, sta
# 3. portage version is equal to the release version and the latest version. (GREEN)
# 4. portage version is greater than the release version (GREEN)
# 5. package does not exist in portage (GREY)
-
+
# again, we choose release_packages as the enumerator for the package names
# since it will have ALL packages ( for example, if we used portage_packages, we
# might miss the packages that do not exist in portage )
@@ -203,7 +203,7 @@ def compare_packages(release_packages, latest_packages, packages_in_portage, sta
if latest_package == None:
print "No latest version known for %s, FIXME!" % release_package.name
latest_package = release_package
-
+
if DEBUG:
print "package: " + str(release_package.name) + \
" | sp: " + str(stable_portage_package.version) + \
@@ -213,5 +213,5 @@ def compare_packages(release_packages, latest_packages, packages_in_portage, sta
" | status: " + str(status)
status_packages.append(package_module.PackageStatus(release_package.name, str(portage_package.version), str(release_package.version), str(latest_package.version), status, str(stable_portage_package.version)))
-
+
return status_packages
diff --git a/modules/xmodular_output.py b/modules/xmodular_output.py
index 57f3c9c..a510c58 100644
--- a/modules/xmodular_output.py
+++ b/modules/xmodular_output.py
@@ -3,7 +3,7 @@
# Copyright Ben de Groot <yngwin@gentoo.org>
# LICENSE - GPL2
-import package_module,time,clioptions_module,gnome_module,os,cgi
+import package_module, time, clioptions_module, gnome_module, os, cgi
class Output:
@@ -12,25 +12,25 @@ class Output:
if to_calculate:
self.calculate_stats()
-
+
def calculate_stats(self):
# variables to hold for stats
- total_packs = len(self.packages)
+ total_packs = len(self.packages)
self.update_needed = float(0)
self.compliant = float(0)
self.not_found = float(0)
self.newer = float(0)
-
+
for package in self.packages:
if package.status == package_module.Status.Compliant:
- self.compliant +=1
+ self.compliant += 1
elif package.status == package_module.Status.NewerVersion:
- self.newer +=1
+ self.newer += 1
elif package.status == package_module.Status.NotFound:
- self.not_found +=1
+ self.not_found += 1
elif package.status == package_module.Status.NeedUpdate:
- self.update_needed +=1
-
+ self.update_needed += 1
+
try:
self.update_percent = float(self.update_needed / total_packs) * 100
except ZeroDivisionError:
@@ -47,17 +47,17 @@ class Output:
self.total_percent = float( (self.update_needed + self.not_found ) / total_packs ) * 100
except ZeroDivisionError:
self.total_percent = 0
-
+
def generate_html(self):
-
+
# now we have all the results in the results list.
# just time to generate some kind of "useful" output.
# for now, lets just make a html file. ( using html5 and css )
# name, portage_version, gnome_version, status <-- is whats in the PackageUpdate object
current_time = str(time.asctime(time.localtime()))
-
+
lines = []
-
+
# header
lines.append('<!DOCTYPE html>')
lines.append("<html>")
@@ -76,12 +76,12 @@ class Output:
lines.append("<p>Packages that need to be updated: " + str('%0.2f' % self.update_percent)+ "%" + " Number = " + str(self.update_needed) + "</p>")
lines.append("<p>New Packages that need to be added: " + str('%0.2f' % self.notfound_percent)+ "%" + " Number = " + str(self.not_found) + "</p>")
lines.append("</div>")
-
+
lines.append('<table>')
lines.append('<tr>')
lines.append('<th class="pn">Package Name</th><th>Stable</th><th>Testing</th><th>Official</th><th>Latest</th>')
lines.append('</tr>')
-
+
# data
for package in self.packages:
if package.status == package_module.Status.NeedUpdate:
@@ -94,24 +94,24 @@ class Output:
lines.append('<tr class="notfound">') # "grey"
elif package.status == package_module.Status.NewerVersion:
lines.append('<tr class="newerversion">') # "yellow"
-
+
lines.append('<td class="pn">' + str(package.name) + "</td>")
lines.append('<td>' + str(package.stable_version) + "</td>")
lines.append("<td>" + str(package.portage_version) + "</td>")
lines.append("<td>" + str(package.gnome_version) + "</td>")
lines.append("<td>" + str(package.latest_version) + "</td>")
-
+
lines.append("</tr>")
-
+
lines.append("</table>")
-
+
# footer
lines.append("<p>Official Version: Latest stable Xorg released individual packages.</p>")
lines.append("<p>Latest Version: Latest available Xorg released individual packages, including the snapshots.</p>")
lines.append("</body></html>")
-
+
self.write_file(lines, clioptions_module.Options().get_arguments().output)
-
+
print "Generated html output."
def generate_keywords(self):
diff --git a/x-modular-bumpchecker.py b/x-modular-bumpchecker.py
index ab8cd86..3c39510 100755
--- a/x-modular-bumpchecker.py
+++ b/x-modular-bumpchecker.py
@@ -5,14 +5,14 @@
# Copyright Tomas Chvatal <scarabeus@gentoo.org>
# LICENSE - GPL2
-import os,sys
+import os, sys
sys.path.append(os.path.sep.join([os.path.dirname(sys.argv[0]), 'modules']))
version = "0.0.1"
if __name__ == '__main__':
-
+
import clioptions_module
options = clioptions_module.Options()
@@ -32,7 +32,7 @@ if __name__ == '__main__':
options.get_arguments().portdir, \
options.get_arguments().all_overlays, \
options.get_arguments().overlays)
-
+
stable_packages_in_portage = \
portage_module.find_packages_in_tree(release_packages, \
options.get_arguments().portdir, \