This commit is contained in:
Untriex Programming 2021-04-15 14:56:49 +02:00
parent d8d3ff9b8e
commit 506047ca5c
10 changed files with 404 additions and 68 deletions

@ -22,21 +22,21 @@ class Log:
if self.print_error:
print(f"{datetime.now()} -> ERROR: {error}")
if self.save_error:
with open("log.txt", "a") as file:
with open("log.txt", "a", encoding='utf-8') as file:
file.write(f"\n{datetime.now()} -> ERROR: {error}")
def warning(self, warning):
if self.print_warning:
print(f"{datetime.now()} -> Warning: {warning}")
if self.save_warning:
with open("log.txt", "a") as file:
with open("log.txt", "a", encoding='utf-8') as file:
file.write(f"\n{datetime.now()} -> Warning: {warning}")
def message(self, message):
if self.print_messages:
print(f"{datetime.now()} -> message: {message}")
if self.save_messages:
with open("log.txt", "a") as file:
with open("log.txt", "a", encoding='utf-8') as file:
file.write(f"\n{datetime.now()} -> message: {message}")
def debug(self, debug):
@ -46,7 +46,7 @@ class Log:
class Update:
def __init__(self):
with open("version.json", "r") as f: # loading settings
with open("version.json", "r", encoding='utf-8') as f: # loading settings
version = json.load(f)
self.url = "https://raw.githubusercontent.com/UntriexTv/test_directory/main/ver.json"
self.version = version["version"]
@ -88,7 +88,7 @@ class Scan:
self.errors.append("Filesystem is missing")
else:
try:
with open("filesystem.json", "r") as f:
with open("filesystem.json", "r", encoding='utf-8') as f:
filesystem = json.load(f)
except:
self.state_list["error"].append("filesystem")
@ -120,5 +120,6 @@ class Scan:
def fix_version(self):
subprocess.check_output(["python3", "system.py", "update"])
o = subprocess.check_output(["python3", "system.py", "update"])
print(o)

0
server/files/PQ.apk Normal file

198
server/files/sample.pdf Normal file

@ -0,0 +1,198 @@
%PDF-1.3
%âãÏÓ
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Count 2
/Kids [ 4 0 R 6 0 R ]
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/Resources <<
/Font <<
/F1 9 0 R
>>
/ProcSet 8 0 R
>>
/MediaBox [0 0 612.0000 792.0000]
/Contents 5 0 R
>>
endobj
5 0 obj
<< /Length 1074 >>
stream
2 J
BT
0 0 0 rg
/F1 0027 Tf
57.3750 722.2800 Td
( A Simple PDF File ) Tj
ET
BT
/F1 0010 Tf
69.2500 688.6080 Td
( This is a small demonstration .pdf file - ) Tj
ET
BT
/F1 0010 Tf
69.2500 664.7040 Td
( just for use in the Virtual Mechanics tutorials. More text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 652.7520 Td
( text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 628.8480 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 616.8960 Td
( text. And more text. Boring, zzzzz. And more text. And more text. And ) Tj
ET
BT
/F1 0010 Tf
69.2500 604.9440 Td
( more text. And more text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 592.9920 Td
( And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 569.0880 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 557.1360 Td
( text. And more text. And more text. Even more. Continued on page 2 ...) Tj
ET
endstream
endobj
6 0 obj
<<
/Type /Page
/Parent 3 0 R
/Resources <<
/Font <<
/F1 9 0 R
>>
/ProcSet 8 0 R
>>
/MediaBox [0 0 612.0000 792.0000]
/Contents 7 0 R
>>
endobj
7 0 obj
<< /Length 676 >>
stream
2 J
BT
0 0 0 rg
/F1 0027 Tf
57.3750 722.2800 Td
( Simple PDF File 2 ) Tj
ET
BT
/F1 0010 Tf
69.2500 688.6080 Td
( ...continued from page 1. Yet more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 676.6560 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 664.7040 Td
( text. Oh, how boring typing this stuff. But not as boring as watching ) Tj
ET
BT
/F1 0010 Tf
69.2500 652.7520 Td
( paint dry. And more text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 640.8000 Td
( Boring. More, a little more text. The end, and just as well. ) Tj
ET
endstream
endobj
8 0 obj
[/PDF /Text]
endobj
9 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
>>
endobj
10 0 obj
<<
/Creator (Rave \(http://www.nevrona.com/rave\))
/Producer (Nevrona Designs)
/CreationDate (D:20060301072826)
>>
endobj
xref
0 11
0000000000 65535 f
0000000019 00000 n
0000000093 00000 n
0000000147 00000 n
0000000222 00000 n
0000000390 00000 n
0000001522 00000 n
0000001690 00000 n
0000002423 00000 n
0000002456 00000 n
0000002574 00000 n
trailer
<<
/Size 11
/Root 1 0 R
/Info 10 0 R
>>
startxref
2714
%%EOF

BIN
server/files/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

@ -1,12 +1,12 @@
{
"ID": 0,
"location": "izba",
"location": "49.14178021389778,18.353783098441415",
"description": {
"title": "legionrpi",
"description_s": "krátky popis, ktorý bude zobrazený iba v náhladovom okne",
"description_l": "dlhší popis zariadenia, ktorý bude zobrazený po otvorení",
"photo_s": "mala_fotka.png",
"photo_b": "velka fotka.png"
"photo_s": "test.jpg",
"photo_b": "test.png"
},
"files": [
{

@ -1,3 +1,159 @@
2021-03-15 10:13:26.660898 -> Warning: 192.168.1.232 disconnected/is not available
2021-03-15 11:23:33.589998 -> Warning: 192.168.1.231 disconnected/is not available
2021-03-21 12:33:11.947538 -> Warning: 192.168.1.232 disconnected/is not available
2021-03-24 09:47:07.677185 -> Warning: 192.168.1.232 disconnected/is not available
2021-03-24 10:51:12.802174 -> Warning: 192.168.1.232 disconnected/is not available
2021-03-24 10:51:12.804164 -> Warning: 192.168.1.231 disconnected/is not available
2021-03-24 12:20:17.717820 -> Warning: 192.168.1.231 disconnected/is not available
2021-03-24 12:20:18.728113 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 17:47:36.579990 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 18:01:09.637683 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 18:06:27.367910 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:09:14.702582 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:09:44.558742 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:11:19.482976 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:21:00.445053 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: Internal Server Error
2021-04-06 18:21:00.468768 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: Internal Server Error
2021-04-06 18:26:26.230043 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:26:26.765624 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:26:46.326513 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:26:46.857832 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:27:17.853160 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:27:18.393648 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:28:32.760504 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:28:33.303332 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "Version not found.\n"
2021-04-06 18:28:47.795564 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 18:29:38.864951 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 18:30:21.991616 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "Download succefull\nExtracting update\nupdate to 0.6 was succefull.\n"
2021-04-06 18:30:22.828559 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "Download succefull\nExtracting update\nupdate to 0.6 was succefull.\n"
2021-04-06 18:38:39.034010 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version {'version': '0.6', 'id': 4, 'url': 'https://raw.githubusercontent.com/UntriexTv/test_directory/main/ver.json'} to 0.6 was sucesfull\n"
2021-04-06 18:38:39.846078 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version {'version': '0.6', 'id': 4, 'url': 'https://raw.githubusercontent.com/UntriexTv/test_directory/main/ver.json'} to 0.6 was sucesfull\n"
2021-04-06 18:38:43.579251 -> Warning: 192.168.1.231 disconnected/is not available
2021-04-06 18:41:20.200515 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version {'0.1': {'change_list': 'this is only initial release for testing purpose', 'id': 2}, '0.5': {'change_list': 'fist working release', 'id': 3}, '0.6': {'change_list': 'normal update', 'id': 4}} to 0.6 was sucesfull\n"
2021-04-06 18:41:21.012333 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version {'0.1': {'change_list': 'this is only initial release for testing purpose', 'id': 2}, '0.5': {'change_list': 'fist working release', 'id': 3}, '0.6': {'change_list': 'normal update', 'id': 4}} to 0.6 was sucesfull\n"
2021-04-06 18:43:14.079603 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:43:14.908686 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:44:45.325212 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:44:45.334610 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:44:51.128403 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:44:51.135988 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: {"detail":"Not Found"}
2021-04-06 18:45:13.073433 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:45:13.894493 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:46:42.900283 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:46:43.720053 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:47:20.543756 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:47:21.533385 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:48:44.524464 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:48:45.362610 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:49:28.460321 -> Warning: 192.168.1.232 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:49:29.387142 -> Warning: 192.168.1.231 failed to update. Manual update may be needed for proper working of network.
Response from server: "SUCCESS\nUpdate from version 0.6 to 0.6 was sucesfull\n"
2021-04-06 18:52:52.010837 -> Warning: 192.168.1.231 disconnected/is not available
2021-04-06 18:53:06.029220 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-06 19:52:34.214066 -> Warning: Device Address(host='10.42.0.238', port=18381) is creating new sensor data.
SENSOR: ['vlhkost', '40']
2021-04-06 20:58:51.194511 -> Warning: Address(host='10.42.0.238', port=11244) created new sensor.
SENSOR: name='Teplota' value='18'
2021-04-06 20:58:52.311838 -> Warning: Address(host='10.42.0.238', port=8118) created new sensor.
SENSOR: name='Vlhkost' value='52'
2021-04-06 21:00:22.844916 -> Warning: Address(host='10.42.0.238', port=9199) created new sensor.
SENSOR: name='Teplota' value='27'
2021-04-06 21:00:23.915833 -> Warning: Address(host='10.42.0.238', port=15482) created new sensor.
SENSOR: name='Vlhkost' value='95'
2021-04-06 21:01:04.874694 -> Warning: Address(host='10.42.0.238', port=4606) created new sensor.
SENSOR: name='Teplota' value='24'
2021-04-06 21:01:06.020948 -> Warning: Address(host='10.42.0.238', port=16111) created new sensor.
SENSOR: name='Vlhkost' value='95'
2021-04-06 21:02:56.676046 -> Warning: Address(host='10.42.0.238', port=1280) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-06 21:02:57.773619 -> Warning: Address(host='10.42.0.238', port=12034) created new sensor.
SENSOR: name='Vlhkost' value='91'
2021-04-07 14:07:15.258217 -> Warning: Address(host='10.42.0.238', port=32353) created new sensor.
SENSOR: name='Teplota' value='19'
2021-04-07 14:07:16.454490 -> Warning: Address(host='10.42.0.238', port=19858) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 14:17:42.961164 -> Warning: Address(host='10.42.0.238', port=4696) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 14:17:44.114338 -> Warning: Address(host='10.42.0.238', port=4387) created new sensor.
SENSOR: name='Vlhkost' value='42'
2021-04-07 14:18:25.886229 -> Warning: 192.168.1.232 disconnected/is not available
2021-04-07 14:22:13.260725 -> ERROR: Sensor data download from 1 failed.
ERROR: 1 is not in list
2021-04-07 14:22:42.995956 -> ERROR: Sensor data download from 1 failed.
ERROR: 1 is not in list
2021-04-07 17:06:13.637610 -> ERROR: Sensor data download from 25 failed.
ERROR: 25 is not in list
2021-04-07 17:16:09.500542 -> Warning: test on server 192.168.1.231 is changed.
2021-04-07 17:24:05.379288 -> Warning: Address(host='10.42.0.238', port=25175) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 17:24:06.475344 -> Warning: Address(host='10.42.0.238', port=5919) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 17:34:29.681729 -> Warning: Address(host='10.42.0.238', port=8767) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 17:34:30.857047 -> Warning: Address(host='10.42.0.238', port=19458) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 17:35:06.210117 -> Warning: Address(host='10.42.0.238', port=15677) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 17:35:07.332588 -> Warning: Address(host='10.42.0.238', port=27433) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 17:36:02.490752 -> Warning: Address(host='10.42.0.238', port=29010) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 17:36:03.561727 -> Warning: Address(host='10.42.0.238', port=26279) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 17:39:30.650731 -> Warning: Address(host='10.42.0.238', port=26716) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 17:39:31.746802 -> Warning: Address(host='10.42.0.238', port=11238) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 19:03:34.951363 -> Warning: Address(host='10.42.0.238', port=19388) created new sensor.
SENSOR: name='Teplota' value='20'
2021-04-07 19:03:36.076556 -> Warning: Address(host='10.42.0.238', port=24582) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-07 20:03:53.809025 -> Warning: Address(host='10.42.0.238', port=30182) created new sensor.
SENSOR: name='Vlhkost' value='46'
2021-04-14 12:55:05.505789 -> ERROR: Sensor data download from 1 failed.
ERROR: 1 is not in list
2021-04-14 13:04:30.181791 -> Warning: Address(host='192.168.1.99', port=54888) created new sensor.
SENSOR: name='sensor1' value='test'
2021-04-14 13:04:36.780037 -> Warning: Address(host='192.168.1.99', port=54904) created new sensor.
SENSOR: name='sensor2' value='1234'
2021-04-14 13:06:59.405575 -> Warning: Address(host='192.168.1.99', port=54974) created new sensor.
SENSOR: name='sensor2' value='1234'
2021-04-14 14:09:58.696666 -> Warning: Address(host='192.168.1.99', port=58182) created new sensor.
SENSOR: name='sensor1' value='test'
2021-04-14 14:10:06.190377 -> Warning: Address(host='192.168.1.99', port=58192) created new sensor.
SENSOR: name='sensor2' value='123456789'

@ -1,14 +1,13 @@
import hashlib
import json
import os
import sys
import threading
import time
import engine
import requests
import uuid
import subprocess
from fastapi import FastAPI, Request
from fastapi import FastAPI, Request, File, UploadFile
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from pydantic import BaseModel
@ -18,12 +17,12 @@ check.check_to_go()
if check.state_list["error"]:
for error in check.errors:
print(error)
sys.exit()
check.fix_version()
with open("settings.json", "r") as f: # loading settings
with open("settings.json", "r", encoding='utf-8') as f: # loading settings
settings = json.load(f)
with open("filesystem.json", "r") as f: # loading filesystem
with open("filesystem.json", "r", encoding='utf-8') as f: # loading filesystem
filesystem = json.load(f)
IP = settings["IP"]
@ -54,7 +53,7 @@ time_to_heartbeat_offline = settings[
heartbeat_table = settings["heartbeat_table"]
sensors = {}
messages = []
messages = [] # {user: "", timestamp: time.Time(), message: ""}
heartbeat_table["ID"].append(ID)
heartbeat_table["IP"].append(IP)
@ -163,6 +162,10 @@ def get_file(IDx: int, file: str, request: Request):
log.error(f"{request.client} tried to access file ({file}) on id {IDx} that does not exist.")
return f"ERROR: {file} does not exist."
log.message(f"Downloaded {file} from {server_ip}")
if ".txt" in file:
with open(f"cache/{IDx}/{file}", "wb", encoding='utf-8') as save:
save.write(bytes(r.content))
else:
with open(f"cache/{IDx}/{file}", "wb") as save:
save.write(bytes(r.content))
return FileResponse(f"cache/{IDx}/{file}")
@ -222,32 +225,39 @@ def admin_get(command: str):
state = subprocess.check_output(["python3", "system.py", "update", "-version", f"""{command.split("-")[1]}"""])
log.warning(state.decode("utf-8"))
return state.decode("utf-8")
if command == "setting":
if command == "settings":
return settings
if command == "filesystem":
return filesystem
@app.post("admin/post/{command}")
def admin_post(command: str, data):
pass
@app.post("/admin/upload_file")
async def create_upload_file(uploaded_file: UploadFile = File(...), patch: str = ""):
file_location = f"{patch}{uploaded_file.filename}"
with open(file_location, "wb+") as file_object:
file_object.write(uploaded_file.file.read())
return {"info": f"file '{uploaded_file.filename}' saved at '{file_location}'"}
# Todo upload of update file and settings
@app.get("/messages/get")
def get_messages(m_from: int = 0, m_to: int = 10):
return messages[m_from:m_to]
def get_messages(timestamp):
for position, message in enumerate(reversed(messages)):
if message["timestamp"] == timestamp:
return reversed(messages)[:position]
@app.get("/messages/reqister")
def get_messages():
return uuid.uuid4().hex[24:]
return [uuid.uuid4().hex[24:], messages[:9]]
@app.post("/messages/post")
def get_messages(m_sender: str = None, message: str = None):
if m_sender and message:
messages.append({"sender": m_sender, "message": message})
messages.append({"sender": m_sender, "message": message, "timestamp": time.time()})
return "successful"
else:
return "Empty message/sender"
@ -303,7 +313,7 @@ def mainloop():
log.message("Saving heartbeat table.")
log.debug(f"Saving heartbeat table: {heartbeat_table}")
settings["heartbeat_table"] = heartbeat_table
with open("settings.json", "w") as file:
with open("settings.json", "w", encoding='utf-8') as file:
json.dump(settings, file, indent=2)
time.sleep(1)

@ -1,7 +1,7 @@
{
"ID": 0,
"IP": "192.168.1.99",
"location": "izba",
"location": "49.14178021389778,18.353783098441415",
"time_to_heartbeat": 20,
"time_to_heartbeat_offline": 25,
"save_table": false,
@ -13,7 +13,7 @@
"print_warning": true,
"save_message": false,
"print_message": true,
"enable_debug": false
"enable_debug": true
},
"heartbeat_table": {
"ID": [],

@ -29,29 +29,24 @@ if command in ["u", "update"]:
sys.exit()
else:
version_download = 0
try:
with open("version.json", "r") as f: # loading settings
with open("version.json", "r", encoding='utf-8') as f: # loading settings
version = json.load(f)
except:
version = {"id": 0}
version = {"id": 0, "version": "recovery"}
for ver, data in enumerate(server_version.values()):
if data["id"] > version["id"] and ver > version_download:
if data["id"] > version["id"]:
version_download = list(server_version.keys())[ver]
try:
with open("update.zip", "wb") as save:
with open("update.zip", "wb", encoding='utf-8') as save:
save.write(
bytes(requests.get(
f"https://github.com/UntriexTv/test_directory/releases/download/{version_download}/update.zip").content))
except Exception as error:
print(f"FAILED TO DOWNLOAD UPDATE. ERROR: {error}")
sys.exit()
if not os.path.isdir("update"):
os.mkdir("update")
with zipfile.ZipFile("update.zip", "r") as zip_ref:
zip_ref.extractall("update")
os.rmdir("update")
zip_ref.extractall("")
os.remove("update.zip")
print("SUCCESS")
print(f"""Update from version {version["version"]} to {version_download} was sucesfull""")
@ -60,24 +55,24 @@ if command == "clean":
if arguments[1] == "all":
open("log.txt", "w").close()
with open("settings.json", "r") as file:
with open("settings.json", "r", encoding='utf-8') as file:
settings = json.load(file)
for line in settings["heartbeat_table"]:
settings["heartbeat_table"][line] = []
with open("settings.json", "w") as file:
with open("settings.json", "w", encoding='utf-8') as file:
json.dump(settings, file, indent=2)
if arguments[1] == "log":
open("log.txt", "w").close()
if arguments[1] == "heartbeat_table":
with open("settings.json", "r") as file:
with open("settings.json", "r", encoding='utf-8') as file:
settings = json.load(file)
for line in settings["heartbeat_table"]:
settings["heartbeat_table"][line] = []
with open("settings.json", "w") as file:
with open("settings.json", "w", encoding='utf-8') as file:
json.dump(settings, file, indent=2)

@ -1,24 +0,0 @@
import threading
import uuid
import time
zoznam = []
rovnake = 0
run = True
start = time.time()
def generate():
global zoznam, rovnake, run
while run:
cache = uuid.uuid4().hex[24:]
if cache in zoznam:
rovnake += 1
zoznam.append(cache)
pocet = len(zoznam)
print(f"{pocet} : {rovnake} rovnakých - {cache}")
if pocet > 50000:
break
generate()
print(f"process lasted {time.time()-start}")