forked from beilinli/cellblender-browser-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
43 lines (35 loc) · 1.04 KB
/
__init__.py
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 os
import sys
import subprocess
import shutil
import atexit
import signal
def find_in_path(program_name):
for path in os.environ.get('PATH', '').split(os.pathsep):
full_name = os.path.join(path, program_name)
if os.path.exists(full_name) and not os.path.isdir(full_name):
return full_name
return None
def get_name():
return ("Browser Plotter")
def requirements_met():
return True
def plot(data_path, plot_spec):
program_path = os.path.dirname(__file__)
python_cmd = find_in_path("python3")
#python_cmd = shutil.which("python3", mode=os.X_OK)
if python_cmd is None:
print("Unable to plot: python not found in path")
else:
plot_cmd = []
plot_cmd.append(python_cmd)
plot_cmd.append(os.path.join(program_path, "server.py"))
print(data_path)
plot_cmd.append(data_path)
for spec in plot_spec.split():
plot_cmd.append(spec)
print ("Plotting with: \"" + ' '.join(plot_cmd) + "\"")
server_proc = subprocess.Popen(plot_cmd, cwd = program_path)
atexit.register(shut_down, server_proc)
def shut_down(proc):
proc.kill()