diff options
Diffstat (limited to 'client_ls.py')
| -rwxr-xr-x[-rw-r--r--] | client_ls.py | 10 |
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 | ||
| 4 | import fcntl | 4 | import 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 | ||
| 21 | print(read_data()) | 25 | read_data() |
