File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 3
3
import configparser
4
4
import netbox_connection
5
5
6
+ # Get the directory of the current script
7
+ script_dir = os .path .dirname (os .path .abspath (__file__ ))
8
+
6
9
def get_ipam_prefixes (netbox ):
7
10
"""
8
11
Retrieve all IPAM prefixes from Netbox.
@@ -24,7 +27,6 @@ def write_to_csv(data, filename):
24
27
- data (pynetbox.core.query.Request): IPAM prefixes data retrieved from Netbox.
25
28
- filename (str): Name of the CSV file to write data to.
26
29
"""
27
- script_dir = os .path .dirname (os .path .realpath (__file__ )) # Get the directory of the running script
28
30
file_path = os .path .join (script_dir , filename ) # Construct the full path to the output file
29
31
with open (file_path , 'w' , newline = '' ) as file :
30
32
writer = csv .writer (file )
@@ -38,7 +40,7 @@ def write_to_csv(data, filename):
38
40
39
41
# Read URL and token from var.ini
40
42
config = configparser .ConfigParser ()
41
- config .read ('var.ini' )
43
+ config .read (os . path . join ( script_dir , 'var.ini' ) )
42
44
url = config ['credentials' ]['url' ]
43
45
token = config ['credentials' ]['token' ]
44
46
You can’t perform that action at this time.
0 commit comments