Last active
June 18, 2016 16:47
-
-
Save techtonik/47e97b236558ba24e6faf93f3ae746fa to your computer and use it in GitHub Desktop.
cross-platform package info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 <[email protected]>' | |
__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