My favorites | Sign in
Project Home Issues Source
Checkout   Browse   Changes    
 
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/env python
import gtk
import cjson
import urllib
import commands
import posix

try:
from kiwi.ui.views import BaseView, SlaveView
from kiwi.ui.gadgets import quit_if_last
from kiwi.ui.objectlist import ObjectList, Column
except:
print "Please get kiwi package:"
print "pacman -S kiwi"

def is_root():
uid = posix.getuid()
return uid == 0

root = is_root()

class Local():
def __init__(self):
self.list = commands.getstatusoutput("pacman -Q")
self.list = self.list[1:]
self.list = self.list[0]
self.list = self.list.split('\n')
self.names = []
self.versions = []
for row in self.list:
item = row.split(' ')
self.names.append(item[0])
self.versions.append(item[1])

def check(self, package):
try:
index_number = self.names.index("%s" % package)
return self.versions[index_number]
except:
return ""


class CategoryItem():
def __init__(self, name):
self.name = name


class Category(SlaveView):

columns = [
Column("name", sorted=True)
]

def __init__(self):
listt = ObjectList(self.columns)
listt.connect('selection-changed', self.selected)

# selecting categories
f = urllib.urlopen("http://pacnet.karbownicki.com/api/categories/").read()
json=cjson.decode(f)
for category in json:
row = CategoryItem(category['fields']['name'])
listt.append(row)

SlaveView.__init__(self, listt)

def selected(self, the_list, item):
package.new_list(item.name)


class PackageItem():
def __init__(self, name, version, installed, description):
self.name, self.version, self.installed, self.description = name, version, installed, description


class Package(SlaveView):

columns = [
Column("name", sorted=True),
Column("version"),
Column("installed"),
Column("description")
]

def __init__(self):
self.list = ObjectList(self.columns)
self.list.connect('selection-changed', self.info)

self.to_install = ""

# selecting categories
f = urllib.urlopen("http://pacnet.karbownicki.com/api/category/app-accessibility/").read()
json=cjson.decode(f)
for category in json:
got = local.check(category['name'])
row = PackageItem(category['name'], category['version'], got, category['description'])
self.list.append(row)

SlaveView.__init__(self, self.list)


def info(self, the_list, item):
pkg_info = commands.getstatusoutput('pacman -Si %s' % item.name)[1]
shell.get_widget("info").get_buffer().set_text(pkg_info)
self.to_install = item.name

def new_list(self, category):
self.list.clear()
f = urllib.urlopen("http://pacnet.karbownicki.com/api/category/%s/" % category).read()
json=cjson.decode(f)
for category in json:
got = local.check(category['name'])
row = PackageItem(category['name'], category['version'], got, category['description'])
self.list.append(row)

class Install():

def __init__(self):
self.button = shell.get_widget("install")
self.button.add_events(gtk.gdk.BUTTON_PRESS_MASK)
self.button.connect('button_press_event', self.clicked)

def clicked(self, widget, event):
if package.to_install:
if root:
lol = commands.getstatusoutput('terminal -e "pacman -S %s && read"' % package.to_install)
else:
lol = commands.getstatusoutput("terminal -e \"su --command='pacman -S %s && read'\"" % package.to_install)
else:
print "brak pakietu do zainstalowania"


shell = BaseView(gladefile="gpacnet", delete_handler=quit_if_last)

local = Local()
category = Category()
package = Package()
install = Install()


shell.attach_slave("category", category)
shell.attach_slave("package", package)



category.show_all()
category.focus_topmost()
package.show_all()
package.focus_topmost()
shell.show()
gtk.main()

Change log

r6 by T.Karbownicki on Mar 18, 2011   Diff
UPDATE to new API version
Go to: 
Sign in to write a code review

Older revisions

r5 by T.Karbownicki on Apr 10, 2009   Diff
Change API URL-s
r4 by T.Karbownicki on Oct 19, 2008   Diff
- TextView in ScrolledWindow
- Information about package from
pacman -Si
r2 by T.Karbownicki on Oct 18, 2008   Diff
First files
All revisions of this file

File info

Size: 3696 bytes, 151 lines
Powered by Google Project Hosting