Skip to content

Commit

Permalink
Merge pull request #3 from CorySanin/master
Browse files Browse the repository at this point in the history
- Add option to run continuously on intervals of seconds (environment variable)
- Update optional config section, add Docker Compose section
- Add docker-compose template
  • Loading branch information
Ricardo-Osorio committed Jan 26, 2020
2 parents b8d932f + a42cecb commit c184bf8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
24 changes: 22 additions & 2 deletions README.md
Expand Up @@ -30,9 +30,29 @@ docker run -e EMAIL=<EMAIL> -e PASSWORD=<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=<EMAIL> -e PASSWORD=<PASSWORD> epicgames
docker run -e TIMEOUT=10 -e LOGIN_TIMEOUT=15 -e LOGLEVEL=DEBUG -e SLEEPTIME=43200 -e EMAIL=<EMAIL> -e PASSWORD=<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
```
16 changes: 16 additions & 0 deletions 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
9 changes: 8 additions & 1 deletion main.py
@@ -1,4 +1,5 @@
import os
import time
import logging
from selenium import webdriver
from selenium.webdriver.common.by import By
Expand All @@ -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)
Expand All @@ -22,6 +23,8 @@ def read_env_variables():
EMAIL = os.getenv('EMAIL') or ''
PASSWORD = os.getenv('PASSWORD') or ''
LOGLEVEL = str.upper(os.getenv('LOGLEVEL') or '')
SLEEPTIME = int(os.getenv('SLEEPTIME') or -1)



def execute():
Expand Down Expand Up @@ -174,6 +177,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__':
Expand Down

0 comments on commit c184bf8

Please sign in to comment.