Skip to content

Commit 8832370

Browse files
p-rintzdanner26
andauthored
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 <[email protected]>
1 parent 4fca4a7 commit 8832370

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

gitcmd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, args, repo_path):
1111
self.url = args.url
1212
self.repo_path = repo_path
1313
self.branch = args.branch
14-
self.repo = Repo()
14+
# self.repo = Repo()
1515
self.cwd = os.getcwd()
1616

1717
if os.path.isdir(self.repo_path):
@@ -43,4 +43,3 @@ def clone_repo(self):
4343
settings.handle.exception("GitCommandError", self.url, git_error)
4444
except Exception as git_error:
4545
settings.handle.exception("Exception", 'Git Repository Error', git_error)
46-

nb-dt-import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def getFiles(vendors=None):
5353

5454
files = []
5555
discoveredVendors = []
56-
base_path = './repo/device-types/'
56+
base_path = f'{settings.REPO_PATH}/device-types/'
5757
if vendors:
5858
for r, d, f in os.walk(base_path):
5959
for folder in d:
@@ -88,7 +88,7 @@ def get_files_modules(vendors=None):
8888

8989
files = []
9090
discoveredVendors = []
91-
base_path = './repo/module-types/'
91+
base_path = f'{settings.REPO_PATH}/module-types/'
9292
if vendors:
9393
for r, d, f in os.walk(base_path):
9494
for folder in d:

settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
NETBOX_URL = os.getenv("NETBOX_URL")
1313
NETBOX_TOKEN = os.getenv("NETBOX_TOKEN")
1414
IGNORE_SSL_ERRORS = (os.getenv("IGNORE_SSL_ERRORS", default="False") == "True")
15-
REPO_PATH = "./repo"
15+
REPO_PATH = f"{os.path.dirname(os.path.realpath(__file__))}/repo"
1616

1717
# optionally load vendors through a comma separated list as env var
1818
VENDORS = list(filter(None, os.getenv("VENDORS", "").split(",")))

0 commit comments

Comments
 (0)