Skip to content

Commit 2fd80df

Browse files
committed
FIX lintering
1 parent 38aab63 commit 2fd80df

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

src/gh/components/DF_http_listener/code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ def _import_job(url):
6565
sc.sticky['status_message'] = f"Done: {count} points"
6666
else:
6767
sc.sticky['status_message'] = f"Done: {count} vertices"
68-
ghenv.Component.Message = sc.sticky.get('status_message')
68+
ghenv.Component.Message = sc.sticky.get('status_message') # noqa: F821
6969

7070
except Exception as e:
7171
sc.sticky['imported_geom'] = None
7272
sc.sticky['status_message'] = f"Error: {e}"
7373
finally:
7474
try:
7575
os.remove(tmp)
76-
except:
76+
except Exception:
7777
pass
7878
sc.sticky['thread_running'] = False
79-
ghenv.Component.ExpireSolution(True)
79+
ghenv.Component.ExpireSolution(True) # noqa: F821
8080

8181
if sc.sticky['ply_url'] != i_ply_url:
8282
sc.sticky['ply_url'] = i_ply_url
@@ -90,7 +90,7 @@ def _import_job(url):
9090
threading.Thread(target=_import_job, args=(i_ply_url,), daemon=True).start()
9191

9292
sc.sticky['prev_load'] = i_load
93-
ghenv.Component.Message = sc.sticky.get('status_message', "")
93+
ghenv.Component.Message = sc.sticky.get('status_message', "") # noqa: F821
9494

9595
# output
9696
o_geometry = sc.sticky.get('imported_geom')

src/gh/components/DF_tcp_listener/code.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ def RunScript(self, i_load: bool, i_reset: bool, i_port: int, i_host: str):
2525
# close old socket if any
2626
old = sc.sticky.get('server_sock')
2727
try:
28-
if old: old.close()
29-
except: pass
28+
if old:
29+
old.close()
30+
except Exception:
31+
pass
3032

3133
sc.sticky['listen_addr'] = addr
3234
sc.sticky['server_sock'] = None
3335
sc.sticky['server_started'] = False
3436
sc.sticky['cloud_buffer_raw'] = []
3537
sc.sticky['latest_cloud'] = None
3638
sc.sticky['status_message'] = "Reset" if i_reset else f"Addr → {i_host}:{i_port}"
37-
ghenv.Component.Message = sc.sticky['status_message']
39+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
3840

3941
# Client handler
4042
def handle_client(conn):
@@ -52,29 +54,29 @@ def handle_client(conn):
5254
raw = json.loads(line.decode())
5355
except Exception as e:
5456
sc.sticky['status_message'] = f"JSON error: {e}"
55-
ghenv.Component.Message = sc.sticky['status_message']
57+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
5658
continue
5759

5860
if isinstance(raw, list) and all(isinstance(pt, list) and len(pt)==6 for pt in raw):
5961
sc.sticky['cloud_buffer_raw'] = raw
6062
sc.sticky['status_message'] = f"Buffered {len(raw)} pts"
6163
else:
6264
sc.sticky['status_message'] = "Unexpected format"
63-
ghenv.Component.Message = sc.sticky['status_message']
65+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
6466
except Exception as e:
6567
sc.sticky['status_message'] = f"Socket error: {e}"
66-
ghenv.Component.Message = sc.sticky['status_message']
68+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
6769
break
6870

6971
def accept_loop(srv_sock):
7072
while True:
7173
try:
7274
conn, _ = srv_sock.accept()
7375
threading.Thread(target=handle_client, args=(conn,), daemon=True).start()
74-
except:
76+
except Exception:
7577
break
7678

77-
#Start server
79+
# Start server
7880
def start_server():
7981
try:
8082
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -84,11 +86,11 @@ def start_server():
8486
sc.sticky['server_sock'] = srv
8587
sc.sticky['server_started'] = True
8688
sc.sticky['status_message'] = f"Listening on {i_host}:{i_port}"
87-
ghenv.Component.Message = sc.sticky['status_message']
89+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
8890
threading.Thread(target=accept_loop, args=(srv,), daemon=True).start()
8991
except Exception as e:
9092
sc.sticky['status_message'] = f"Server error: {e}"
91-
ghenv.Component.Message = sc.sticky['status_message']
93+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
9294

9395
if not sc.sticky['server_started']:
9496
start_server()
@@ -104,8 +106,7 @@ def start_server():
104106
sc.sticky['status_message'] = f"Retrieved {pc.Count} pts"
105107
else:
106108
sc.sticky['status_message'] = "No data buffered"
107-
ghenv.Component.Message = sc.sticky['status_message']
108-
109+
ghenv.Component.Message = sc.sticky['status_message'] # noqa: F821
109110
sc.sticky['prev_load'] = i_load
110111

111112
return [sc.sticky['latest_cloud']]

src/gh/components/DF_websocket_listener/code.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def _import_job(url):
2727
if not url.lower().endswith('.ply'):
2828
raise ValueError("URL must end in .ply")
2929

30-
resp = requests.get(url, timeout=30); resp.raise_for_status()
30+
resp = requests.get(url, timeout=30)
31+
resp.raise_for_status()
3132
fn = os.path.basename(url)
3233
tmp = os.path.join(tempfile.gettempdir(), fn)
3334
with open(tmp, 'wb') as f:
@@ -61,32 +62,35 @@ def _import_job(url):
6162
sc.sticky['imported_geom'] = geom
6263
count = geom.Count if isinstance(geom, rg.PointCloud) else geom.Vertices.Count
6364
if isinstance(geom, rg.PointCloud):
64-
sc.sticky['status_message'] = f"Done: {count} points"
65-
else: sc.sticky['status_message'] = f"Done: {count} vertices"
66-
ghenv.Component.Message = sc.sticky.get('status_message')
65+
sc.sticky['status_message'] = f"Done: {count} points"
66+
else:
67+
sc.sticky['status_message'] = f"Done: {count} vertices"
68+
ghenv.Component.Message = sc.sticky.get('status_message') # noqa: F821
6769

6870
except Exception as e:
6971
sc.sticky['imported_geom'] = None
7072
sc.sticky['status_message'] = f"Error: {e}"
7173
finally:
72-
try: os.remove(tmp)
73-
except: pass
74+
try:
75+
os.remove(tmp)
76+
except Exception:
77+
pass
7478
sc.sticky['thread_running'] = False
75-
ghenv.Component.ExpireSolution(True)
79+
ghenv.Component.ExpireSolution(True) # noqa: F821
7680

7781
if sc.sticky['ply_url'] != i_ply_url:
7882
sc.sticky['ply_url'] = i_ply_url
7983
sc.sticky['status_message'] = "URL changed. Press Load"
8084
sc.sticky['thread_running'] = False
81-
sc.sticky['prev_load'] = False
85+
sc.sticky['prev_load'] = False
8286

8387
if i_load and not sc.sticky['prev_load'] and not sc.sticky['thread_running']:
8488
sc.sticky['status_message'] = "Loading..."
8589
sc.sticky['thread_running'] = True
8690
threading.Thread(target=_import_job, args=(i_ply_url,), daemon=True).start()
8791

8892
sc.sticky['prev_load'] = i_load
89-
ghenv.Component.Message = sc.sticky.get('status_message', "")
93+
ghenv.Component.Message = sc.sticky.get('status_message', "") # noqa: F821
9094

9195
# output
9296
o_geometry = sc.sticky.get('imported_geom')

0 commit comments

Comments
 (0)