Last active
December 20, 2015 22:49
-
-
Save Widdershin/6207931 to your computer and use it in GitHub Desktop.
A wrapper for Chocolatey's cinst, to allow searching. Usage: ci (search/package name)
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
""" | |
ci.py | |
A wrapper for Chocolatey's cinst, to allow searching. | |
Usage: ci (search/package name) | |
""" | |
import os | |
import sys | |
import urllib | |
from BeautifulSoup import BeautifulSoup | |
request = sys.argv[1] | |
URL = "http://chocolatey.org/packages?q={}".format | |
REGEX = r'.* cinst (.*)' | |
choc_page = urllib.urlopen(URL(request)) | |
soup = BeautifulSoup(choc_page.read()) | |
packages = soup.findAll('code') | |
if len(packages) > 0: | |
for package in packages: | |
result = package.text.split()[-1] | |
print result | |
if result.lower().strip() == request.lower().strip(): | |
print "Package found, running cinst." | |
os.system("cinst {}".format(request)) | |
else: | |
print "No packages found." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment