Skip to content

Commit

Permalink
Work around the OS X security cli setting the return code to 1 if no …
Browse files Browse the repository at this point in the history
…trust settings are available to dump
  • Loading branch information
wbond committed Mar 19, 2015
1 parent ff91a73 commit d3bc04f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
5 changes: 4 additions & 1 deletion package_control/ca_certs.py
Expand Up @@ -346,7 +346,10 @@ def _osx_get_distrusted_certs(settings):
"""

args = ['/usr/bin/security', 'dump-trust-settings', '-d']
result = Cli(None, settings.get('debug')).execute(args, '/usr/bin')
result = Cli(None, settings.get('debug')).execute(args, '/usr/bin', ignore_errors='No Trust Settings were found')

if not result:
return []

distrusted_certs = []
cert_name = None
Expand Down
30 changes: 17 additions & 13 deletions package_control/cmd.py
Expand Up @@ -75,7 +75,7 @@ def __init__(self, binary_locations, debug):
self.binary_locations = binary_locations
self.debug = debug

def execute(self, args, cwd, input=None, encoding='utf-8', meaningful_output=False):
def execute(self, args, cwd, input=None, encoding='utf-8', meaningful_output=False, ignore_errors=None):
"""
Creates a subprocess with the executable/args
Expand All @@ -92,6 +92,9 @@ def execute(self, args, cwd, input=None, encoding='utf-8', meaningful_output=Fal
If the output from the command is possibly meaningful and should
be displayed if in debug mode
:param ignore_errors:
A regex of errors to ignore
:return: A string of the executable output
"""

Expand Down Expand Up @@ -164,18 +167,19 @@ def kill_proc():
output = output.replace('\r\n', '\n').rstrip(' \n\r')

if proc.returncode != 0:
show_error(
u'''
Error executing: %s
%s
VCS-based packages can be ignored with the
"ignore_vcs_packages" setting.
''',
(create_cmd(args), output)
)
return False
if not ignore_errors or re.search(ignore_errors, output) is None:
show_error(
u'''
Error executing: %s
%s
VCS-based packages can be ignored with the
"ignore_vcs_packages" setting.
''',
(create_cmd(args), output)
)
return False

if meaningful_output and self.debug and len(output) > 0:
console_write(output, indent=' ', prefix=False)
Expand Down

0 comments on commit d3bc04f

Please sign in to comment.