Skip to content

Instantly share code, notes, and snippets.

@fdelbos
Created March 23, 2012 21:21
Show Gist options
  • Save fdelbos/2175177 to your computer and use it in GitHub Desktop.
Save fdelbos/2175177 to your computer and use it in GitHub Desktop.
display information on each package on freebsd
#!/usr/local/bin/python
import os, sys, commands
def print_package(name):
rows, columns = os.popen('stty size', 'r').read().split()
for i in range (int(columns)):
sys.stdout.write('_')
print '\n'
print '\033[1;32m' + name + '\033[1;m'
print '\n'
status, output = commands.getstatusoutput('pkg_info ' + name)
print output
status, output = commands.getstatusoutput('pkg_info -o ' + name)
print '\033[1;33m' + output + '\033[1;m'
status, output = commands.getstatusoutput('pkg_info -rR ' + name)
print '\033[1;31m' + output + '\033[1;m'
status, output = commands.getstatusoutput('pkg_info')
lines = output.split('\n')
for line in lines:
pkg = line.split(' ')[0]
print_package(pkg)
var = raw_input("press enter for next: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment