Skip to content

Commit

Permalink
Support SNAP_REAL_HOME
Browse files Browse the repository at this point in the history
Otherwise the config file can not be found when running the snap.
  • Loading branch information
toabctl committed Jul 21, 2023
1 parent 62ab153 commit 7e08041
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jenviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ def _get_profile(args):


def _parser():
# snaps do set $HOME to something like
# /home/$USER/snap/jenkins-tool/$SNAP_VERSION
# the real home (usually /home/$USERNAME) is stored in $SNAP_REAL_HOME
# see https://snapcraft.io/docs/environment-variables
SNAP_REAL_HOME = os.getenv('SNAP_REAL_HOME')
if SNAP_REAL_HOME:
conf_default = os.path.join(os.path.join(SNAP_REAL_HOME, '.config', 'jenviz.ini'))
else:
conf_default = os.path.join(os.path.expanduser('~'), '.config', 'jenviz.ini')

parser = argparse.ArgumentParser(
description='Visualize Jenkins jobs')
jenkins_group = parser.add_argument_group(title='Jenkins')
jenkins_group.add_argument('--jenviz-config-file', '-c',
default=os.path.join(os.path.expanduser('~'), '.config', 'jenviz.ini'),
default=conf_default,
help='Path to the jenviz configuration file. Default: %(default)s')
jenkins_group.add_argument('--jenviz-config-profile', '-p',
help='The profile (section) to use in the jenviz-config-file')
Expand Down

0 comments on commit 7e08041

Please sign in to comment.