-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomate.py
More file actions
27 lines (23 loc) · 992 Bytes
/
Copy pathautomate.py
File metadata and controls
27 lines (23 loc) · 992 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
import subprocess
import shutil
# Run the Python script and capture its output
python_script = "script_2.py"
result = subprocess.run(["python", python_script], capture_output=True, text=True)
# Check if the Python script ran successfully
if result.returncode == 0:
# Extract the output from the result
python_output = result.stdout
# Write the Python output to a TypeScript file in the desired format
ts_file_path = "eventData.ts"
with open(ts_file_path, "w") as ts_file:
ts_file.write("const events = \n")
ts_file.write(python_output)
ts_file.write(";\n\n")
ts_file.write("export default events;\n")
# Define the destination directory to move the file to
destination_directory = "/data/eventData.ts"
# Move the file to the specified directory
shutil.move(ts_file_path, destination_directory)
print(f"Output file moved to {destination_directory}/eventData.ts")
else:
print("Error running the Python script.")