Compare commits
No commits in common. "8633bd072440270e1cdc953e0c63b4ffa5218640" and "904c77fc299a9ea61089525e2c814a8d24d56f01" have entirely different histories.
8633bd0724
...
904c77fc29
BIN
platform_dotfiles_gpg/ideapad_slim_3_15arp10/sensitive-configs-2025-12-04T11:59:04+03:00.gpg
(Stored with Git LFS)
BIN
platform_dotfiles_gpg/ideapad_slim_3_15arp10/sensitive-configs-2025-12-04T11:59:04+03:00.gpg
(Stored with Git LFS)
Binary file not shown.
@ -1,8 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
import datetime
|
|
||||||
import time
|
|
||||||
import os
|
import os
|
||||||
import signal
|
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -20,48 +17,7 @@ from typing import (
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_info(
|
|
||||||
sh: list[str],
|
|
||||||
timeout: int | float,
|
|
||||||
):
|
|
||||||
t1: list[str] = []
|
|
||||||
|
|
||||||
for sh_index, o in enumerate(
|
|
||||||
[
|
|
||||||
*sh,
|
|
||||||
*[
|
|
||||||
r"""
|
|
||||||
A=$(free -h | grep -P Mem: | grep -Po '[\w\.\d]+');
|
|
||||||
echo -n $A | awk '{print $2, $7}';
|
|
||||||
""",
|
|
||||||
r"""
|
|
||||||
date +'%Y-%m-%d %l:%M:%S %p';
|
|
||||||
""",
|
|
||||||
],
|
|
||||||
]
|
|
||||||
):
|
|
||||||
try:
|
|
||||||
t1.append(
|
|
||||||
subprocess.check_output(
|
|
||||||
o,
|
|
||||||
shell=True,
|
|
||||||
timeout=timeout,
|
|
||||||
)
|
|
||||||
.decode('utf-8')
|
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
t1.append('fail %d' % sh_index)
|
|
||||||
|
|
||||||
t3 = ' | '.join(t1).replace('\n\r', '')
|
|
||||||
|
|
||||||
sys.stdout.write(t3)
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
|
|
||||||
def run(argv: list[str]):
|
def run(argv: list[str]):
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
|
|
||||||
assert isinstance(argv, list) and all([isinstance(o, str) for o in argv])
|
assert isinstance(argv, list) and all([isinstance(o, str) for o in argv])
|
||||||
|
|
||||||
class c1(optparse.IndentedHelpFormatter):
|
class c1(optparse.IndentedHelpFormatter):
|
||||||
@ -125,13 +81,6 @@ def run(argv: list[str]):
|
|||||||
default=None,
|
default=None,
|
||||||
type=float,
|
type=float,
|
||||||
)
|
)
|
||||||
add_option(
|
|
||||||
parser,
|
|
||||||
'--repeat_interval',
|
|
||||||
dest='repeat_interval',
|
|
||||||
default=None,
|
|
||||||
type=float,
|
|
||||||
)
|
|
||||||
add_option(
|
add_option(
|
||||||
parser,
|
parser,
|
||||||
'--config',
|
'--config',
|
||||||
@ -173,38 +122,40 @@ printf '% 3.0f%%' $(upower -d | grep -Po 'percentage:\\s+\\d+(\\.\\d+)?%' | grep
|
|||||||
|
|
||||||
options.sh.extend(config.get('sh', []))
|
options.sh.extend(config.get('sh', []))
|
||||||
|
|
||||||
last_ts = datetime.datetime.now()
|
t1: list[str] = []
|
||||||
|
|
||||||
shutdown: bool = False
|
for sh_index, o in enumerate(
|
||||||
|
[
|
||||||
def on_signal(*args: Any, **kwargs: Any):
|
*options.sh,
|
||||||
nonlocal shutdown
|
*[
|
||||||
|
r"""
|
||||||
shutdown = True
|
A=$(free -h | grep -P Mem: | grep -Po '[\w\.\d]+');
|
||||||
|
echo -n $A | awk '{print $2, $7}';
|
||||||
signal.signal(signal.SIGINT, on_signal)
|
""",
|
||||||
signal.signal(signal.SIGTERM, on_signal)
|
r"""
|
||||||
|
date +'%Y-%m-%d %l:%M:%S %p';
|
||||||
while not shutdown:
|
""",
|
||||||
get_info(
|
],
|
||||||
|
]
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
t1.append(
|
||||||
|
subprocess.check_output(
|
||||||
|
o,
|
||||||
|
shell=True,
|
||||||
timeout=timeout2,
|
timeout=timeout2,
|
||||||
sh=options.sh,
|
|
||||||
)
|
)
|
||||||
|
.decode('utf-8')
|
||||||
|
.strip()
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
t1.append('fail %d' % sh_index)
|
||||||
|
|
||||||
if not options.repeat_interval:
|
t3 = ' | '.join(t1).replace('\n\r', '')
|
||||||
break
|
|
||||||
else:
|
sys.stdout.write(t3)
|
||||||
sys.stdout.write('\n')
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
now_ts = datetime.datetime.now()
|
|
||||||
spent = (now_ts - last_ts).total_seconds()
|
|
||||||
|
|
||||||
last_ts = last_ts + datetime.timedelta(seconds=options.repeat_interval)
|
|
||||||
|
|
||||||
if spent < options.repeat_interval:
|
|
||||||
time.sleep(options.repeat_interval - spent)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run(sys.argv[1:])
|
run(sys.argv[1:])
|
||||||
|
|||||||
BIN
releases/whl/online_fxreader_pr34-0.1.5.43-py3-none-any.whl
(Stored with Git LFS)
BIN
releases/whl/online_fxreader_pr34-0.1.5.43-py3-none-any.whl
(Stored with Git LFS)
Binary file not shown.
Loading…
Reference in New Issue
Block a user