Skip to content

Commit

Permalink
[refactor] improve exception management
Browse files Browse the repository at this point in the history
  • Loading branch information
4383 committed Dec 6, 2017
1 parent f6682dc commit d1ff09d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 54 deletions.
35 changes: 17 additions & 18 deletions run_curator.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/usr/bin/env python

"""Wrapper for running curator from source."""

from curator.cli import cli

if __name__ == '__main__':
try:
cli()
except Exception as e:
if type(e) == type(RuntimeError()):
if 'ASCII' in str(e):
print('{0}'.format(e))
print(
'''
"""
Wrapper for running curator from source.
When used with Python 3 (and the DEB and RPM packages of Curator are compiled
and bundled with Python 3), Curator requires the locale to be unicode. Any of
Expand All @@ -29,9 +18,19 @@
Be sure to substitute your unicode variant for en_US.utf8
'''
)
else:
import sys
"""

from curator.cli import cli


if __name__ == '__main__':
try:
cli()
except RuntimeError as e:
import sys
print('{0}'.format(e))
sys.exit(1)
except Exception as e:
if 'ASCII' in str(e):
print('{0}'.format(e))
sys.exit(1)
print(__doc__)
35 changes: 17 additions & 18 deletions run_es_repo_mgr.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/usr/bin/env python

"""Wrapper for running es_repo_mgr from source."""

from curator.repomgrcli import repo_mgr_cli

if __name__ == '__main__':
try:
repo_mgr_cli()
except Exception as e:
if type(e) == type(RuntimeError()):
if 'ASCII' in str(e):
print('{0}'.format(e))
print(
'''
"""
Wrapper for running es_repo_mgr from source.
When used with Python 3 (and the DEB and RPM packages of Curator are compiled
and bundled with Python 3), Curator requires the locale to be unicode. Any of
Expand All @@ -29,9 +18,19 @@
Be sure to substitute your unicode variant for en_US.utf8
'''
)
else:
import sys
"""

from curator.repomgrcli import repo_mgr_cli


if __name__ == '__main__':
try:
repo_mgr_cli()
except RuntimeError as e:
import sys
print('{0}'.format(e))
sys.exit(1)
except Exception as e:
if 'ASCII' in str(e):
print('{0}'.format(e))
sys.exit(1)
print(__doc__)
35 changes: 17 additions & 18 deletions run_singleton.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
#!/usr/bin/env python

"""Wrapper for running singletons from source."""
import click
from curator.singletons import cli

if __name__ == '__main__':
try:
cli(obj={})
except Exception as e:
if type(e) == type(RuntimeError()):
if 'ASCII' in str(e):
print('{0}'.format(e))
print(
'''
"""
Wrapper for running singletons from source.
When used with Python 3 (and the DEB and RPM packages of Curator are compiled
and bundled with Python 3), Curator requires the locale to be unicode. Any of
Expand All @@ -29,9 +18,19 @@
Be sure to substitute your unicode variant for en_US.utf8
'''
)
else:
import sys
"""

import click
from curator.singletons import cli

if __name__ == '__main__':
try:
cli(obj={})
except RuntimeError as e:
import sys
print('{0}'.format(e))
sys.exit(1)
except Exception as e:
if 'ASCII' in str(e):
print('{0}'.format(e))
sys.exit(1)
print(__doc__)

0 comments on commit d1ff09d

Please sign in to comment.