2023-05-17 10:16:15 +00:00
|
|
|
import sys
|
|
|
|
|
import os
|
2023-10-27 13:14:49 +00:00
|
|
|
import platform
|
2023-05-17 10:16:15 +00:00
|
|
|
import configparser
|
2023-11-02 19:17:25 +00:00
|
|
|
from log import Log
|
2023-11-09 13:57:36 +00:00
|
|
|
|
|
|
|
|
print("---- [BOOT] ----")
|
|
|
|
|
from core.registration.registrar import Registrar
|
|
|
|
|
registrar = Registrar()
|
2023-11-09 20:22:58 +00:00
|
|
|
registrar.registry().register("message","logs")
|
2023-11-09 13:57:36 +00:00
|
|
|
registrar.registry().register("log","display")
|
|
|
|
|
registrar.registry().register("console","display")
|
|
|
|
|
print("---- [END OF BOOT] ----")
|
|
|
|
|
|
2023-11-02 19:17:25 +00:00
|
|
|
log = Log(3)
|
|
|
|
|
log.debugOn()
|
|
|
|
|
log.debug_level = 3
|
2023-11-09 20:22:58 +00:00
|
|
|
log.eventOff()
|
2023-11-02 19:17:25 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
from mouseevents import MouseEvents
|
|
|
|
|
from pynput import mouse
|
|
|
|
|
from sightfactory import SightFactory
|
|
|
|
|
from PyQt6.QtWidgets import QApplication
|
|
|
|
|
from pynput.mouse import Controller
|
2023-10-30 19:43:35 +00:00
|
|
|
import subprocess
|
2023-11-09 13:57:36 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
|
2023-11-09 13:57:36 +00:00
|
|
|
def getTimeStamp():
|
|
|
|
|
return int(time.time())
|
2023-05-17 10:16:15 +00:00
|
|
|
def init():
|
2023-11-02 19:17:25 +00:00
|
|
|
global sights, mousectrl, app, data
|
|
|
|
|
data = {}
|
2023-11-09 13:57:36 +00:00
|
|
|
data["started_time"] = int(time.time())
|
2023-05-17 10:16:15 +00:00
|
|
|
#init the basic values
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
|
mousectrl = Controller()
|
|
|
|
|
sights = SightFactory()
|
2023-10-31 07:20:44 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
data["move"] = False
|
|
|
|
|
data["active_sight"] = "main"
|
2023-11-02 19:17:25 +00:00
|
|
|
|
2023-10-27 13:14:49 +00:00
|
|
|
data["platform"] = {}
|
|
|
|
|
data["platform"]["system"] = platform.system()
|
2023-05-17 10:16:15 +00:00
|
|
|
data["mouse_distance_x"] = 0
|
|
|
|
|
data["mouse_distance_y"] = 0
|
2023-10-30 19:43:35 +00:00
|
|
|
data["display_server"] = ""
|
|
|
|
|
if data["platform"]["system"] == "Linux":
|
|
|
|
|
args = ["echo -n $XDG_SESSION_TYPE"]
|
|
|
|
|
result = subprocess.check_output(args, shell=True)
|
|
|
|
|
data["display_server"] = result.decode('ascii')
|
2023-05-17 10:16:15 +00:00
|
|
|
data["base_dir"]=os.path.abspath(os.getcwd())+os.path.sep
|
|
|
|
|
data["template_dir"]=data["base_dir"]+"place"+os.path.sep+"templates"+os.path.sep
|
2023-11-02 19:17:25 +00:00
|
|
|
|
|
|
|
|
data["admin_template"] = data["base_dir"] + "admin" +os.path.sep + "base"+os.path.sep
|
2023-10-31 07:20:44 +00:00
|
|
|
#LOAD the template config.ini file's content
|
2023-05-17 10:16:15 +00:00
|
|
|
loadConfigTemplate()
|
2023-10-31 07:20:44 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
#Events
|
|
|
|
|
mouseevent = MouseEvents()
|
|
|
|
|
start()
|
|
|
|
|
|
2023-10-30 19:43:35 +00:00
|
|
|
def frameSupported():
|
|
|
|
|
if data["display_server"] == "wayland":
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
def loadConfigTemplate():
|
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
|
config.sections()
|
|
|
|
|
config.read(data["template_dir"]+"config.ini")
|
|
|
|
|
if "DEFAULT" in config:
|
|
|
|
|
data["default_template"] = config["DEFAULT"]["default_template"]
|
2023-10-27 13:14:49 +00:00
|
|
|
data["default_template_page"] = config["DEFAULT"]["default_template_page"]
|
2023-05-17 10:16:15 +00:00
|
|
|
data["default_template_dir"] = data["template_dir"]+data["default_template"]+os.path.sep
|
|
|
|
|
data["sight_mode"] = config["DEFAULT"]["sight_mode"]
|
2023-11-02 19:17:25 +00:00
|
|
|
log.byCode("CFL1000S","CONFIG.INI file")
|
2023-05-17 10:16:15 +00:00
|
|
|
else:
|
2023-11-02 19:17:25 +00:00
|
|
|
log.byCode( "CFL1000F", "Missing 'DEFAULT' data from the templates config.ini folder. It can't start!")
|
2023-05-17 10:16:15 +00:00
|
|
|
|
|
|
|
|
def start():
|
2023-11-02 19:17:25 +00:00
|
|
|
# Creating admin sight
|
2023-11-13 19:32:09 +00:00
|
|
|
sights.create("sight-admin", "sight-admin")
|
|
|
|
|
sights.show("sight-admin")
|
2023-11-02 19:17:25 +00:00
|
|
|
|
2023-05-17 10:16:15 +00:00
|
|
|
# Creating the main Sight
|
2023-10-31 07:20:44 +00:00
|
|
|
sights.create("main", data["default_template_page"])
|
|
|
|
|
sights.show("main")
|
2023-11-09 13:57:36 +00:00
|
|
|
|
2023-11-02 19:17:25 +00:00
|
|
|
app.exec()
|