From 7e51b810832f053be41697f0f1345b89b5bcef9c Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Sun, 19 Jan 2020 23:38:16 -0600 Subject: [PATCH 1/4] add option to check for free games every X seconds --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index b7e0bd6..005195c 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import os +import time import logging from selenium import webdriver from selenium.webdriver.common.by import By @@ -12,7 +13,7 @@ def read_env_variables(): - global TIMEOUT, LOGIN_TIMEOUT, EMAIL, PASSWORD, LOGLEVEL + global TIMEOUT, LOGIN_TIMEOUT, EMAIL, PASSWORD, LOGLEVEL, SLEEPTIME value = os.getenv('TIMEOUT') or 5 TIMEOUT = int(value) @@ -22,6 +23,7 @@ def read_env_variables(): EMAIL = os.getenv('EMAIL') or "" PASSWORD = os.getenv('PASSWORD') or "" LOGLEVEL = str.upper(os.getenv('LOGLEVEL')) + SLEEPTIME = int(os.getenv('SLEEPTIME') or -1) def execute(): @@ -174,6 +176,10 @@ def main(): return logger.debug('started with TIMEOUT: %i, LOGIN_TIMEOUT: %i, EMAIL: %s, password: %s', TIMEOUT, LOGIN_TIMEOUT, EMAIL, len(PASSWORD)*"*") execute() + while SLEEPTIME >= 0: + logger.info('sleeping for %i seconds', SLEEPTIME) + time.sleep(SLEEPTIME) + execute() if __name__ == '__main__': From 09659fd55f62a84860ab22ec828f774a02301509 Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Mon, 20 Jan 2020 20:07:46 -0600 Subject: [PATCH 2/4] update optional config section, add Docker Compose section --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b71825..da32403 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,29 @@ docker run -e EMAIL= -e PASSWORD= epicgames Replacing the environment variables `EMAIL` and `PASSWORD` for your epicgames store credentials. ## Optional configuration -You can also specify two extra environmente variables `TIMEOUT` and `LOGIN_TIMEOUT` if you have a slow internet connection speed and want to make sure it won't affect the result of the script. `LOGLEVEL` can be used to specify the [log level](https://docs.python.org/3.7/library/logging.html#logging-levels) to log. +You can also specify two extra environmente variables `TIMEOUT` and `LOGIN_TIMEOUT` if you have a slow internet connection speed and want to make sure it won't affect the result of the script. `LOGLEVEL` can be used to specify the [log level](https://docs.python.org/3.7/library/logging.html#logging-levels) to log. `SLEEPTIME` can be used to set the number of seconds to wait between looping through the procedure again. Defaults to -1, which will stop execution after a single iteration. Run a docker container with these: ``` -docker run -e TIMEOUT=10 -e LOGIN_TIMEOUT=15 -e LOGLEVEL=DEBUG -e EMAIL= -e PASSWORD= epicgames +docker run -e TIMEOUT=10 -e LOGIN_TIMEOUT=15 -e LOGLEVEL=DEBUG -e SLEEPTIME=43200 -e EMAIL= -e PASSWORD= epicgames ``` These environmente variables have a default value of `TIMEOUT = 5` and `LOGIN_TIMEOUT = 10`. + +## Docker Compose +``` +version: '2' + +services: + + egs-freegame: + build: + context: ./epicgames-weekly-freegames/ + dockerfile: Dockerfile + restart: always + environment: + - TIMEOUT=10 + - LOGIN_TIMEOUT=15 + - SLEEPTIME=43200 + - LOGLEVEL=DEBUG + - EMAIL=example@example.com + - PASSWORD=password123 +``` From 9243cae571287c4744b5e137aa412e911614aa0d Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Tue, 21 Jan 2020 18:42:13 -0600 Subject: [PATCH 3/4] add docker-compose template --- docker-compose.yml.template | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docker-compose.yml.template diff --git a/docker-compose.yml.template b/docker-compose.yml.template new file mode 100644 index 0000000..046612b --- /dev/null +++ b/docker-compose.yml.template @@ -0,0 +1,16 @@ +version: '2' + +services: + egs-freegame: + container_name: egs-freegame + build: + context: ./ + dockerfile: Dockerfile + restart: always + environment: + - TIMEOUT=10 + - LOGIN_TIMEOUT=15 + - SLEEPTIME=43200 + - LOGLEVEL=DEBUG + - EMAIL=example@example.com + - PASSWORD=password123 From a42cecbe860c6528402f28fe798b6a6ad4659d8c Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Wed, 22 Jan 2020 19:35:14 -0600 Subject: [PATCH 4/4] revert accidental changes from resolving conflicts --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 219af89..23b6dad 100644 --- a/main.py +++ b/main.py @@ -20,8 +20,8 @@ def read_env_variables(): value = os.getenv('LOGIN_TIMEOUT') or 10 LOGIN_TIMEOUT = int(value) - EMAIL = os.getenv('EMAIL') or "" - PASSWORD = os.getenv('PASSWORD') or "" + EMAIL = os.getenv('EMAIL') or '' + PASSWORD = os.getenv('PASSWORD') or '' LOGLEVEL = str.upper(os.getenv('LOGLEVEL') or '') SLEEPTIME = int(os.getenv('SLEEPTIME') or -1)