Skip to content

Instantly share code, notes, and snippets.

@techtonik
Last active June 18, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techtonik/47e97b236558ba24e6faf93f3ae746fa to your computer and use it in GitHub Desktop.
Save techtonik/47e97b236558ba24e6faf93f3ae746fa to your computer and use it in GitHub Desktop.
cross-platform package info
"""
packaging for humans (tm)..
humans are easily overloaded with information, so
this should be the intuitive way to express and
solve what humans want.
001 get what package does
pk show <name>
pk info <name>
002 check what was updated
pk news <name>
"""
__author__ = 'anatoly techtonik <techtonik@gmail.com>'
__license__ = 'public domain'
import os
import sys
import subprocess
def run(command):
print('running: ' + command)
subprocess.Popen(command.split()).communicate()
if len(sys.argv) < 3:
sys.exit(__doc__.strip() + "\n")
command = sys.argv[1]
name = sys.argv[2]
if command not in ['info', 'show', 'news']:
sys.exit('error: unsupported command "%s"' % command)
if command == 'info':
command = 'show'
# Debian, Ubuntu, ...
if os.path.exists('/etc/debian_version'):
if command == 'show':
cmd = 'apt-cache show ' + name
elif command == 'news':
cmd = 'apt-get changelog ' + name
run(cmd)
else:
sys.exit('error: can\'t detect OS for running "%s"' % command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment