change script to a single run

This commit is contained in:
Andreas Zweili 2017-03-16 09:20:18 +01:00
parent 22b9f7bcba
commit 147f1b599d
2 changed files with 20 additions and 12 deletions

View File

@ -104,17 +104,16 @@ class Configuration():
self.recipient_address = self.config['DEFAULT']['recipient_address']
dryscrape.start_xvfb()
settings = Configuration()
email = Email(settings.recipient_address)
website = Website(settings.url)
while True:
website.get_page()
if website.extract_price() < settings.price:
email.connecting(settings.smtp_server, settings.smtp_port)
email.login(settings.sender_address, settings.password)
email.sending(settings.sender_address, settings.url)
sys.exit(0)
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
print("No Match yet")
time.sleep(10)
website.get_page()
if website.extract_price() < settings.price:
email.connecting(settings.smtp_server, settings.smtp_port)
email.login(settings.sender_address, settings.password)
email.sending(settings.sender_address, settings.url)
sys.exit(0)
else:
sys.exit(0)

View File

@ -1,4 +1,13 @@
#!/bin/bash
source bin/activate
./price_checker.py
# Get the current working directory
SCRIPTPATH=$(dirname -- "$(readlink -e -- "$BASH_SOURCE")")
# add the bin directory to the path
PATH=$PATH:$SCRIPTPATH/bin/
# activate the virtual environment
source $SCRIPTPATH/bin/activate
# execute the main script
python3 $SCRIPTPATH/price_checker.py
exit 0