Ejemplo n.º 1
0
 def data_allocation(self):
     if self.n_file != self.file:
         try:
             info = self.player.getVideoInfoTag()
             self.location = info.getTitle()
             self.poi = ast.literal_eval(info.getPlot())
             self.timeOfDay = info.getTagLine()
             self.key_list = list()
             self.file = self.n_file
             self.changing = False
             for i in sorted(self.poi.iterkeys(), key=int):
                 self.key_list.append(i)
         except Exception as err:
             c.beta(err)
     try:
         if self.key_list != "":
             if int(self.t) > int(self.key_list[0]):
                 self.label.setLabel(self.poi["%s" % self.key_list[0]])
                 j = t(target=self.counter)
                 j.start()
                 del self.key_list[0]
     except Exception as err:
         c.log(err)
         try:
             if self.label.getLabel() != self.location:
                 if self.poi == "" or self.poi == None:
                     self.label.setLabel(self.location)
                     j = t(target=self.counter)
                     j.start()
         except:
             pass
     return
Ejemplo n.º 2
0
 def look(self):
         self.ifname = ifaddr.get_adapters()
         self._get_ip()
         for ip in self.ips:
                 _1, _2, _3, _4 = ip.split('.')
                 for i in range(1,256):
                         ip = (f"{_1}.{_2}.{_3}.{i}", 33333)
                         t(target=self.connect, args=(ip)).start()
Ejemplo n.º 3
0
def start_threads (item):
	proxies = {
		"http"  :"http://{}".format(item['proxy']),
		"https" :"https://{}".format(item['proxy'])}

	t1 = t(target=thread_, args=(item['access_token'], proxies, item['id']))
	t1.start()
Ejemplo n.º 4
0
    def onAction(self, action):
        if action == 10 or action == 92:
            self.running = False
            self.player.stop()
            self.close()

        elif action == 100 or action == 103 or action == 7:
            j = t(target=self.counter)
            j.start()
        elif action == 1:
            if int(playlist.size()) == (int(playlist.getposition())+1):
                self.player.pause()
                self.changing = True
                self.file = "REPEATING"
                self.player.play(playlist, windowed=True)
            else:
                self.changing = True
                self.player.playprevious()
        elif action == 2:
            if int(playlist.size()) == (int(playlist.getposition())+1):
                self.player.pause()
                self.changing = True
                self.file = "REPEATING"
                self.player.play(playlist, windowed=True)
            else:
                self.changing = True
                self.player.playnext()
Ejemplo n.º 5
0
 def play_sequence(self):
     threads = []
     for notes in self.note_objects:
         #create a list of threads, and initialize all at same time
         self.threads.append(t(target = (lambda: NotePlayer().play_sequence(notes))))
     for thread in self.threads:
         thread.start()
Ejemplo n.º 6
0
def rodar_multithread(key_pipefy, CAMPOS, pipe_id):

    rs = []

    IDs = pegar_ids(key_pipefy, pipe_id)

    from threading import Thread as t
    threads = [t(target=run_init, args=(CAMPOS, rs, key_pipefy, pipe_id)) if id_fim == '' else t(target=run_mid, args=(id_fim, CAMPOS, rs, key_pipefy, pipe_id)) for id_fim in IDs]
    for t in threads: t.start()
    for t in threads: t.join()

    print('Aguardando threads')
    time.sleep(1)

    return rs
Ejemplo n.º 7
0
def listen():
    w = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        w.bind((host, main_port))
    except Exception as e:
        print e
        sys.exit()
        return

    w.listen(1)
    print 'Server listening on', str(main_port)
    while 1:
        conn, addr = w.accept()
        sender = t(target = datasender, args = (conn, addr))
        sender.start()
Ejemplo n.º 8
0
def scrap_synsuite_multithread(login, senha, path='.'):

    chromeOptions = webdriver.ChromeOptions() #inicializa o webdriver

    # nao baixar imagens e diretorio para download do chrome
    if path == '.':
        path_ = os.getcwd()
    else:
        path_ = path

    prefs = {'profile.managed_default_content_settings.images':2,
            'download.default_directory' : path_ + '/arquivos_synsuite'}

    chromeOptions.add_experimental_option("prefs", prefs)

    def scrap_unico(campo):
        driver = webdriver.Chrome(ChromeDriverManager().install(), options=chromeOptions)
        try:
            driver.get('https://synsuite.reweb.com.br/customized_reports') #acessa o synsuite

            # Login
            driver.find_element_by_xpath('//*[@id="UserLogin"]').send_keys(login)
            driver.find_element_by_xpath('//*[@id="UserPassword2"]').send_keys(senha)
            driver.find_element_by_xpath('//*[@id="UserLoginForm"]/button').click()

            time.sleep(10)


            driver.find_element_by_xpath('//*[@id="customized-reports-table"]/tbody/tr[{}]/td'.format(campo)).click()
            time.sleep(2)
            driver.find_element_by_xpath('//*[@id="download"]').click()
            time.sleep(2)
            try:
                driver.find_element_by_xpath('/html/body/div[4]/div[3]/div/button[1]').click()
            except:
                pass
            time.sleep(30)

            driver.close()
        except:
            driver.close()

    campos = [26, 27, 28, 29] #ordem dos relatorios a serem baixados

    from threading import Thread as t
    threads = [t(target=scrap_unico, args=(campo,)) for campo in campos]
    for t in threads: t.start()
    for t in threads: t.join()
Ejemplo n.º 9
0
"""
Python: Using threading
        Example 3
"""
import time
from threading import Thread as t


def sleeper(i):
    print("Thread {} sleeps for 5 seconds\n".format(i))
    time.sleep(5)
    print("Thread %d woke up\n".format(i))


if __name__ == '__main__':
    for i in range(10):
        t1 = t(target=sleeper, args=(i, ))
        t1.start()
Ejemplo n.º 10
0
def ahah():
	data.sort()
	for i in data:
			print(f'''Produk : {i[1]}
Harga  : Rp{i[0]}
Toko   : {i[3]}
URL    : \033[90m{i[2]}\033[0m
++++++++++++++++++++++++++++++++++++++
''')
	print(f'''####################################################
Harga terendah  : \033[92mRp{data[0][0]}\033[0m ({data[0][3]})
Harga tertinggi : \033[91mRp{data[-1][0]}\033[0m ({data[-1][3]})''')	
if __name__=='__main__':
	os.system('clear')
	print('''\033[95m
     _          \033[0m __       _ \033[95m
    |_)    |  _ \033[0m(_ |_  _ |_)\033[95m
    |_)|_| |<(_|\033[0m__)| |(_)|  \033[95mfb.me/om.karjok
    |\033[0mBukalapak x Shopee price sorter
    ''')
	q = input('Cari : ')
	tr = t(target=comp,name='tmp')
	tr.start()
	txt = ['   ','.  ','.. ','...']
	while tr.isAlive():
		for i in txt:
			print(f'\rSedang nyariin {q} buat kamu{i}',end=''),;sys.stdout.flush();time.sleep(0.5)
	
	print('\n')
	ahah()
Ejemplo n.º 11
0

def timer():
    global counter
    counter = 0.00
    while game:
        s(0.01)
        counter += 0.01


initBoard()

player = 1
game = True

t(target=timer).start()

while game:
    printBoard()
    col = input("\nPlayer " + str(player) + ": ")
    if str.isdigit(col):
        if int(col) >= 1 and int(col) <= 7:
            if board[0][int(col) - 1] == "  ":
                if board[1][int(col) - 1] == "  ":
                    if board[2][int(col) - 1] == "  ":
                        if board[3][int(col) - 1] == "  ":
                            if board[4][int(col) - 1] == "  ":
                                if board[5][int(col) - 1] == "  ":
                                    board[5][int(col) - 1] = "P" + str(player)
                                else:
                                    board[4][int(col) - 1] = "P" + str(player)
Ejemplo n.º 12
0

def fourth_page():
    index_ = 67965
    start_ = Requests_law_url(index_)
    while index_ <= 80000:
        index_ = index_
        start_.parse_url()
        index_ += 1


def fifth_page():
    index_ = 838292
    start_ = Requests_law_url(index_)
    while index_ <= 100000:
        start_.parse_url()
        index_ += 1


threads.append(t(target=third_page))
threads.append(t(target=fourth_page))
threads.append(t(target=fifth_page))

if __name__ == '__main__':
    try:
        for t in threads:
            t.start()
            time.sleep(3)
            # 防止过两秒重试造成的线程二无法启动
    except:
        print('出错。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。')
Ejemplo n.º 13
0
        logging.info('Connected to MQTT broker.')
    except Exception as e:
        logging.error(f'Unable to connect to MQTT broker: {e}')
        sys.exit()


if __name__ == '__main__':
    if MQTT_HOST == None:
        logging.error(
            'Please specify the IP address or hostname of your MQTT broker.')
        sys.exit()

    if LOG_LEVEL.lower() not in ['debug', 'info', 'warning', 'error']:
        logging.basicConfig(level='INFO',
                            format='%(asctime)s %(levelname)s: %(message)s')
        logging.warning(
            f'Selected log level "{LOG_LEVEL}" is not valid; using default')
    else:
        logging.basicConfig(level=LOG_LEVEL,
                            format='%(asctime)s %(levelname)s: %(message)s')

    client = mqtt.Client(f'battery2mqtt_{MQTT_TOPIC}')
    path = "/sys/class/power_supply/"
    dirs = os.listdir(path)
    b = Battery()

    b.check_conditions()
    mqtt_connect()
    polling_thread = t(target=b.get_info, daemon=True)
    polling_thread.start()
    client.loop_forever()
Ejemplo n.º 14
0
            meta = r.info()
            bufsize = meta.getheaders("Content-Length")[0]
            bufsize = int(bufsize)
        else:
            r = open(path)
            stat = os.stat(path)
            bufsize = stat.st_size

        bufsize = bufsize / track[3]
        bufsize = int(bufsize * sleeptime) + 100

        buf = r.read(bufsize)
        
        while buf != '':
            for port in ports:
                s.sendto(buf, (host, port))
            buf = r.read(bufsize)
            sleep(sleeptime)

        r.close()
        sleep(sleeptime)

listener = t(target = listen, args = ())
streamer = t(target = stream, args = ())

listener.start()
streamer.start()

listener.join()
streamer.join()