Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with some issues. #2

Merged
merged 3 commits into from
Jul 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions bugwarrior/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
)

import logging
logging.basicConfig()
log = logging.getLogger(__name__)


Expand All @@ -30,6 +29,19 @@ def _get_section_name(flavor):
return 'general'


def _try_load_config(main_section, interactive):
try:
return load_config(main_section, interactive)
except IOError:
# Our standard logging configuration depends on the bugwarrior
# configuration file which just failed to load.
logging.basicConfig()

log.critical("Could not load configuration. "
"Maybe you have not created a configuration file.")
sys.exit(1)


@click.command()
@click.option('--dry-run', is_flag=True)
@click.option('--flavor', default=None, help='The flavor to use')
Expand All @@ -44,14 +56,7 @@ def pull(dry_run, flavor, interactive, debug):

try:
main_section = _get_section_name(flavor)

# Load our config file
try:
config = load_config(main_section, interactive)
except IOError:
log.critical("Could not load configuration. "
"Maybe you have not created a configuration file.")
sys.exit(1)
config = _try_load_config(main_section, interactive)

lockfile_path = os.path.join(get_data_path(), 'bugwarrior.lockfile')
lockfile = PIDLockFile(lockfile_path)
Expand All @@ -74,10 +79,6 @@ def pull(dry_run, flavor, interactive, debug):
)
except RuntimeError as e:
log.critical("Aborted (%s)" % e)
except SystemExit as e:
sys.exit(e.code)
except:
log.exception('oh noes')


@click.group()
Expand Down Expand Up @@ -145,12 +146,7 @@ def set(target, username):
@click.option('--flavor', default=None, help='The flavor to use')
def uda(flavor):
main_section = _get_section_name(flavor)
try:
conf = load_config(main_section)
except IOError:
log.critical("Could not load configuration. "
"Maybe you have not created a configuration file.")
sys.exit(1)
conf = _try_load_config(main_section)
print "# Bugwarrior UDAs"
for uda in get_defined_udas_as_strings(conf, main_section):
print uda
Expand Down