Ejemplo n.º 1
0
def likePost(browser, count, actions, tags, MaxSkip):

#pragma regiom Check if post embed has closed

    if browser.current_url == 'https://www.instagram.com/explore/tags/' + tags + '/':
        postLocation = browser.find_elements_by_xpath('//*[@class="_9AhH0"]')
        postLocation[MaxSkip].click()
        QThread.sleep(3)

#pragma regionend

#pragma Like / check if liked

    try:
        browser.find_element_by_xpath('//*[@aria-label="Unlike"]')
        print('Post already liked.')
        QThread.sleep(2)
        actions.perform()
        QThread.sleep(3)
        return count
    except:
        # Like photo
        browser.find_element_by_xpath('//*[@aria-label="Like"]').click()
        count += 1

#pragma endregion

#pragma region Move to next post

    QThread.sleep(3)
    print('Post liked successfully. ' + str(count) + ' post(s) in total.')
    actions.perform()
    QThread.sleep(2)
    return count
Ejemplo n.º 2
0
    def run(self):
        while not self.isOver:
            # 抓取视频
            status, img = self.dev.read()

            if not status:
                self.dev.release()
                self.exit(0)

            if self.isSave:
                img = self.ai.handle_image(img)

                if self.ai.n >= 50:
                    self.isSave = False

                img = FontZh().draw_text(img, (10, 20),
                                         F"采集中: {self.ai.n: 03d}", 20,
                                         (0, 0, 255))

            else:
                img = FontZh().draw_text(img, (10, 20), F"停止采集", 20,
                                         (0, 0, 255))

            # 发送信号给窗体显示视频
            self.sign_show.emit(img.shape[0], img.shape[1], img.shape[2],
                                img.tobytes())
            QThread.sleep(0.5)
Ejemplo n.º 3
0
    def run(self):
        while not self.cam.is_open():
            print("can't open")
            self.cam.open(0)

        frame_index = 0
        while not self.video_player.video_name:
            QThread.sleep(1)
            print("sleep...")

        video_name = self.video_player.video_name
        while True:
            self.mut.lock()
            ret, frame = self.cam.get_frame()
            self.mut.unlock()
            if not ret:
                print("can not read from camera")
                break
            frame = cv2.resize(frame, (320, 240))
            # try:

            is_good, yaw, pitch, roll = self.hp_detector.detect(
                frame, frame_index, self.video_player.get_position(),
                self.video_player.get_video_id(), self.user_id,
                self.video_player.is_paused())

            self.signal.emit(
                dict(is_good=is_good,
                     yaw=yaw,
                     pitch=pitch,
                     roll=roll,
                     frame=frame))
Ejemplo n.º 4
0
 def do_work(self):
     timer = time()
     while True:
         QThread.sleep(30)
         if time() - timer >= self.cycle:
             self.out_signal.emit()
             timer = time()
Ejemplo n.º 5
0
    def run(self):
        platform = get_platform()

        while self.is_running:
            try:
                self.download_url = self.get_download_url()
                commit = self.download_url.split('-', )[2]
                new_version = True

                if self.parent.layouts:
                    if (commit in self.parent.layouts[0].git
                            or commit in self.parent.progressBar.text()):
                        new_version = False

                if new_version:
                    datetime = self.get_commit_datetime(commit)

                    if platform == 'Windows':
                        locale.setlocale(locale.LC_ALL, 'eng_usa')
                    elif platform == 'Linux':
                        locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

                    self.strptime = time.strptime(datetime,
                                                  '%a, %d %b %Y %H:%M:%S %z')
                    strftime = time.strftime("%d-%b-%H:%M", self.strptime)
                    info = urlopen(self.download_url).info()
                    size = str(int(info['content-length']) // 1048576) + " MB"
                    display_name = "Git-" + commit + " | " + strftime + " | " + size
                    self.new_version_obtained.emit(display_name)
            except urllib.error.URLError as e:
                print(e)

            QThread.sleep(600)

        return
Ejemplo n.º 6
0
def scan():
    app = QtWidgets.QApplication(sys.argv)
    from pymodaq.daq_scan.daq_scan_main import DAQ_Scan

    splash_path = os.path.join(
        os.path.split(__file__)[0], 'daq_scan', 'splash.png')
    splash = QtGui.QPixmap(splash_path)
    if splash is None:
        print('no splash')
    splash_sc = QtWidgets.QSplashScreen(
        splash, Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)

    splash_sc.show()
    QtWidgets.QApplication.processEvents()
    splash_sc.raise_()
    splash_sc.showMessage('Loading Main components', color=Qt.white)
    QtWidgets.QApplication.processEvents()

    win = QtWidgets.QMainWindow()
    win.setVisible(False)
    area = DockArea()
    win.setCentralWidget(area)
    win.resize(1000, 500)
    win.setWindowTitle('pymodaq Scan')

    # win.setVisible(False)
    prog = DAQ_Scan(area)
    QThread.sleep(0)
    win.show()
    splash_sc.finish(win)
    sys.exit(app.exec_())
Ejemplo n.º 7
0
    def run(self):
        found= False
        for reader in readers():
            try:
                connection = reader.createConnection()
                connection.connect()
                ATR = toHexString(connection.getATR())
                APDU = [0xFF,0xCA,0x00,0x00,0x00]
                data, sw1, sw2 = connection.transmit(APDU)
                UID= toHexString(data)
            except NoCardException:
                print(reader, 'no card inserted')

            except:
                self.signals.error.emit((reader, 'error !!'))

            else:
                found= True
                self.signals.result.emit(UID)

            finally:
                QThread.sleep(2)
        if(found):
            self.signals.finished.emit()
        else:
            self.signals.error.emit((reader,'aucune carte à proximité ou insérée !!!'))
Ejemplo n.º 8
0
 def do_work(self):
     i = 1
     while self.continue_run:  # give the loop a stoppable condition
         print(i)
         QThread.sleep(1)
         i = i + 1
     self.finished.emit()  # emit the finished signal when the loop is done
Ejemplo n.º 9
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.resize(1400, 800)
        self.setWindowTitle('Light Seeker')

        self.menuBar()
        self.menu_bar()

        self.output = NewTable.OutputTable()
        self.input = NewTable.InputTable()

        spliter = QSplitter(self)
        spliter.addWidget(self.output)
        spliter.addWidget(self.input)
        spliter.setOrientation(Qt.Horizontal)
        self.setCentralWidget(spliter)

        QThread.sleep(1)
        self.show()

        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
Ejemplo n.º 10
0
 def commit(self):
     try:
         self.session.commit()
     except Exception as e:
         QThread.sleep(10)
         if self.logger:
             self.logger.error(e)
Ejemplo n.º 11
0
    def runtest(self):
        try:
            self.set_value()
            logger.info(str(ctime()))
            newDir = "testresult/log-" + datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
            os.mkdir(newDir)
            QThread.sleep(1)
            self.ThreadStress.reportfile = newDir + '/Report.html'
            self.logthread.reportdir = newDir
            # Testcase.LOG_Switch = True
            self.ThreadStress.treeWidget = self.treeWidget
            self.checkProcess = QProgressDialog()
            self.checkProcess.setFont(self.font)
            
            self.checkProcess.setCancelButtonText("Close")
            self.checkProcess.setWindowTitle("Device checking...")
            
            self.checkDevice.Process.connect(self.checkProcess.setValue)
            self.checkDevice.FindDevice.connect(self.checkProcess.close)
            self.checkProcess.resize(400, 150)
            self.checkDevice.start()
            self.checkProcess.exec_()

            # self.TestTable.sinOutLog.connect(self.exportlog)
            # self.TestTable.sinOutProcess.connect(self.set_BarProcess)

        except Exception as err:
            # logger.error(str(err))
            traceback.print_exc()
Ejemplo n.º 12
0
def watchStoriesFromAccount(browser, targetAccount, TargetAmount):

    pageMovement = ActionChains(browser)
    pageMovement.send_keys(Keys.ARROW_RIGHT)
    acc_count = 0

    try:
        while acc_count < len(targetAccount):
            browser.get('https://www.instagram.com/' +
                        targetAccount[acc_count] + '/')
            QThread.sleep(5)
            browser.find_element_by_xpath(
                "//a[contains(@href,'/follower')]").click()
            QThread.sleep(5)

            count = 0
            while count < TargetAmount:
                count = WatchStoriesAction.watchStoriesAction(
                    browser, count, targetAccount[acc_count], pageMovement)

            if count == TargetAmount:
                print('Done returning to instagram...')
                browser.get('https://www.instagram.com')
                acc_count += 1
    except:
        print('Account is private or does not exist. Exiting')
        browser.get('https://www.instagram.com')
Ejemplo n.º 13
0
def main():
    # define command line parameters
    parser = ArgumentParser()
    parser.add_argument("--no-splash", dest="splash", action="store_false")
    args = parser.parse_args()

    app = QApplication(sys.argv)

    # create splash screen with sponsors
    # default splash=True, use "-s" or "--splash" to set splash=False
    window = MainWindow()
    if args.splash:
        pixmap = QPixmap(os.path.join("resources","splash", "splash.jpg"))
        splash = QSplashScreen(pixmap)
        splash.showMessage("  Version: " + __version__, Qt.AlignBottom)

        # show the splash screen for 3 seconds
        splash.show()
        app.processEvents()
        QThread.sleep(3)
        window.show()
        splash.finish(window)
    else:
        window.show()

    sys.exit(app.exec())
Ejemplo n.º 14
0
    def on_thing_requested(self, thing, callback):
        if self.quit:
            self.sig_thing_finished.emit("aborted-" + thing + "-Work", callback)
            return

        QThread.sleep(1)
        self.sig_thing_finished.emit(thing + "-Work", callback)
Ejemplo n.º 15
0
    def run(self):
        while self.is_running:
            try:
                self.download_url = self.get_download_url()
                commit = self.download_url.split('-', )[-2]
                new_version = True

                if self.parent.layouts:
                    if (commit in self.parent.layouts[0].git
                            or commit in self.parent.progressBar.text()):
                        new_version = False

                if new_version:
                    datetime = self.get_commit_datetime(commit)
                    self.strptime = time.strptime(datetime,
                                                  '%a, %d %b %Y %H:%M:%S %z')
                    strftime = time.strftime("%d-%b-%H:%M", self.strptime)
                    info = urlopen(self.download_url).info()
                    size = str(int(info['content-length']) // 1048576) + " MB"
                    display_name = "Git-" + commit + " | " + strftime + " | " + size
                    self.new_version_obtained.emit(display_name)
            except urllib.error.URLError as e:
                print(e)

            print("Check For Updates")
            QThread.sleep(60)

        return
Ejemplo n.º 16
0
    def run(self):
        # Start working timer
        working_length = 60 * self.working
        label = "Working"
        self.change_label.emit(label)

        while working_length > 0:
            mins, seconds = divmod(working_length, 60)

            time_left = str(mins).zfill(2) + ":" + str(seconds).zfill(2)
            QThread.sleep(1)
            working_length -= 1
            self.change_time.emit(time_left)

        winsound.PlaySound(self._end_sound, winsound.SND_FILENAME)

        # Star resting timer
        rest_length = 60 * self.resting
        label = "Resting"
        self.change_label.emit(label)
        while rest_length > 0:
            mins, seconds = divmod(rest_length, 60)

            time_left = str(mins).zfill(2) + ":" + str(seconds).zfill(2)
            QThread.sleep(1)
            rest_length -= 1
            self.change_time.emit(time_left)

        winsound.PlaySound(self._end_sound, winsound.SND_FILENAME)
Ejemplo n.º 17
0
def LikePost(browser, Max, tags):

    #pragma region Pagemovement Setup

    pageMovement = ActionChains(browser)
    pageMovement.send_keys(Keys.ARROW_RIGHT)

    #pragma endregion

    #pragma region Actions
    browser.get('https://www.instagram.com/explore/tags/' + tags + '/')
    QThread.sleep(3)

    #pragma region Setting Values

    print('Currently Liking ' + str(Max) + ' photos!')
    #pragma endregion

    #pragma region Start Liking
    count = 0
    while count < Max:
        count = LikeAction.likePost(browser, count, pageMovement, tags, 10)

    if (count == Max):
        print("done!")
Ejemplo n.º 18
0
    def run(self):
        self.started.emit()
        subfolders = self.get_subfolders()

        while self.parent:
            new_subfolders = self.get_subfolders()

            if subfolders != new_subfolders:
                if len(new_subfolders) > len(subfolders):
                    for sub in new_subfolders:
                        if sub not in subfolders:
                            print("New -> " + sub)
                elif len(new_subfolders) < len(subfolders):
                    for sub in subfolders:
                        if sub not in new_subfolders:
                            print("Deleted -> " + sub)
                else:
                    for sub in new_subfolders:
                        if sub not in subfolders:
                            print("Changed -> " + sub)

                subfolders = new_subfolders

            QThread.sleep(3)

        return
Ejemplo n.º 19
0
    def on_thing_requested(self, thing, callback):
        if self.quit:
            self.sig_thing_finished.emit("aborted-" + thing + "-Work",
                                         callback)
            return

        QThread.sleep(1)
        self.sig_thing_finished.emit(thing + "-Work", callback)
Ejemplo n.º 20
0
    def do_work(self):

        for i in range(30):

            if not self.stopped:
                print('running . . .')
                self.incremented.emit(str(i))
                QThread.sleep(1)
Ejemplo n.º 21
0
    def func(self):

        while True:
            x = randint(10, 450)
            y = randint(10, 150)
            self.btn_ClickMe.move(x, y)
            print("rwtest")
            QThread.sleep(1)
Ejemplo n.º 22
0
 def do_work(self):
     counter = 0
     while True:
         counter += 1
         print('running . . .')
         QThread.sleep(2)
         if counter == 5:
             self.call_window()
Ejemplo n.º 23
0
 def run(self):
     print('thread id', QThread.currentThread())
     for i in range(1, 101):
         if self.isInterruptionRequested():
             break
         print('value', i)
         self.valueChanged.emit(i)
         QThread.sleep(1)
Ejemplo n.º 24
0
    def do_work(self):
        i = 0
        while self.continue_run:
            i += 1
            # noinspection PyCallByClass
            QThread.sleep(1)
            self.out_signal[str].emit(str(i))  # and need details here

        self.finished.emit()  # emit the finished signal when the loop is done
Ejemplo n.º 25
0
 def run(self):
     flag = True
     while flag:
         count = self.pool.activeThreadCount()
         if count <= 0:  # 打包完成,发完成信号,重置flag,终止线程
             self.signal.emit()
             flag = False
         else:  # 打包进行中,线程休眠
             QThread.sleep(3)
Ejemplo n.º 26
0
    def run(self):
        self.pre_run(False)

        while self.running:
            self.model.dut_exist = self.check_dut()

            QThread.sleep(1)

        self.post_run(False)
Ejemplo n.º 27
0
 def run(self):
     try:
         self.handle = ctypes.windll.kernel32.OpenThread(  # @UndefinedVariable
             win32con.PROCESS_ALL_ACCESS, False, int(QThread.currentThreadId()))
     except Exception as e:
         print('get thread handle failed', e)
     print('thread id', int(QThread.currentThreadId()))
     for i in range(1, 101):
         print('value', i)
         self.valueChanged.emit(i)
         QThread.sleep(1)
Ejemplo n.º 28
0
 def read_data_fast(self):
     """Polls the file for new data by attempting another read, keeping the file handle open (fast)"""
     done = False
     with self.fs.open(self.filename) as file:
         (done, line_start) = self.read_lines(file)
         while not done:
             # try to read new data after a while. need to restore read position when there's
             # no new line to read, to cope with incomplete lines (while they're being written)
             QThread.sleep(self.poll_time)
             file.seek(line_start)
             (done, line_start) = self.read_lines(file)
Ejemplo n.º 29
0
 def run(self):
     try:
         time_sum = -5  #Five seconds of delay
         while (self.targettime > time_sum):
             QThread.sleep(self.steptime)
             time_sum = time_sum + 0.9 * self.steptime
             timeL = int(100 * (time_sum / self.targettime))
             if timeL > 0 and timeL < 100:
                 self.timeleft.emit(timeL)
     except:
         self.timeleft.emit(-1)
Ejemplo n.º 30
0
Archivo: TSA.py Proyecto: watroba/senti
 def run(self):
     while True:
         for key in counties.od:
             lat = counties.od[key][3]
             long = counties.od[key][4]
             GEO = str(lat)+','+str(long)+','+str(self.radius)+self.unit
             moodVal = self._get_mood_per_county(GEO)
             #print(moodVal[0])
             self.update_Label.emit(counties.od[key][0],moodVal,
                       (self.Vavg/self.i,self.Aavg/self.i,self.Davg/self.i))
             QThread.sleep(1)
Ejemplo n.º 31
0
 def commit(self):
     """
     sqlite commit, avoid sqlite commit lock
     :return:
     """
     try:
         self.session.commit()
     except Exception as e:
         QThread.sleep(10)
         if self.logger:
             self.logger.error(e)
 def run(self):
     self.connecting = True
     while self.connecting:
         QThread.sleep(1)
         try:
             self.core.connect("MaidFiddlerService")
             if self._connected():
                 print("Connected!")
                 return
         except Exception as e:
             print(f"Failed to connect because {e}! Retrying in a second!")
             self.connection_reset.emit()