[~] Refactor

This commit is contained in:
Siarhei Siniak 2022-01-17 15:49:15 +03:00
parent bbf3be0b66
commit 0b8570e725

@ -232,6 +232,28 @@ def eternal_firefox(
if debug: if debug:
assert subprocess.check_call(['notify-send', '%s:Closed' % group_name]) == 0 assert subprocess.check_call(['notify-send', '%s:Closed' % group_name]) == 0
def resilient_ethernet(ip_addr, ethernet_device):
subprocess.check_call(
r'''
sudo sh -c '\
while true; \
do ping -c 3 -w 3 -W 1 {{IP_ADDR}} || (\
ip link set {{ETHERNET_DEVICE}} down; \
ip link set {{ETHERNET_DEVICE}} up; \
sleep 4; true;\
); \
sleep 10; clear; date; \
done'
'''.replace(
'{{IP_ADDR}}',
ip_addr
).replace(
'{{ETHERNET_DEVICE}}}',
ethernet_device
),
shell=True
)
def status(): def status():
return ' | '.join([ return ' | '.join([
subprocess.check_output(o, shell=True).decode('utf-8').strip() subprocess.check_output(o, shell=True).decode('utf-8').strip()
@ -322,6 +344,11 @@ try:
debug=json.loads(sys.argv[5]), debug=json.loads(sys.argv[5]),
tabs=sys.argv[6:], tabs=sys.argv[6:],
) )
elif sys.argv[1] == 'resilient-ethernet':
resilient_ethernet(
ip_addr=sys.argv[2],
ethernet_device=sys.argv[3],
)
else: else:
raise NotImplementedError raise NotImplementedError
except: except: