-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfind-waiting-packages-for-ack
executable file
·151 lines (101 loc) · 4.61 KB
/
find-waiting-packages-for-ack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import urllib
import piksemel
import lzma
import bz2
import locale
locale.setlocale(locale.LC_ALL, "tr_TR.UTF-8")
repoOf = {
'2009' : ('http://packages.pardus.org.tr/pardus-2009/pisi-index.xml.bz2', 'http://packages.pardus.org.tr/pardus-2009-test/pisi-index.xml.bz2', 'bzip2' ),
'2011' : ('http://packages.pardus.org.tr/pardus/2011/stable/x86_64/pisi-index.xml.xz', 'http://packages.pardus.org.tr/pardus/2011/testing/x86_64/pisi-index.xml.xz', 'xz' ),
'kurumsal2' : ('http://packages.pardus.org.tr/pardus/kurumsal2/stable/x86_64/pisi-index.xml.xz', 'http://packages.pardus.org.tr/pardus/kurumsal2/testing/x86_64/pisi-index.xml.xz', 'xz'),
}
usage = " %s PardusRelease\n Finds packages that waiting for ACK in PardusRelease (which is one of %s)" % (sys.argv[0], ', '.join(sorted(repoOf.keys())))
def fail(message):
print message
sys.exit(1)
def readFileFrom(_url):
try:
return urllib.urlopen( _url )
except IOError:
fail("could not connect %s" % _url)
def getDocument( _url ):
rawdata = readFileFrom( _url )
filetype = _url.split(".")[-1]
if filetype == "xz":
data = lzma.decompress( rawdata.read() )
elif filetype == "bz2":
data = bz2.decompress( rawdata.read() )
else:
fail("not support filetype %s for decompress" % filetype)
return piksemel.parseString(data)
class PendingPackages():
packagerList = []
listofPackagesByOwned = {}
listofPackagesByModified = {}
def addModifiedPackage(self, packageURI, package_owner, updateBy):
if package_owner not in self.packagerList:
self.packagerList.append(package_owner)
if updateBy not in self.packagerList:
self.packagerList.append( updateBy )
self.listofPackagesByOwned.setdefault( package_owner, []).append( packageURI )
if package_owner != updateBy:
data = ( packageURI, package_owner )
self.listofPackagesByModified.setdefault(updateBy, []).append( data )
def printKnowledgePendingPackages(self):
print "LISTOFPACKAGESWAITINGFORACK"
print "=========================="
self.packagerList.sort(cmp=locale.strcoll)
for packager in self.packagerList:
print "\n%s" % packager
if packager in self.listofPackagesByOwned:
self.listofPackagesByOwned[packager].sort()
packages = self.listofPackagesByOwned[packager]
for package in packages:
print " %s" % package
if packager in self.listofPackagesByModified:
self.listofPackagesByModified[packager].sort()
packages = self.listofPackagesByModified[packager]
for package, packager in packages:
print " %s (%s)" % (package , packager)
if __name__ == "__main__":
print
if len(sys.argv) > 1 :
which_release = sys.argv[1]
else:
fail(usage)
if which_release in repoOf.keys():
repos = repoOf.get( which_release )
stable_repo_url = repos[0]
test_repo_url = repos[1]
else:
fail("Could not find release %s\nknown releases are: \n %s " % (which_release, ", ".join(repoOf.keys())))
pendingPackages = PendingPackages()
'''get packageList of stable repo'''
listofStablePackages = {}
doc = getDocument( stable_repo_url )
packages_elements = doc.tags( "Package" )
for package in packages_elements:
package_name = package.getTagData('Name')
# stableRepoPackageLastUpdataRelease = package.getTag("History").tags("Update").next().getAttribute("release")
# listofStablePackages[ package_name ] = stableRepoPackageLastUpdataRelease
packageURI = package.getTagData("PackageURI")
listofStablePackages[ package_name ] = packageURI
'''compare with test repo'''
doc = getDocument( test_repo_url )
package_elements = doc.tags( "Package" )
for package in package_elements:
dont_add = False
package_name = package.getTagData('Name')
packageURI = package.getTagData("PackageURI")
try:
dont_add = (listofStablePackages[ package_name ] == packageURI)
except KeyError:
pass
if not dont_add:
package_owner = package.getTag("Source").getTag("Packager").getTagData("Name")
updateBy = package.getTag("History").tags("Update").next().getTagData('Name')
pendingPackages.addModifiedPackage( packageURI, package_owner, updateBy )
pendingPackages.printKnowledgePendingPackages()