/[gentoo]/src/gwn/get_portage_stats.py
Gentoo

Contents of /src/gwn/get_portage_stats.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download) (as text)
Tue Nov 11 21:23:43 2014 UTC (3 years, 8 months ago) by hwoarang
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +1 -1 lines
File MIME type: text/x-python
get_portage_stats: s/portage/ Gentoo ebuild/ when talking about the Gentoo
packages

1 #!/usr/bin/env python
2 import os, time
3
4 endtime = time.gmtime(time.time())
5 datefor = time.strftime("%Y/%m", endtime)
6 dateimg = time.strftime("%Y-%m", endtime)
7
8 arch = [
9 'alpha',
10 'amd64',
11 'amd64-fbsd',
12 'arm',
13 'arm64',
14 'hppa',
15 'ia64',
16 'm68k',
17 'mips',
18 'ppc',
19 'ppc64',
20 's390',
21 'sh',
22 'sparc',
23 'sparc-fbsd',
24 'x86',
25 'x86-fbsd']
26
27 gen_stats = [
28 'architectures',
29 'categories',
30 'packages',
31 'ebuilds']
32
33 gen_stats_num = []
34
35 stable = []
36 testing = []
37 total = []
38 percent = []
39
40 svals = []
41 tvals = []
42 tot = []
43
44 # Get general portage stats
45 os.system("qcache -sCq | sed \"s:|::g\" > pkgstats.txt")
46
47 # read input files
48 with open("pkgstats.txt") as f:
49 for line in f:
50 line=line.split()
51 try:
52 col = line[0].strip()
53 except:
54 continue
55 if col in gen_stats:
56 gen_stats_num.append(str(line[1].strip()))
57 elif col in arch:
58 #print line[0] + ", " + line[1] + ", " + line[2] +", " + \
59 # line[3] + ", " + line[4]
60 stable.append(int(line[1]))
61 testing.append(int(line[2]))
62 total.append(int(line[3]))
63 percent.append(line[4])
64 f.close()
65 os.remove("pkgstats.txt")
66
67 print "<h1>Portage</h1>"
68 print "This section summarizes the current state of the Gentoo ebuild tree.\n"
69
70 print "[table th=\"0\"]"
71 print "Architectures, " + gen_stats_num[0]
72 print "Categories, " + gen_stats_num[1]
73 print "Packages, " + gen_stats_num[2]
74 print "Ebuilds, " + gen_stats_num[3]
75 print "[/table]\n"
76
77 print "[table]"
78 print "Architecture, Stable, Testing, Total, % of Packages"
79 for x in range(0, len(arch)):
80 print arch[x] + ", " + str(stable[x]) + ", " + \
81 str(testing[x]) + ", " + str(total[x]) + ", " + percent[x]
82 print "[/table]\n"
83
84 for i in range(0, len(arch)):
85 svals.append(round(stable[i] / 123.81, 2))
86 tvals.append(round(testing[i] / 123.81, 2))
87 tot.append(stable[i]+testing[i])
88
89 max_arch=max(tot)
90
91 string1 = ''
92 string2 = ''
93 for i in range(0, len(svals)):
94 string1 += str(svals[i])
95 string2 += str(tvals[i])
96 if i != len(svals) - 1:
97 string1 += ','
98 string2 += ','
99
100 print """<p style="text-align: center"><img class=" wp-image-216 aligncenter"
101 style="line-height: 24px" alt="gmn-portage-stats-%s"
102 src="http://blogs.gentoo.org/news/files/%s/gmn-portage-stats-%s.png"
103 width="800" height="350" /></p>
104 """ % (dateimg, datefor, dateimg)
105
106 print "\n== Chart URL == (save it as \"gmn-portage-stats-%s.png\")\n\n" %dateimg
107 base = 'http://chart.apis.google.com/chart?cht=bhs&chs=800x350&chd=t:'
108 tail = '&chco=45347B,6A5C95&chbh=15&chxt=x,y&chxr=0,0,%s&chdl=Stable|Testing' % (max_arch)
109 labx = '&chxl=0:1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|1000|'
110 laby = '1:'
111
112 for x in reversed(range(0, len(arch))):
113 laby = laby + "|" + arch[x]
114
115 final = base + string1 + '|' + string2 + tail + labx + laby
116 print final

  ViewVC Help
Powered by ViewVC 1.1.20