Skip to content

Commit

Permalink
improve how we find the run folder
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Oct 6, 2023
1 parent 9984468 commit c5683cb
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/exabgp/environment/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import os
import sys

APPLICATION = 'exabgp'
def _find_root():
root = os.environ.get('EXABGP_ROOT', '')

if not root:
root = os.path.normpath(os.path.dirname(sys.argv[0]))

if root.endswith('/bin') or root.endswith('/sbin'):
root = os.path.normpath(os.path.join(root, '..'))

_index = root.find('src/exabgp/application')
if _index:
root = root[:_index]
if root.endswith('/'):
root = root[:-1]

return root

ROOT = os.environ.get('EXABGP_ROOT', '')
if not ROOT:
ROOT = os.path.normpath(os.path.dirname(sys.argv[0]))
if ROOT.endswith('/bin') or ROOT.endswith('/sbin'):
ROOT = os.path.normpath(os.path.join(ROOT, '..'))

APPLICATION = 'exabgp'
ROOT = _find_root()
ETC = os.path.join(ROOT, 'etc', APPLICATION)
ENVFILE = os.path.join(ETC, f'{APPLICATION}.env')



0 comments on commit c5683cb

Please sign in to comment.