summaryrefslogtreecommitdiff
path: root/client_ls.py
diff options
context:
space:
mode:
authorhc <hc@email.ch>2025-02-01 11:07:07 +0800
committerhc <hc@email.ch>2025-02-01 11:07:07 +0800
commit8c1a40d00ca69f2194a9f7c4cf4e884a2d225d3d (patch)
tree2c880e936b465915ea6483fe2737a55b9638923b /client_ls.py
parent6e2bd1f5053f5244d1294ba5ae2c0ffc047743b6 (diff)
formatednicely
Diffstat (limited to 'client_ls.py')
-rwxr-xr-x[-rw-r--r--]client_ls.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/client_ls.py b/client_ls.py
index 6aa3a7e..fdcfc78 100644..100755
--- a/client_ls.py
+++ b/client_ls.py
@@ -1,4 +1,4 @@
1 1#!/usr/bin/env python3
2#lists client information 2#lists client information
3 3
4import fcntl 4import fcntl
@@ -12,10 +12,14 @@ def read_data():
12 # Get shared lock for reading 12 # Get shared lock for reading
13 fcntl.flock(f.fileno(), fcntl.LOCK_SH) 13 fcntl.flock(f.fileno(), fcntl.LOCK_SH)
14 try: 14 try:
15 return json.load(f) 15 data = json.load(f)
16 for pid, info in data.items():
17 print(info)
18 return {}
16 finally: 19 finally:
17 fcntl.flock(f.fileno(), fcntl.LOCK_UN) 20 fcntl.flock(f.fileno(), fcntl.LOCK_UN)
18 except (FileNotFoundError, ValueError): 21 except (FileNotFoundError, ValueError):
22 print("file /tmp/ssh_sessions.json not found")
19 return {} 23 return {}
20 24
21print(read_data()) 25read_data()