def __init__(self):
     self.file_dir = os.path.dirname(os.path.realpath(__file__))
     self.dp_directory = PurePath(
         self.file_dir,
         DataPackageServerConstants().DATAPACKAGEFOLDER)
     self.logs_directory = PurePath(LoggingConstants().PARENTPATH,
                                    LoggingConstants().LOGDIRECTORY)
     self.createFolder()
Beispiel #2
0
def return_logs(time):
    from FreeTAKServer.controllers.configuration.LoggingConstants import LoggingConstants
    import datetime
    log_data = {'log_data': []}
    for line in reversed(open(LoggingConstants().ERRORLOG, "r").readlines()):
        try:
            timeoflog = line.split(" : ")[1]
            if datetime.datetime.strptime(
                    timeoflog,
                    '%Y-%m-%d %H:%M:%S,%f') > datetime.datetime.strptime(
                        json.loads(time)["time"], '%Y-%m-%d %H:%M:%S,%f'):
                outline = {"time": '', "type": '', 'file': '', 'message': ''}
                line_segments = line.split(" : ")
                outline["type"] = line_segments[0]
                outline["time"] = line_segments[1]
                outline["file"] = line_segments[2]
                outline["message"] = " : ".join(line_segments[3:-1])
                log_data['log_data'].append(outline)
            else:
                break
        except:
            pass
    for num in range(1, 6):
        try:
            for line in reversed(
                    open(LoggingConstants().ERRORLOG + '.' + str(num),
                         "r").readlines()):
                try:
                    timeoflog = line.split(" : ")[1]
                    if datetime.datetime.strptime(
                            timeoflog, '%Y-%m-%d %H:%M:%S,%f'
                    ) > datetime.datetime.strptime(
                            json.loads(time)["time"], '%Y-%m-%d %H:%M:%S,%f'):
                        outline = {
                            "time": '',
                            "type": '',
                            'file': '',
                            'message': ''
                        }
                        line_segments = line.split(" : ")
                        outline["type"] = line_segments[0]
                        outline["time"] = line_segments[1]
                        outline["file"] = line_segments[2]
                        outline["message"] = line_segments[3]
                        log_data['log_data'].append(outline)
                    else:
                        break
                except:
                    pass
        except:
            pass
    emit("logUpdate", json.dumps(log_data))
 def createFolder(self):
     try:
         os.mkdir(self.dp_directory)
     except:
         pass
     try:
         os.mkdir(self.logs_directory)
     except:
         pass
     ERRORLOG = open(LoggingConstants().ERRORLOG, "w")
     ERRORLOG.close()
     HTTPLOG = open(LoggingConstants().HTTPLOG, "w")
     HTTPLOG.close()
     DEBUGLOG = open(LoggingConstants().DEBUGLOG, "w")
     DEBUGLOG.close()
     INFOLOG = open(LoggingConstants().INFOLOG, "w")
     INFOLOG.close()
Beispiel #4
0
from FreeTAKServer.controllers.CreateLoggerController import CreateLoggerController
from FreeTAKServer.controllers.services.RestAPI import RestAPI
from FreeTAKServer.model.ServiceObjects.FTS import FTS as FTSObj
from FreeTAKServer.model.SimpleClient import SimpleClient
import time
from FreeTAKServer.controllers.AddDataToCoTList import AddDataToCoTList
from FreeTAKServer.model.FilterGroup import FilterGroup
from FreeTAKServer.controllers.services.SSLCoTServiceController import SSLCoTServiceController
from FreeTAKServer.controllers.services.TCPCoTServiceController import TCPCoTServiceController
from FreeTAKServer.controllers.services.federation.FederationClientService import FederationClientServiceController
from FreeTAKServer.controllers.services.federation.federation import FederationServerService
from FreeTAKServer.controllers.DatabaseControllers.DatabaseController import DatabaseController
from FreeTAKServer.controllers.certificate_generation import AtakOfTheCerts
from multiprocessing import Queue
from FreeTAKServer.controllers.configuration.MainConfig import MainConfig
loggingConstants = LoggingConstants()
logger = CreateLoggerController("FTS").getLogger()


# noinspection PyUnresolvedReferences
class FTS:
    def __init__(self):
        self.CoTService = None
        self.TCPDataPackageService = None
        self.UserCommand = None
        self.killSwitch = False
        self.ReceiveConnectionsReset = None
        self.CoTPoisonPill = None
        self.ClientDataPipe = None
        self.SSLClientDataPipe = None
        self.clientArray = []