-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpython.py
More file actions
43 lines (27 loc) · 820 Bytes
/
python.py
File metadata and controls
43 lines (27 loc) · 820 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# import matplotlib.pyplot as plt
import triangle as tr
import networkx as nx
import os, json, sys
import pickle
from pathlib import Path
### DATA INPUT
# run locally
if len(sys.argv) < 2:
# hard code data path
script_path = os.path.realpath(__file__).split("\\")
data_path = "\\".join(script_path[:-1] + ["_temp", "script_inputs.d"])
# run from outside with args
else:
# load data path from args
data_path = sys.argv[-1]
with open(data_path, 'rb') as f:
data_in = pickle.load(f, encoding='latin1')
### PROCESS
data_out = "Data received: {}".format(data_in)
### DATA OUTPUT
output_path = "\\".join(data_path.split("\\")[:-1] + ["script_output.d"])
with open(output_path, 'wb') as f:
pickle.dump(data_out, f, protocol=2)
print("Done with output:")
# must be last print statement
print(output_path)