OXIESEC PANEL
- Current Dir:
/
/
snap
/
core24
/
888
/
usr
/
lib
/
python3
/
dist-packages
/
cloudinit
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
__init__.py
0 bytes
01/15/2025 03:24:11 PM
rw-r--r--
📁
__pycache__
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📁
analyze
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
apport.py
8.27 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
atomic_helper.py
2.79 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
cloud.py
3.71 KB
01/15/2025 03:24:11 PM
rw-r--r--
📁
cmd
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📁
config
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📁
distros
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
dmi.py
7.86 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
event.py
2 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
features.py
5.27 KB
02/04/2025 10:36:06 PM
rw-r--r--
📁
filters
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
gpg.py
7.99 KB
01/15/2025 03:24:11 PM
rw-r--r--
📁
handlers
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
helpers.py
16.16 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
importer.py
2.43 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
lifecycle.py
7.79 KB
01/15/2025 03:24:11 PM
rw-r--r--
📁
log
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📁
mergers
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📁
net
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
netinfo.py
24.02 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
performance.py
3.1 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
persistence.py
2.52 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
registry.py
1022 bytes
01/15/2025 03:24:11 PM
rw-r--r--
📁
reporting
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
safeyaml.py
10.11 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
settings.py
2.12 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
signal_handler.py
3.92 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
simpletable.py
1.93 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
socket.py
5.93 KB
01/15/2025 03:24:11 PM
rw-r--r--
📁
sources
-
03/18/2025 08:12:15 AM
rwxr-xr-x
📄
ssh_util.py
22.22 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
stages.py
41.53 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
subp.py
12.43 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
temp_utils.py
2.94 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
templater.py
7.8 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
type_utils.py
703 bytes
01/15/2025 03:24:11 PM
rw-r--r--
📄
url_helper.py
38.18 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
user_data.py
14.44 KB
01/15/2025 03:24:11 PM
rw-r--r--
📄
util.py
90.78 KB
02/04/2025 10:36:06 PM
rw-r--r--
📄
version.py
568 bytes
02/04/2025 10:36:06 PM
rw-r--r--
📄
warnings.py
3.76 KB
01/15/2025 03:24:11 PM
rw-r--r--
Editing: performance.py
Close
import functools import logging import time LOG = logging.getLogger(__name__) class Timed: """ A context manager which measures and optionally logs context run time. :param msg: A message that describes the thing that is being measured :param threshold: Threshold, in seconds. When the context exceeds this threshold, a log will be made. :param log_mode: Control whether to log. Defaults to "threshold". Possible values include: "always" - Always log 'msg', even when 'threshold' is not reached. "threshold" - Log when context time exceeds 'threshold'. "skip" - Do not log. Context time and message are stored in the 'output' and 'delta' attributes, respectively. Used to manually coalesce with other logs at the call site. usage: this call: ``` with Timed("Configuring the network"): run_configure() ``` might produce this log: ``` Configuring the network took 0.100 seconds ``` """ def __init__( self, msg: str, *, threshold: float = 0.01, log_mode: str = "threshold", ): self.msg = msg self.threshold = threshold self.log_mode = log_mode self.output = "" self.start = 0.0 self.delta = 0.0 def __enter__(self): self.start = time.monotonic() return self def __exit__(self, exc_type, exc_val, exc_tb): self.delta = time.monotonic() - self.start suffix = f"took {self.delta:.3f} seconds" if "always" == self.log_mode: LOG.debug("%s %s", self.msg, suffix) elif "skip" == self.log_mode: return elif "threshold" == self.log_mode: if self.delta > self.threshold: LOG.debug("%s %s", self.msg, suffix) self.output = f"{self.msg} {suffix}" else: raise ValueError( f"Invalid Timed log_mode value: '{self.log_mode}'." ) def timed(msg: str, *, threshold: float = 0.01, log_mode: str = "threshold"): """ A decorator which measures and optionally logs context run time. :param msg: A message that describes the thing that is being measured :param threshold: Threshold, in seconds. When the context exceeds this threshold, a log will be made. :param log_mode: Control whether to log. Defaults to "threshold". Possible values include: "always" - Always log 'msg', even when 'threshold' is not reached. "threshold" - Log when context time exceeds 'threshold'. usage: this call: ``` @timed("Configuring the network") def run_configure(): ... ``` might produce this log: ``` Configuring the network took 0.100 seconds ``` """ def wrapper(func): @functools.wraps(func) def decorator(*args, **kwargs): with Timed(msg, threshold=threshold, log_mode=log_mode): return func(*args, **kwargs) return decorator return wrapper