mirror of
https://github.com/netbox-community/Device-Type-Library-Import.git
synced 2024-11-25 00:53:12 +01:00
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:
parent
4fca4a7fb4
commit
8832370aba
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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(",")))
|
||||
|
Loading…
Reference in New Issue
Block a user