Remove Repo init from __init__ (#76)

* Remove Repo init from __init__

Initializing the repository from init, before the path has been updated, will lead to various errors when the script is not run directly from the repository.

* Implemented fix that will allow for running script from any directory

---------

Co-authored-by: Daniel W. Anner <daniel.anner@danstechsupport.com>
This commit is contained in:
Philipp Rintz 2023-03-08 19:30:18 +01:00 committed by GitHub
parent 4fca4a7fb4
commit 8832370aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -11,7 +11,7 @@ class GitCMD:
self.url = args.url
self.repo_path = repo_path
self.branch = args.branch
self.repo = Repo()
# self.repo = Repo()
self.cwd = os.getcwd()
if os.path.isdir(self.repo_path):
@ -43,4 +43,3 @@ class GitCMD:
settings.handle.exception("GitCommandError", self.url, git_error)
except Exception as git_error:
settings.handle.exception("Exception", 'Git Repository Error', git_error)

View File

@ -53,7 +53,7 @@ def getFiles(vendors=None):
files = []
discoveredVendors = []
base_path = './repo/device-types/'
base_path = f'{settings.REPO_PATH}/device-types/'
if vendors:
for r, d, f in os.walk(base_path):
for folder in d:
@ -88,7 +88,7 @@ def get_files_modules(vendors=None):
files = []
discoveredVendors = []
base_path = './repo/module-types/'
base_path = f'{settings.REPO_PATH}/module-types/'
if vendors:
for r, d, f in os.walk(base_path):
for folder in d:

View File

@ -12,7 +12,7 @@ REPO_BRANCH = os.getenv("REPO_BRANCH", default="master")
NETBOX_URL = os.getenv("NETBOX_URL")
NETBOX_TOKEN = os.getenv("NETBOX_TOKEN")
IGNORE_SSL_ERRORS = (os.getenv("IGNORE_SSL_ERRORS", default="False") == "True")
REPO_PATH = "./repo"
REPO_PATH = f"{os.path.dirname(os.path.realpath(__file__))}/repo"
# optionally load vendors through a comma separated list as env var
VENDORS = list(filter(None, os.getenv("VENDORS", "").split(",")))