mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-22 15:14:24 -04:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a9b35c687 | ||
|
|
68d5118a9d |
No files matched your search
+11
-1
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""lcb.py FILE.jsonl — run control requests from a JSON-lines file ({"method":..., "params":...} or {"sleep": s})."""
|
||||
import json, socket, sys, time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _jsonl_path(arg):
|
||||
"""Resolve the CLI file argument; require an existing regular file."""
|
||||
path = Path(arg).resolve()
|
||||
if not path.is_file():
|
||||
sys.exit(f"not a readable file: {arg}")
|
||||
return path
|
||||
|
||||
def call(method, params):
|
||||
s = socket.create_connection(("127.0.0.1", 7980), timeout=180)
|
||||
s.sendall((json.dumps({"id": 1, "method": method, "params": params}) + "\n").encode())
|
||||
@@ -10,7 +20,7 @@ def call(method, params):
|
||||
if not c: break
|
||||
buf += c
|
||||
return json.loads(buf)
|
||||
for line in open(sys.argv[1]):
|
||||
for line in open(_jsonl_path(sys.argv[1])):
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"): continue
|
||||
r = json.loads(line)
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
sonar.projectKey=storytold_lightcraft
|
||||
sonar.organization=storytold
|
||||
sonar.coverage.exclusions=**/tools/**,**/docs/**,**/examples/**
|
||||
@@ -19,6 +19,23 @@ import sys
|
||||
import colour
|
||||
import numpy as np
|
||||
from scipy.optimize import minimize
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _existing_dir(arg):
|
||||
"""Resolve a directory CLI argument; require it to exist."""
|
||||
path = Path(arg).resolve()
|
||||
if not path.is_dir():
|
||||
sys.exit(f"not a directory: {arg}")
|
||||
return str(path)
|
||||
|
||||
|
||||
def _out_path(arg):
|
||||
"""Resolve an output path CLI argument; require its parent to exist."""
|
||||
path = Path(arg).resolve()
|
||||
if not path.parent.is_dir():
|
||||
sys.exit(f"output directory does not exist: {arg}")
|
||||
return str(path)
|
||||
|
||||
WL = np.arange(380, 781, 5)
|
||||
D50 = colour.xy_to_XYZ(colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D50"])
|
||||
@@ -119,4 +136,4 @@ def main(root, out):
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("usage: spectral_camera_table.py <rawtoaces-data checkout> <output .rs>")
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
main(_existing_dir(sys.argv[1]), _out_path(sys.argv[2]))
|
||||
Reference in new issue
Block a user