blob: 669b3ef98a20d2b4144da67299c463f73ee46851 (
plain)
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
|
#!/usr/bin/env python3
# © Copyright 2021-2022, Scott Gasch
"""Miscellaneous utilities."""
import os
import sys
def is_running_as_root() -> bool:
"""Returns True if running as root.
>>> is_running_as_root()
False
"""
return os.geteuid() == 0
def debugger_is_attached() -> bool:
"""Return if the debugger is attached"""
gettrace = getattr(sys, 'gettrace', lambda: None)
return gettrace() is not None
if __name__ == '__main__':
import doctest
doctest.testmod()
|