list of important (atau essential) packages APT dengan web2py

Atas bantuan, dan saran rekan kcin, kita bisa me-list dari essential package linux yang berbasis aptnya debian menggunakan web2py python framework

ini controllernya :

def important(): 
    apt_pkg.init()
    cache = apt_pkg.Cache()
    return dict(pkg=cache.packages)

dan viewnya :

{{extend 'layout.html'}}
<ul>
{{for t in pkg:}}{{if t.important:}}<li>{{=t.name}}</li>{{pass}}{{pass}}
</ul>

Atas masukan di milistnya juga, bisa juga diimplementasikan dengan

def important(): 
    apt_pkg.init()
    cache = apt_pkg.Cache()
    return dict(packages=[package.name for package in cache.packages if package.essential]) 

dan viewnya :

<ul> 
{{for package in packages:}} 
<li>{{=package}}</li> 
{{pass}} 
</ul>

atau dengan yang lebih mudah :

{{=UL(packages)}} 
Advertisements
Comments
2 Responses to “list of important (atau essential) packages APT dengan web2py”
  1. wh, gak ngerti bang, hehe, maaf nubie….. ntar kalo lagi di kanal minta ajarin yah….. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: