Esempio n. 1
0
 def do_login_tasks(self, email, passphrase):
     self.root.ids.wait_text.text = "Connecting.."
     server, port, proto = yield Task(nowallet.get_random_server, self.loop)
     connection = yield Task(nowallet.Connection, self.loop, server, port,
                             proto)
     #        connection = yield Task(
     #            nowallet.Connection, self.loop, "mdw.ddns.net", 50002, "s")
     self.root.ids.wait_text.text = "Deriving Keys.."
     self.wallet = yield Task(nowallet.Wallet,
                              email,
                              passphrase,
                              connection,
                              self.loop,
                              self.chain,
                              bech32=self.bech32)
     self.root.ids.wait_text.text = "Fetching history.."
     yield Task(self.wallet.discover_all_keys)
     self.root.ids.wait_text.text = "Fetching exchange rates.."
     self.exchange_rates = {"btcav": {"USD": 12000.0}}
     #        self.exchange_rates = yield Task(self.loop.run_until_complete,
     #            fetch_exchange_rates(self.chain.chain_1209k))
     self.root.ids.wait_text.text = "Getting fee estimate.."
     coinkb_fee = yield Task(self.wallet.get_fee_estimation)
     self.current_fee = self.estimated_fee = \
         nowallet.Wallet.coinkb_to_satb(coinkb_fee)
Esempio n. 2
0
 def on_button_click(self, *args):
     self.status_label.setText("Downloading image...")
     # Run single task in separate thread
     image_data = yield Task(
         self.load_url, "http://www.google.com/images/srpr/logo4w.png")
     pixmap = QtGui.QPixmap.fromImage(QtGui.QImage.fromData(image_data))
     self.image_label.setPixmap(pixmap)
     self.status_label.setText("Downloading pages...")
     urls = [
         'http://www.google.com', 'http://www.yandex.ru',
         'http://www.python.org'
     ]
     # Run multiple task simultaneously in thread pool
     pages = yield [Task(self.load_url, url) for url in urls]
     self.status_label.setText("Done")
     avg_size = sum(map(len, pages)) / len(pages)
     self.result_label.setText("Average page size: %s" % avg_size)
Esempio n. 3
0
 def cpu_bound(self, event):
     t = time.time()
     self.status.SetLabel("calculating...")
     prime_flags = yield MultiProcessTask(
         [Task(is_prime, n) for n in PRIMES])
     print time.time() - t
     text = '\n'.join("%s: %s" % (n, prime)
                      for n, prime in zip(PRIMES, prime_flags))
     self.status.SetLabel(text)
Esempio n. 4
0
 def check_primes(self, checked):
     t = time.time()
     self.status_label.setText("Checking primes...")
     prime_flags = yield MultiProcessTask(
         [Task(is_prime, n) for n in PRIMES], )
     self.status_label.setText("Elapsed: %.3f seconds" % (time.time() - t))
     text = '\n'.join("%s: %s" % (n, prime)
                      for n, prime in zip(PRIMES, prime_flags))
     self.result_label.setText(text)
Esempio n. 5
0
 def cpu_bound(self):
     t = time.time()
     self.status[0]["text"] = "calculating..."
     prime_flags = yield MultiProcessTask(
         [Task(is_prime, n) for n in PRIMES])
     print(time.time() - t)
     text = '\n'.join("%s: %s" % (n, prime)
                      for n, prime in zip(PRIMES, prime_flags))
     self.status[0]["text"] = text
Esempio n. 6
0
    def load_anime_list(self, db_file, home_anime_list):

        db = TinyDB(db_file)
        anime_db = db.all()
        Anime = Query()

        print(home_anime_list)

        if len(anime_db) < 1 and len(home_anime_list.children) < 1:
            print('im here')
            get_started = MDAccordionItem()
            get_started.icon = 'help'
            get_started.title = "This is where you're watchlist will show."
            home_anime_list.add_widget(get_started)
            navigate_to_crit = MDAccordionSubItem(parent_item= get_started, text='Get started by going to the criterea selection screen!')
            # navigate_to_crit.on_release = functools.partial(self.navigate, 'criterea_selection')
            get_started.add_widget(navigate_to_crit)

        for anime in anime_db:
            print('processing ' + anime["romaji_name"])
            self.download_image(anime["image"], anime["romaji_name"])

            start_fetching_episodes_from =  0
            episodes_out = anime["episodes_out"]
            if(episodes_out is None):
                episodes_out = 0

            if anime["romaji_name"] not in Global.ANIME_LIST:
                print('Gonna start then')
                anime_item = MDAccordionItem()
                anime_item.icon = 'movie'
                anime_item.title = anime["romaji_name"]
                home_anime_list.add_widget(anime_item)
                #can skip if anime isnt airing (for future season expansions)

                if anime["airing"]:
                    current_episode = yield Task(functools.partial(anilist_api.get_next_airing_episode,anime["id"]))
                    print(current_episode)
                    if(current_episode is not None):
                        current_episode = current_episode - 1
                        print(anime["romaji_name"] + ' is on episode '+ str(current_episode) + ' | database shows '+ str(episodes_out))
                        if(current_episode != episodes_out):
                            print('changing db to match with eps')
                            db.update({'episodes_out': current_episode}, Anime.id == anime["id"])
                            episodes_out = current_episode

                if episodes_out > 50:
                    start_fetching_episodes_from = episodes_out - 50

                for episode in range(start_fetching_episodes_from, episodes_out):
                    anime_sub_item = MDAccordionSubItem(parent_item = anime_item, text = 'Episode ' + str(episode + 1))
                    anime_sub_item.on_release = functools.partial(self.open_episode_page_with_model, episode + 1, anime)
                    anime_item.add_widget(anime_sub_item)
                Global.ANIME_LIST.append(anime["romaji_name"])

        print(len(anime_db))
Esempio n. 7
0
 def open_episode_page_with_string(self, string, *_):
     print('aight lets go')
     Global.MAIN_WIDGET.ids.home.ids.home_spinner.active = True
     Snackbar(
         text="Fetching torrents for: "+ string, duration=2).show()
     self.ids.home_spinner.active = True
     yield Task(functools.partial(Global.EPISODE_PAGE_CLASS.search,string))
     self.manager.transition.direction = 'left'
     self.manager.current = 'ep_page'
     Global.MAIN_WIDGET.ids.home.ids.home_spinner.active = False
Esempio n. 8
0
 def open_episode_page_with_model(self, episode, anime, *_):
     print('aight lets go')
     Global.MAIN_WIDGET.ids.home.ids.home_spinner.active = True
     Snackbar(
         text="Fetching torrents for: "+ anime["romaji_name"]+ " Ep " + str(episode), duration=2).show()
     filename = "thumbnails/"+ anime["romaji_name"] + ".jpg"
     print(filename + ' is the image')
     self.ids.home_spinner.active = True
     yield Task(functools.partial(Global.EPISODE_PAGE_CLASS.search_with_episode,anime,episode,filename))
     self.manager.transition.direction = 'left'
     self.manager.current = 'ep_page'
     Global.MAIN_WIDGET.ids.home.ids.home_spinner.active = False
Esempio n. 9
0
    def do_login_tasks(self, email, passphrase):
        self.root.ids.wait_text.text = "Connecting.."

        server, port, proto = yield Task(self.loop.run_until_complete,
                                         nowallet.get_random_server(self.loop))
        connection = nowallet.Connection(self.loop, server, port, proto)
        yield Task(self.loop.run_until_complete, connection.do_connect())

        self.root.ids.wait_text.text = "Deriving Keys.."
        self.wallet = yield Task(nowallet.Wallet,
                                 email,
                                 passphrase,
                                 connection,
                                 self.loop,
                                 self.chain,
                                 bech32=self.bech32)

        self.root.ids.wait_text.text = "Fetching history.."
        yield Task(self.loop.run_until_complete,
                   self.wallet.discover_all_keys())

        self.root.ids.wait_text.text = "Fetching exchange rates.."
        self.exchange_rates = yield Task(
            self.loop.run_until_complete,
            fetch_exchange_rates(nowallet.BTC.chain_1209k))

        self.root.ids.wait_text.text = "Getting fee estimate.."
        coinkb_fee = yield Task(self.loop.run_until_complete,
                                self.wallet.get_fee_estimation())
        self.current_fee = self.estimated_fee = nowallet.Wallet.coinkb_to_satb(
            coinkb_fee)
        logging.info("Finished 'doing login tasks'")
Esempio n. 10
0
    def on_button_click(self, *args):
        t = time.time()
        self.status_label.setText("Downloading pages...")
        tasks = [Task(self.load_url, url) for url in self.urls]
        use_unordered = self.checkBoxUpdateWhenReady.isChecked()
        results = yield MultiTask(tasks, unordered=use_unordered,
                                  skip_errors=True)
        for url_result in results:
            row = self.url_to_row[url_result.url]
            size_item = QtGui.QTableWidgetItem(str(len(url_result.data)))
            elapsed_item = QtGui.QTableWidgetItem("%.2f" % url_result.elapsed)
            self.urls_table.setItem(row, 1, size_item)
            self.urls_table.setItem(row, 2, elapsed_item)

        self.status_label.setText("Done (%.3f seconds)" % (time.time() - t))
Esempio n. 11
0
    def set_anime_from_criterea(self, *_):
        if not self.number_validation_sanitation():
            return

        self.ids.spinner.active = True
        current_releasing_anime = yield Task(anilist_api.get_releasing_anime)

        anime_models = []
        for anime in current_releasing_anime:
            anime_m = Anime(anime)
            anime_models.append(anime_m)

        filtered_anime_models = self.filter_anime(anime_models)
        self.anime_confirmation(filtered_anime_models)

        self.ids.spinner.active = False
Esempio n. 12
0
 def async_gen():
     answer = yield [Task(task_func, i) for i in range(N)]
     self.assertEquals(answer, list(range(N)))
     called[0] = True
     quit_func()
Esempio n. 13
0
 def async_request(self, func, **kwargs):
     yield Task(self.do, func, **kwargs)
Esempio n. 14
0
 def do_listen_task(self):
     yield Task(self.loop.run_until_complete,
                self.wallet.listen_to_addresses())
     logging.info("Listening for new transactions.")
Esempio n. 15
0
 def do_listen_task(self):
     yield Task(self.listen_task)