Skip to content

Commit

Permalink
Simplify install_package API
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmatthews committed Feb 10, 2017
1 parent c464773 commit dd83ee1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
15 changes: 7 additions & 8 deletions COT/helpers/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ def __init__(self):
version_args=['--version'],
version_regexp=r"Homebrew ([0-9.]+)")

def install_package(self, # pylint: disable=arguments-differ
package,
opts=None):
def install_package(self, package):
"""Install the requested package if needed.
Args:
package (str): Name of the package to install.
opts (list): Additional parameters to append to the command.
package (str,list): Name of the package to install or list of
parameters needed to install the package.
"""
# Brew automatically updates when called so no need for us to do it.
cmd = ['install', package]
if opts:
cmd += opts
if isinstance(package, list):
cmd = ['install'] + package
else:
cmd = ['install', package]
self.call(cmd, capture_output=False)
5 changes: 5 additions & 0 deletions COT/helpers/fatdisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def __init__(self):
info_uri="http://github.com/goblinhack/fatdisk",
version_regexp="version ([0-9.]+)")

_provider_package = {
'brew': ['glennmatthews/fatdisk/fatdisk', '--devel'],
'port': 'fatdisk',
}

@property
def installable(self):
"""Whether COT is capable of installing this program on this system."""
Expand Down
7 changes: 3 additions & 4 deletions COT/helpers/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,12 @@ def cp(src, dest):
class PackageManager(Helper):
"""Helper program with additional API method install_package()."""

def install_package(self, package, *args, **kwargs):
def install_package(self, package):
"""Install the requested package if needed.
Args:
package (str): Name of the package to install.
*args (list): Subclasses may accept additional positional args.
**kwargs (dict): Subclasses may accept additional keyword args.
package (str,list): Name of the package to install or list of
parameters needed to install the package.
"""
raise NotImplementedError("install_package not implemented!")

Expand Down
5 changes: 5 additions & 0 deletions COT/helpers/vmdktool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class VMDKTool(Helper):
http://www.freshports.org/sysutils/vmdktool/
"""

_provider_package = {
'brew': 'vmdktool',
'port': 'vmdktool',
}

def __init__(self):
"""Initializer."""
super(VMDKTool, self).__init__(
Expand Down

0 comments on commit dd83ee1

Please sign in to comment.