-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathaddEnvPath.py
More file actions
27 lines (24 loc) · 746 Bytes
/
addEnvPath.py
File metadata and controls
27 lines (24 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#Adds the virtual environment's executable path to json file
import json
import sys
import os.path
jsonPath = sys.argv[1]
key = sys.argv[2]
if os.path.isfile(jsonPath):
with open(jsonPath, 'r') as read_file:
data = json.load(read_file)
else:
directory = os.path.dirname(jsonPath)
if not os.path.exists(directory):
os.makedirs(directory)
with open(jsonPath, 'w+') as read_file:
data = {}
data = {}
with open(jsonPath, 'w') as outfile:
if key == 'condaExecPath':
data[key] = sys.argv[3]
else:
data[key] = sys.executable
json.dump(data, outfile, sort_keys=True, indent=4)