Пример #1
0
	def __init__(self):
		self.Logs = Logs(self)
		self.Configs = Configs(self)
		self.DataUnits = DataUnits(self)
		self.HttpClient = HttpClient(self)
		self.HttpServer = HttpServer(self)
		self.Manipulator = Manipulator(self)
Пример #2
0
def btnlogout():
    logs = Logs()

    logs.logadorInfo("Logout do usuario: " + session['user'])
    session.pop('user', None)
    session.clear()
    return redirect(url_for('home.index'))
Пример #3
0
def AddAviso():

    valida = ValidaUser()

    retorno = valida.validaPermissao("avisos", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    avisos = Avisos()

    avisos.Titulo = request.form['Titulo']
    avisos.Conteudo = request.form['Conteudo']
    avisos.DataInicial = request.form['DataInicial']
    avisos.DataFinal = request.form['DataFinal']
    avisos.Tipo = 4

    avisos.UserPostId = request.form['UserId']

    avisos.Status = request.form['Status']

    exec = avisos.insertAviso()

    logs = Logs()
    logs.logadorInfo("novo Aviso Cadastrado.")

    return redirect(url_for('Avisos.AvisosAdm', resultInsert=exec))
Пример #4
0
def AddAnuncio():

    anuncios = Anuncios()
    imagens = Imagens()
    logs = Logs()

    anuncios.Titulo = request.form['Titulo']
    anuncios.Conteudo = request.form['Conteudo']
    anuncios.DataInicial = request.form['DataInicial']
    anuncios.DataFinal = request.form['DataFinal']
    anuncios.Status = request.form['Status']
    anuncios.Tipo = 3

    anuncios.UserPostId = session['id']

    imagens.imagem = "data:" + request.files[
        'imagem'].content_type + ";base64," + str(
            base64.b64encode(request.files['imagem'].read()), "utf-8")

    imagens.Post_ID = anuncios.insertAnuncio()

    if imagens.imagem == "data:application/octet-stream;base64,":
        imagens.imagem = None

    imagens.InsertImagem()
    logs.logadorInfo("Novo anuncio Criado")
    return redirect(url_for('Anuncios.AllAnunciosAdm'))
Пример #5
0
def UpdateUser():

    valida = ValidaUser()

    retorno = valida.validaPermissao("Users", session['tipo'])
        
    if retorno != True :  
        return redirect(url_for('home.index', msg="User_sem_Permissão"))      

    user=Usuarios()
    
    user.id = request.form['Id']
    user.Nome = request.form['Nome']
    user.Username = request.form['Username']
    user.Password = request.form['Password']
    user.tipo = request.form['Tipo']
    user.email = request.form['Email']
    user.phone = request.form['Phone']

    exec = user.updateUser()

    logs = Logs()
    logs.logadorInfo("Usuario Editado: " + user.Nome)

    return redirect(url_for('usuarios.index', resultUpdate=exec))
Пример #6
0
def Updatebanner():

    validauser = ValidaUser()

    retorno = validauser.validaPermissao("banners", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    banners = Banners()
    imagens = Imagens()

    banners.id = request.form['Id']
    banners.Titulo = request.form['Titulo']
    banners.Conteudo = request.form['Conteudo']
    banners.UserPostId = request.form['UserId']
    banners.Status = request.form['Status']

    imagens.imagem = "data:" + request.files[
        'imagem'].content_type + ";base64," + str(
            base64.b64encode(request.files['imagem'].read()), "utf-8")
    imagens.Post_ID = request.form['Id']

    banners.updatebanner()

    if imagens.imagem != "data:" + request.files[
            'imagem'].content_type + ";base64,":
        imagens.UpdateImagem()

    logs = Logs()
    logs.logadorInfo("Banner Editado com sucesso: " + banners.id)

    return redirect(url_for('Banners.BannersList'))
Пример #7
0
def Addnoticia():

    valida = ValidaUser()
    retorno = valida.validaPermissao("noticias", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    noticias = Noticias()
    imagens = Imagens()

    noticias.Titulo = request.form['Titulo']
    noticias.Conteudo = request.form['Conteudo']
    noticias.UserPostId = session['id']
    noticias.DataInicial = request.form['DataInicial']
    noticias.DataFinal = request.form['DataFinal']

    imagens.Post_ID = noticias.addnoticia()

    imagens.imagem = "data:" + request.files[
        'imagem'].content_type + ";base64," + str(
            base64.b64encode(request.files['imagem'].read()), "utf-8")

    if imagens.imagem == "data:application/octet-stream;base64,":
        imagens.imagem = None

    imagens.InsertImagem()

    logs = Logs()
    logs.logadorInfo("Nova noticia cadastrada.")

    return redirect(url_for('noticias.listanoticias'))
Пример #8
0
def UpdateAnuncio():

    anuncios = Anuncios()
    imagens = Imagens()
    logs = Logs()

    imagens.Post_ID = request.form['Id']
    anuncios.id = request.form['Id']
    anuncios.Titulo = request.form['Titulo']
    anuncios.Conteudo = request.form['Conteudo']
    anuncios.DataInicial = request.form['DataInicial']
    anuncios.DataFinal = request.form['DataFinal']
    anuncios.Status = request.form['Status']
    anuncios.Tipo = 3

    anuncios.UserPostId = session['id']

    if 'imgoptions' in request.form:
        rmvimg = request.form['imgoptions']
    else:
        rmvimg = "nova"

    if rmvimg == "remove":
        imagens.nullImagem()

    elif rmvimg == "nova":
        imagens.imagem = "data:" + request.files[
            'imagem'].content_type + ";base64," + str(
                base64.b64encode(request.files['imagem'].read()), "utf-8")
        imagens.UpdateImagem()
    anc = anuncios.updateAnuncio()

    logs.logadorInfo("anuncio Editado  " + anuncios.id)

    return redirect(url_for('Anuncios.AllAnunciosAdm'))
    def __init__(self, *args):
        self.log = Logs().getLog()
        super().__init__()
        self.point_scale = 20
        self.distance_scale = 40
        # self.label_y_offset = 10

        self.DB = Database()
        self.tracker = Tracker(self.DB)

        self.track_unknown = True
    def iniciaSimulacao(self):

        tempo1 = time.time()

        self.geraIndividuosAleatoriamente()
        #self.geraFogoInicial()
        for ind in range(self.dados.QTD_REPLICACACOES):
            self.carregaMapas()
            #self.geraIndividuosAleatoriamente()
            if self.dados.FLAG_ATIVACAO_FOGO:
                self.geraFogoInicial()

            self.diretorioImagens = self.diretorio + "/" + str(
                ind) + '/imagens/'
            os.makedirs(self.diretorioImagens)
            logs = Logs(self.diretorio, ind)
            #print("Replicacao numero "+str(ind))
            #logs.gravaNumReplicacao(ind)
            #logs.gravaCabecalho(self.dados.QTD_PESSOAS)
            self.tempo = 0
            self.atribuiMapaIndividuoInicial()
            #self.geraIndividuosAleatoriamente()

            logs.abreMovsPerIter()
            iters = self.simulacao(logs)
            logs.fechaMovsPerIter()

            KPIs = logs.printaKPIs(self.listaIndividuos,
                                   self.dados.FLAG_ATIVACAO_FOGO)

            logs.geraHTML(self.data, self.tempo,
                          self.listaIndividuos.__len__(),
                          self.listaMapas.__len__(), KPIs,
                          self.dados.FLAG_ATIVACAO_FOGO)
            #print("Simulacao Finalizada com sucesso com Tempo = " + str(self.tempo))
            #print(str(ind)+"\t"+str(self.tempo));
            logs.geraResultado(ind, self.tempo)

            self.exportaGraficos(self.diretorio, ind)

        tempo2 = time.time()
        dife = tempo2 - tempo1

        # Se arquivo não existe, cria-o com o cabeçalho
        if os.path.exists('resultados.txt'):
            file = open('resultados.txt', "a")
        else:
            file = open('resultados.txt', "w+")
            file.write("RUNTIME\tIteracoes\tMedia movimentos\tMedia espera\n")
        file.write(f"{str(dife)}\t{str(iters)}\t{KPIs[0]}\t{KPIs[1]}\n")
        file.close()
Пример #11
0
    def validaUsuario(self, username, password):
        banco = Banco()
        logs = Logs()
        logs.logadorInfo("Buscando usaurio no base.")
        try:
            c = banco.conexao.cursor()
            c.execute(
                "SELECT [id],[username] ,[password] , [tipo]  FROM [dbo].[users] where username = %s and "
                "password = %s", (username, password))
            result = c.fetchall()
            c.close()

            return result
        except:
            logs.logadorInfo("Erro ao buscar usuario na base.")
            return None
Пример #12
0
def ExcluiAnuncio():

    anuncios = Anuncios()
    imagens = Imagens()
    logs = Logs()

    anuncios.id = request.form['Id']
    imagens.Post_ID = request.form['Id']

    imagens.DeleteImagem()

    anuncios.DeletePost()

    logs.logadorInfo("anuncio Deletado  " + anuncios.id)

    return redirect(url_for('Anuncios.AllAnunciosAdm'))
Пример #13
0
def index():
    logs = Logs()
    logs.logadorInfo("iniciando carregamento da tela inicial")
    banners = Banners()
    noticias = Noticias()
    avisos = Avisos()

    banners = banners.selectAllBanners()
    principal = noticias.selectTop1noticiaspublic()
    top6 = noticias.selectTop6noticiaspublic()
    avisos = avisos.selecttop6Avisos()

    logs.logadorInfo("tela inicial carregada")


    return render_template('home_index.html', banners=banners, principal=principal, top6=top6, avisos=avisos)
Пример #14
0
    def __init__(self, DB):
        self.log = Logs().getLog()
        # Initializing MAC table
        self.STATION_MACS = {}
        self.TRACKING_MACS = []
        # 10 Second timeout
        self.timeout = 10

        # Dictionary of things to be tracked with MACs as key and coordinantes as values
        self.tracked_objects = {}

        self.DB = DB

        # Running actual program
        self.initMacs()

        self.last_id = 0
Пример #15
0
def main():
    config = configparser.ConfigParser()
    config.read('config.ini')

    logs = Logs(config['network']['IP'])
    waitTime = int(config['streaming']['delta'])

    Thread(target=PredictionProcess, args=(
        logs,
        waitTime,
        'IIS',
    )).start()
    Thread(target=PredictionProcess, args=(
        logs,
        waitTime,
        'DB',
    )).start()
Пример #16
0
def btnlogin():
    logs = Logs()
    validauser = ValidaUser()

    logs.logadorInfo("iniciando login")

    user = request.form.get('user')
    password = request.form.get('pass')

    userBanco = validauser.validaUsuario(user, password)

    userNameDB = 0
    passwordDB = 0
    tipo = 0

    if userBanco != None and userBanco != "":
        for row in userBanco:
            id = row[0]
            userNameDB = row[1]
            passwordDB = row[2]
            tipo = row[3]
        # Usuario correto
        if user == userNameDB and password == passwordDB:
            session.clear()
            session['user'] = userNameDB
            session['tipo'] = tipo
            session['id'] = id

            logs.logadorInfo("Login realizado para o usuario: " + user)

            return redirect(url_for('admin.index'))
        # user errado
        else:
            logs.logadorInfo(
                "Login nao realizado, Login ou senha incorretos para o usuario: "
                + user)
            return redirect(url_for('login.index', userIncorrect=1))
    else:
        logs.logadorInfo("Usuario nao encontrado: " + userNameDB)
        return redirect(
            url_for('login.index',
                    userIncorrect=1,
                    userdb=userNameDB,
                    passwordDB=passwordDB,
                    user=user,
                    password=password))
Пример #17
0
def DeleteAviso():

    valida = ValidaUser()
    retorno = valida.validaPermissao("avisos", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    avisos = Avisos()

    avisos.id = request.form['Id']

    exec = avisos.DeleteAviso()

    logs = Logs()
    logs.logadorInfo("Aviso Excluido: " + avisos.id)

    return redirect(url_for('Avisos.AvisosAdm', resultInsert=exec))
Пример #18
0
 def __init__(self, n, m, sc):
     self.N = n
     self.tura = 0
     self.M = m
     self.l = Logs(self)
     self.queue = Kolejka()
     self.aktualnygatunek = "Antylopa"
     self.aktualnyobrazek = pygame.image.load(self.aktualnygatunek + ".bmp")
     self.plikdozapisu = "save.txt"
     self.dozabicia = Zabij()
     self.plansza = [[None for i in range(self.M)] for j in range(self.N)]
     self.ekran = sc
     self.tlo = pygame.image.load("panelgry.png")
     self.pustepole = pygame.image.load("pusty.bmp")
     if n >= m:
         self.skalowanie = int(400 / n)
     else:
         self.skalowanie = int(400 / m)
Пример #19
0
 def scalability(self, comm, numbers, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for count in numbers:
         tid = "{}-scalability-{:02d}".format(comm, count)
         title = "Scalability - {} nodes ({})".format(count, comm.upper())
         self.run(comm + "_scalability", tid, count, title, count, skip,
                  logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Number of nodes"
             prefix = "{}-scalability-{}".format(comm, cmd)
             logs.extractThroughput('data/{}-throughput.dat'.format(prefix),
                                    cmd)
             logs.extractLatency('data/{}-latency.dat'.format(prefix), cmd)
             if len(logs.keys()) > 1:
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #20
0
 def loss(self, comm, losses, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for loss in losses:
         tid = "{}-loss-{:02d}".format(comm, loss)
         tc = "netem loss {}%".format(loss)
         title = "Loss {}% ({})".format(loss, comm.upper())
         self.run(comm, tid, tc, title, loss, skip, logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Packet loss rate [%]"
             prefix = "{}-loss-{}".format(comm, cmd)
             self.extract(logs, prefix, cmd)
             if len(logs.keys()) > 1:
                 plotter.lostPackets("{}-lost-packets".format(prefix), cmd,
                                     xlabel)
                 plotter.firstReceived("{}-first-received".format(prefix),
                                       cmd, xlabel)
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #21
0
 def limit(self, comm, limits, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for limit in limits:
         tid = "{}-limit-{:04d}kbit".format(comm, limit)
         tc = "tbf rate {}kbit burst 32kbit latency 500ms".format(limit)
         title = "Limit {}kbit ({})".format(limit, comm.upper())
         self.run(comm, tid, tc, title, limit, skip, logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Throughput limit [kbit]"
             prefix = "{}-limit-{}".format(comm, cmd)
             self.extract(logs, prefix, cmd)
             if len(logs.keys()) > 1:
                 plotter.lostPackets("{}-lost-packets".format(prefix), cmd,
                                     xlabel)
                 plotter.firstReceived("{}-first-received".format(prefix),
                                       cmd, xlabel)
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #22
0
 def reorder(self, comm, reorders, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for reorder in reorders:
         tid = "{}-reorder-{:02d}".format(comm, reorder)
         tc = "netem reorder {}% delay 25ms".format(reorder)
         title = "Reorders {}% ({})".format(reorder, comm.upper())
         self.run(comm, tid, tc, title, reorder, skip, logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Reordering rate [%]"
             prefix = "{}-reorder-{}".format(comm, cmd)
             self.extract(logs, prefix, cmd)
             if len(logs.keys()) > 1:
                 plotter.lostPackets("{}-lost-packets".format(prefix), cmd,
                                     xlabel)
                 plotter.firstReceived("{}-first-received".format(prefix),
                                       cmd, xlabel)
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #23
0
 def delay(self, comm, delays, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for delay in delays:
         tid = "{}-delay-{:04d}".format(comm, delay)
         tc = "netem delay {}ms".format(delay)
         title = "Delay {}ms ({})".format(delay, comm.upper())
         self.run(comm, tid, tc, title, delay, skip, logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Packet delay [ms]"
             prefix = "{}-delay-{}".format(comm, cmd)
             self.extract(logs, prefix, cmd)
             if len(logs.keys()) > 1:
                 plotter.lostPackets("{}-lost-packets".format(prefix), cmd,
                                     xlabel)
                 plotter.firstReceived("{}-first-received".format(prefix),
                                       cmd, xlabel)
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #24
0
 def duplication(self, comm, dups, skip, mean):
     logs = Logs()
     plotter = Plotter()
     for dup in dups:
         tid = "{}-duplication-{:02d}".format(comm, dup)
         tc = "netem duplicate {}%".format(dup)
         title = "Duplication {}% ({})".format(dup, comm.upper())
         self.run(comm, tid, tc, title, dup, skip, logs, mean)
     if len(logs.keys()) > 0:
         for cmd in self.commands:
             xlabel = "Duplication rate [%]"
             prefix = "{}-duplication-{}".format(comm, cmd)
             self.extract(logs, prefix, cmd)
             if len(logs.keys()) > 1:
                 plotter.lostPackets("{}-lost-packets".format(prefix), cmd,
                                     xlabel)
                 plotter.firstReceived("{}-first-received".format(prefix),
                                       cmd, xlabel)
                 plotter.throughput("{}-throughput".format(prefix), cmd,
                                    xlabel)
                 plotter.latency("{}-latency".format(prefix), cmd, xlabel)
Пример #25
0
def excluinoticia():

    valida = ValidaUser()
    retorno = valida.validaPermissao("noticias", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    noticias = Noticias()
    imagens = Imagens()

    noticias.id = request.form['Id']
    imagens.Post_ID = noticias.id

    imagens.DeleteImagem()

    noticias.excluinoticia()

    logs = Logs()
    logs.logadorInfo("Noticia excluida com sucesso: " + noticias.id)

    return redirect(url_for('noticias.listanoticias'))
Пример #26
0
def Updatenoticia():

    valida = ValidaUser()
    retorno = valida.validaPermissao("noticias", session['tipo'])

    if retorno != True:
        return redirect(url_for('home.index', msg="User_sem_Permissão"))

    noticias = Noticias()
    imagens = Imagens()

    noticias.id = request.form['PostId']
    imagens.Post_ID = noticias.id
    noticias.Titulo = request.form['Titulo']
    noticias.Conteudo = request.form['Conteudo']
    noticias.UserPostId = session['id']
    noticias.DataInicial = request.form['DataInicial']
    noticias.DataFinal = request.form['DataFinal']

    if 'imgoptions' in request.form:
        rmvimg = request.form['imgoptions']
    else:
        rmvimg = "nova"

    if rmvimg == "remove":
        imagens.nullImagem()

    elif rmvimg == "nova":
        imagens.imagem = "data:" + request.files[
            'imagem'].content_type + ";base64," + str(
                base64.b64encode(request.files['imagem'].read()), "utf-8")
        imagens.UpdateImagem()

    noticias.updateNoticia()

    logs = Logs()
    logs.logadorInfo("Noticia Editada com sucesso: " + noticias.id)

    return redirect(url_for('noticias.listanoticias'))
Пример #27
0
class Ui_MainWindow(QMainWindow):
    # Initializes logging, useful for not crowding the terminal with output
    log = Logs().getLog()

    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.setupUi()

    def setupUi(self):

        self.setObjectName("MainWindow")
        self.resize(960, 540)
        self.centralwidget = QWidget(self)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout = QHBoxLayout(self.centralwidget)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.graphicsView = DuckieGraphicsView(self.centralwidget)
        self.graphicsView.setObjectName("graphicsView")
        self.verticalLayout.addWidget(self.graphicsView)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(QRect(0, 0, 943, 24))
        self.menubar.setObjectName("menubar")
        self.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        QMetaObject.connectSlotsByName(self)

        self.timer = QTimer()
        self.timer.timeout.connect(self.graphicsView.update)
        self.timer.start(10)

    def Run(self):
        self.graphicsView.update()
Пример #28
0
    def __init__(self, database_filename=None):
        self.log = Logs().getLog()

        if (database_filename != None):
            self.database_filename = database_filename
        else:
            self.database_filename = "test.db"

        init_database = True if (
            not os.path.exists(self.database_filename)
            or not os.path.getsize(self.database_filename) > 0) else False
        # path can equal either :memory: or a database file
        try:
            self.conn = sqlite3.connect(self.database_filename,
                                        isolation_level=None,
                                        check_same_thread=False)
            self.conn.row_factory = sqlite3.Row
        except Error as e:
            print(e)
            self.conn.close()
            exception_string = "Connection to database failed. Closing..."
            # self.log.exception( exception_string )
            raise Exception(exception_string)
Пример #29
0
 def __init__(self, *args):
     self.log = Logs().getLog()
     super().__init__(*args)
     self.trackingScene = DuckieTrackingScene(self, self.log)
     self.setScene(self.trackingScene)
     self.show()
Пример #30
0
 def __init__(self):
     self.notif = Notification()
     self.log = Logs()
     self.bloodBank = BloodBank()