Fixed importing logic for mixins

This commit is contained in:
Maxim Stewart 2020-05-07 19:38:06 -05:00
parent 4ceb32f7b7
commit 6988ce3810
7 changed files with 72 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import threading, subprocess, os
# Gtk imports
# Application imports
from .mixins import *
def threaded(fn):
@ -13,7 +14,7 @@ def threaded(fn):
return wrapper
class CrossClassSignals:
class Signals(DummyMixin):
def __init__(self, settings):
self.settings = settings
self.builder = self.settings.returnBuilder()

View File

@ -1,2 +1,5 @@
"""
Gtk Bound Signal Module
"""
from .mixins import *
from . import Signals
from .Signals import Signals

View File

@ -0,0 +1,4 @@
class DummyMixin:
"""docstring for DummyMixin"""
def printHelloWorld(self):
print("Hello World!")

View File

@ -1 +1 @@
from . import *
from .DummyMixin import DummyMixin

55
src/utils/Logger.py Normal file
View File

@ -0,0 +1,55 @@
# Python imports
import os, logging
# Application imports
class Logger:
def __init__(self):
pass
def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True):
"""
Create a new logging object and return it.
:note:
NOSET # Don't know the actual log level of this... (defaulting or literally none?)
Log Levels (From least to most)
Type Value
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
:param loggerName: Sets the name of the logger object. (Used in log lines)
:param createFile: Whether we create a log file or just pump to terminal
:return: the logging object we created
"""
globalLogLvl = logging.DEBUG # Keep this at highest so that handlers can filter to their desired levels
chLogLevel = logging.CRITICAL # Prety musch the only one we change ever
fhLogLevel = logging.DEBUG
log = logging.getLogger(loggerName)
# Set our log output styles
fFormatter = logging.Formatter('[%(asctime)s] %(pathname)s:%(lineno)d %(levelname)s - %(message)s', '%m-%d %H:%M:%S')
cFormatter = logging.Formatter('%(pathname)s:%(lineno)d] %(levelname)s - %(message)s')
ch = logging.StreamHandler()
ch.setLevel(level=chLogLevel)
ch.setFormatter(cFormatter)
log.addHandler(ch)
if createFile:
folder = "core/logs"
file = folder + "/twitter-bot.log"
if not os.path.exists(folder):
os.mkdir(folder)
fh = logging.FileHandler(file)
fh.setLevel(level=fhLogLevel)
fh.setFormatter(fFormatter)
log.addHandler(fh)
return log

View File

@ -1 +0,0 @@
from . import Settings

6
src/utils/__init__.py Normal file
View File

@ -0,0 +1,6 @@
"""
Utils module
"""
from .Logger import Logger
from .Settings import Settings