Ejemplo n.º 1
0
 def buy(self, product_id):
     pass
     try:
         log.info(
             f"Stock Check {product_id} at {self.interval} second intervals."
         )
         while not self.is_in_stock(product_id):
             self.attempt = self.attempt + 1
             time_delta = str(datetime.now() -
                              self.started_at).split(".")[0]
             with Spinner.get(
                     f"Stock Check ({self.attempt}, have been running for {time_delta})..."
             ) as s:
                 sleep(self.interval)
         if self.enabled:
             cart_success, cart_url = self.get_cart_url(product_id)
             if cart_success:
                 log.info(f"{self.gpu_long_name} added to cart.")
                 self.enabled = False
                 webbrowser.open(cart_url)
                 self.notification_handler.send_notification(
                     f" {self.gpu_long_name} with product ID: {product_id} in "
                     f"stock: {cart_url}")
             else:
                 self.buy(product_id)
     except Timeout:
         log.error("Had a timeout error.")
         self.buy(product_id)
Ejemplo n.º 2
0
 def buy(self, product_id):
     try:
         log.info(
             f"Checking stock for {product_id} at {self.interval} second intervals."
         )
         while not self.add_to_cart(product_id) and self.enabled:
             self.attempt = self.attempt + 1
             time_delta = str(datetime.now() -
                              self.started_at).split(".")[0]
             with Spinner.get(
                     f"Still working (attempt {self.attempt}, have been running for {time_delta})..."
             ) as s:
                 sleep(self.interval)
         if self.enabled:
             self.apply_shopper_details()
             if self.auto_buy_enabled:
                 self.notification_handler.send_notification(
                     f" {self.gpu_long_name} with product ID: {product_id} available!"
                 )
                 log.info("Auto buy enabled.")
                 # self.submit_cart()
                 self.selenium_checkout()
             else:
                 log.info("Auto buy disabled.")
                 cart_url = self.open_cart_url()
                 self.notification_handler.send_notification(
                     f" {self.gpu_long_name} with product ID: {product_id} in stock: {cart_url}"
                 )
             self.enabled = False
     except Timeout:
         log.error("Had a timeout error.")
         self.buy(product_id)
Ejemplo n.º 3
0
 def buy(self, product_id):
     try:
         log.info(
             f"Stock Check {product_id} at {self.interval} second intervals."
         )
         while not self.is_in_stock(product_id):
             self.attempt = self.attempt + 1
             time_delta = str(datetime.now() -
                              self.started_at).split(".")[0]
             with Spinner.get(
                     f"Stock Check ({self.attempt}, have been running for {time_delta})..."
             ) as s:
                 sleep(self.interval)
         if self.enabled:
             cart_success = self.add_to_cart(product_id)
             if cart_success:
                 log.info(f"{self.gpu_long_name} added to cart.")
                 self.enabled = False
                 webbrowser.open(NVIDIA_CART_URL)
                 self.notification_handler.send_notification(
                     f" {self.gpu_long_name} with product ID: {product_id} in "
                     f"stock: {NVIDIA_CART_URL}")
             else:
                 self.notification_handler.send_notification(
                     f" ERROR: Attempted to add {self.gpu_long_name} to cart but couldn't, check manually!"
                 )
                 self.buy(product_id)
     except requests.exceptions.RequestException as e:
         log.warning(
             "Connection error while calling Nvidia API. API may be down.")
         log.info(
             f"Got an unexpected reply from the server, API may be down, nothing we can do but try again"
         )
         self.buy(product_id)
Ejemplo n.º 4
0
 def buy(self, product_id):
     try:
         log.info(f"Stock Check {product_id} at {self.interval} second intervals.")
         while not self.is_in_stock(product_id):
             self.attempt = self.attempt + 1
             time_delta = str(datetime.now() - self.started_at).split(".")[0]
             with Spinner.get(
                 f"Stock Check ({self.attempt}, have been running for {time_delta})..."
             ) as s:
                 sleep(self.interval)
         if self.enabled:
             cart_success, cart_url = self.get_cart_url(product_id)
             if cart_success:
                 log.info(f"{self.gpu_long_name} added to cart.")
                 self.enabled = False
                 webbrowser.open(cart_url)
                 self.notification_handler.send_notification(
                     f" {self.gpu_long_name} with product ID: {product_id} in "
                     f"stock: {cart_url}"
                 )
             else:
                 self.buy(product_id)
     except requests.exceptions.RequestException as e:
         self.notification_handler.send_notification(
             f"Got an unexpected reply from the server, API may be down, nothing we can do but try again"
         )
         self.buy(product_id)
Ejemplo n.º 5
0
 def buy(self, product_id, delay=3):
     log.info(
         f"Checking stock for {product_id} at {delay} second intervals.")
     while not self.add_to_cart(product_id) and self.enabled:
         with Spinner.get("Still working...") as s:
             sleep(delay)
     if self.enabled:
         self.apply_shopper_details()
         if self.auto_buy_enabled:
             self.notification_handler.send_notification(
                 f" {self.gpu_long_name} with product ID: {product_id} available!"
             )
             log.info("Auto buy enabled.")
             # self.submit_cart()
             self.selenium_checkout()
         else:
             log.info("Auto buy disabled.")
             cart_url = self.open_cart_url()
             self.notification_handler.send_notification(
                 f" {self.gpu_long_name} with product ID: {product_id} in stock: {cart_url}"
             )
         self.enabled = False
Ejemplo n.º 6
0
 def buy(self, product_id):
     pass
     try:
         log.info(
             f"Checking stock for {product_id} at {self.interval} second intervals."
         )
         while not self.is_in_stock(product_id) and self.enabled:
             self.attempt = self.attempt + 1
             time_delta = str(datetime.now() - self.started_at).split(".")[0]
             with Spinner.get(
                 f"Still working (attempt {self.attempt}, have been running for {time_delta})..."
             ) as s:
                 sleep(self.interval)
         if self.enabled:
             subprocess.Popen('python playmusic.py', creationflags=subprocess.CREATE_NEW_CONSOLE)
             log.info(f"{self.gpu_long_name} is in stock. Go buy it.")
             cart_url = self.open_cart_url(product_id)
             self.notification_handler.send_notification(f" {self.gpu_long_name} with product ID: {product_id} in "
                                                         f"stock: {cart_url}")
             self.enabled = False
     except Timeout:
         log.error("Had a timeout error.")
         self.buy(product_id)
Ejemplo n.º 7
0
#!/usr/bin/env python
# When cloning the project, to be run with 'pipenv run python examples/simple.py'
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
## ^^ Do not use statement up when installing library ^^

from spinlog import Spinner
from time import sleep

with Spinner.get("yolololo") as s:
    sleep(2)
    s.warn("ah bon?")
    sleep(2)
    s.error("BIM\nBIM")
    sleep(2)
    s.info("HAHA\nHAHA")
    s.log("HAHA")
    s.log("HAHA", symbol="😆".encode("utf-8"))
    sleep(2)
    s.debug("HAHA oui c'est drole")
    sleep(2)