import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((250, 250))
self.SetTitle("frame")
sizer_1 = wx.WrapSizer(wx.VERTICAL)
fields = [
("Ширина (м)", "a"),
("Длина (м)", "b"),
("Высота (м)", "h"),
("Окно ширина (м)", "o1"),
("Окно высота (м)", "o2"),
("Дверь ширина (м)", "d1"),
("Дверь высота (м)", "d2"),
]
# Create grid sizers and controls dynamically
for label_text, attr in fields:
grid_sizer = wx.GridSizer(1, 2, 0, 0)
sizer_1.Add(grid_sizer, 1, wx.EXPAND, 0)
label = wx.StaticText(self, wx.ID_ANY, label_text)
grid_sizer.Add(label, 0, wx.ALL, 1)
text_ctrl = wx.TextCtrl(self, wx.ID_ANY, "")
setattr(self, attr, text_ctrl) # Store the text control in the instance
grid_sizer.Add(text_ctrl, 0, 0, 0)
# Create a horizontal sizer for the result and button
h_sizer = wx.BoxSizer(wx.HORIZONTAL)
# Result text control
self.itogo = wx.TextCtrl(self, wx.ID_ANY, "")
self.itogo.SetBackgroundColour((171, 171, 171))
h_sizer.Add(self.itogo, 1, wx.EXPAND | wx.ALL, 5)
# Calculate button
self.button_1 = wx.Button(self, wx.ID_ANY, "Посчитать", size=(110, 21))
h_sizer.Add(self.button_1, 0, wx.ALL, 5)
self.button_1.Bind(wx.EVT_BUTTON, self.onclick)
# Add the horizontal sizer to the main sizer
sizer_1.Add(h_sizer, 0, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
def onclick(self, event):
a = float(self.a.GetValue())
b = float(self.b.GetValue())
h = float(self.h.GetValue())
o1 = float(self.o1.GetValue())
o2 = float(self.o2.GetValue())
d1 = float(self.d1.GetValue())
d2 = float(self.d2.GetValue())
result = round(a * 2 * h + b * 2 * h - o1 * o2 - d1 * d2, 2)
self.itogo.SetValue(str(result))
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
key = "letters1keydog963"
totp = pyotp.TOTP(key)
base64.b32encode
.
Parameters
Secret
REQUIRED: The secret parameter is an arbitrary key value encoded in Base32 according to RFC 3548. The padding specified in RFC 3548 section 2.2 is not required and should be omitted.
from typing import Dict, Any
def process(answer, result_json: Dict[str, Any]) -> None:
tmp_json = parse_answer(answer)
result_json['summary_text'] += tmp_json['result']
result_json['tags'].extend(tmp_json['tags'])
result_json['input_size'] += answer.input_size
result_json['output_size'] += answer.output_size
def handler(text: str, max_size: int) -> Dict[str, Any]:
result_json = {'summary_text': '', 'tags': [], 'input_size': 0, 'output_size': 0}
match len(text):
case size if size > max_size:
chunker = TextChunker(maxlen=max_size)
for chunk in chunker.chunk(text):
answer = get_answer(chunk, tags_quantity=1)
process(answer, result_json)
case _:
answer = get_answer(text, tags_quantity=3)
process(answer, result_json)
return result_json
import subprocess
from time import sleep
class CameraMonitor:
def __init__(self):
self.IP12 = '192.168.0.100'
self.IP13 = '192.168.0.101'
self.RODOS12 = '192.168.1.100'
self.RODOS13 = '192.168.1.101'
self.fail_count = {'Купол 12': 0, 'Купол 13': 0}
self.reboot_count = {'Купол 12': 0, 'Купол 13': 0}
def ping_camera(self, ip):
cmd = f'ping {ip} -n 1 -w 100'
response = subprocess.call(cmd, stdout=subprocess.DEVNULL)
return response == 0
def cameras_checker(self):
r_dict = {'Купол 12': self.IP12, 'Купол 13': self.IP13}
while True:
for camera, ip in r_dict.items():
if self.ping_camera(ip):
print(f'Camera {camera} - OK')
self.fail_count[camera] = 0
else:
self.fail_count[camera] += 1
print(f'Camera {camera} - Died')
if self.fail_count[camera] >= 5:
self.cameras_reboot(camera)
sleep(5)
def cameras_reboot(self, camera):
if camera == 'Купол 12':
ip = self.RODOS12
else:
ip = self.RODOS13
self.reboot_count[camera] += 1
print(f'Rebooting {camera} at IP {ip}')
def info(self):
for camera, count in self.reboot_count.items():
print(f'Перезагрузок {camera}: {count}')
if __name__ == "__main__":
monitor = CameraMonitor()
monitor.cameras_checker()