Skip to content

Commit

Permalink
Merge pull request #487 from AndreMiras/feature/shorter_exception_cat…
Browse files Browse the repository at this point in the history
…ching

Uses contextlib.suppress to ignore exceptions
  • Loading branch information
AndreMiras authored May 6, 2020
2 parents efd47e6 + f082919 commit e287795
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions kivy_ios/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import fnmatch
import tempfile
import time
from contextlib import contextmanager
from contextlib import contextmanager, suppress
from datetime import datetime
from pprint import pformat
import logging
Expand Down Expand Up @@ -360,9 +360,6 @@ def __init__(self):

# path to some tools
self.ccache = sh.which("ccache")
if not self.ccache:
# ccache is missing, the build will not be optimized
pass
for cython_fn in ("cython-2.7", "cython"):
cython = sh.which(cython_fn)
if cython:
Expand Down Expand Up @@ -462,7 +459,7 @@ def report_hook(index, blksize, size):

if cwd:
filename = join(cwd, filename)
if exists(filename):
with suppress(FileNotFoundError):
unlink(filename)

# Clean up temporary files just in case before downloading.
Expand Down Expand Up @@ -578,10 +575,8 @@ def delete_marker(self, marker):
"""
Delete a specific marker
"""
try:
with suppress(FileNotFoundError):
unlink(join(self.build_dir, ".{}".format(marker)))
except Exception:
pass

def get_include_dir(self):
"""
Expand Down Expand Up @@ -1063,11 +1058,9 @@ def build_arch(self, arch):
build_env = self.get_recipe_env(arch)
hostpython = sh.Command(self.ctx.hostpython)
if self.pre_build_ext:
try:
with suppress(Exception):
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
except Exception:
pass
self.cythonize_build()
shprint(hostpython, "setup.py", "build_ext", "-g",
_env=build_env)
Expand Down Expand Up @@ -1302,13 +1295,10 @@ def recipes(self):
else:
ctx = Context()
for name in Recipe.list_recipes():
try:
with suppress(Exception):
recipe = Recipe.get_recipe(name, ctx)
print("{recipe.name:<12} {recipe.version:<8}".format(recipe=recipe))

except Exception:
pass

def clean(self):
parser = argparse.ArgumentParser(
description="Clean the build")
Expand Down

0 comments on commit e287795

Please sign in to comment.