mirror of
https://github.com/Snigdha-OS/snigdhaos-blackbox.git
synced 2025-09-21 12:05:02 +02:00
⏳ @eshanized updated the repository!!!
This commit is contained in:
@@ -5,9 +5,11 @@ from os import makedirs
|
|||||||
import sys
|
import sys
|
||||||
import gi
|
import gi
|
||||||
import subprocess
|
import subprocess
|
||||||
# import logging
|
import logging
|
||||||
from logging import Logger
|
# from logging import Logger
|
||||||
import shutil
|
import shutil
|
||||||
|
import Settings
|
||||||
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
|
|
||||||
gi.require_version("Gtk" "3.0") # GTK 2.0 is dead!
|
gi.require_version("Gtk" "3.0") # GTK 2.0 is dead!
|
||||||
from gi.repository import GLib, Gtk
|
from gi.repository import GLib, Gtk
|
||||||
@@ -69,7 +71,7 @@ def permissions(dst):
|
|||||||
group = g.replace(")", "").strip() # NOTE: replace with nothing!
|
group = g.replace(")", "").strip() # NOTE: replace with nothing!
|
||||||
subprocess.call(["chown", "-R", sudo_username + ":" + group, dst], shell=False)
|
subprocess.call(["chown", "-R", sudo_username + ":" + group, dst], shell=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
# NOTE: Creating Log, Export and Config Directory:
|
# NOTE: Creating Log, Export and Config Directory:
|
||||||
try:
|
try:
|
||||||
@@ -93,3 +95,35 @@ except os.error as oserror:
|
|||||||
|
|
||||||
# NOTE: Read Config File dst: $HOME/.config/blackbox/blackbox.yaml
|
# NOTE: Read Config File dst: $HOME/.config/blackbox/blackbox.yaml
|
||||||
# NOTE: Initiate logger
|
# NOTE: Initiate logger
|
||||||
|
try:
|
||||||
|
settings = Settings(False, False)
|
||||||
|
settings_config = settings.read_config_file()
|
||||||
|
logger = logging.getLogger("logger")
|
||||||
|
# NOTE: Create a console handler
|
||||||
|
ch = logging.StreamHandler()
|
||||||
|
# NOTE: Rotate the fucking event log!
|
||||||
|
tfh = TimedRotatingFileHandler(
|
||||||
|
event_log_file,
|
||||||
|
encoding="UTF-8",
|
||||||
|
delay=False,
|
||||||
|
when="W4",
|
||||||
|
)
|
||||||
|
|
||||||
|
if settings_config:
|
||||||
|
debug_logging_enabled = None
|
||||||
|
debug_logging_enabled = settings_config[
|
||||||
|
"Debug Logging"
|
||||||
|
]
|
||||||
|
|
||||||
|
if debug_logging_enabled is not None and debug_logging_enabled is True:
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
ch.setLevel(logging.DEBUG)
|
||||||
|
tfh.setLevel(level=logging.DEBUG)
|
||||||
|
else:
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
ch.setLevel(logging.INFO)
|
||||||
|
tfh.setLevel(level=logging.INFO)
|
||||||
|
else:
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
ch.setLevel(logging.INFO)
|
||||||
|
tfh.setLevel(level=logging.INFO)
|
||||||
|
@@ -75,7 +75,7 @@ class Settings(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
fn.Logger.error("[ERROR] Exception: %s" % e)
|
fn.Logger.error("[ERROR] Exception: %s" % e)
|
||||||
|
|
||||||
def read_cofig_file(self):
|
def read_config_file(self):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(fn.config_file):
|
if os.path.exists(fn.config_file):
|
||||||
contents = []
|
contents = []
|
||||||
@@ -125,4 +125,3 @@ class Settings(object):
|
|||||||
return conf_settings
|
return conf_settings
|
||||||
else:
|
else:
|
||||||
print("[ERROR] Failed To Read Settings!")
|
print("[ERROR] Failed To Read Settings!")
|
||||||
|
|
Reference in New Issue
Block a user