Skip to content

Commit

Permalink
Availability check: Printing which zones are available
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Louis NECH committed Nov 2, 2015
1 parent 9a15c30 commit 18cf2d4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions buyKim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import traceback

import requests
from requests.packages.urllib3.exceptions import MaxRetryError
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
Expand Down Expand Up @@ -75,19 +74,26 @@ def print_and_log(message, level=logging.DEBUG, sep=' ', end='\n', flush=False):
found_product = True

found_zone = False
msg_model = ""
msg_zones = "zones:"
zone_avails = []
for zone in line['zones']:
if zone['zone'] == ref_zone:
availability = zone['availability']
zone_name = zone['zone']
zone_avails.append(zone_name + "=" + availability)
if zone_name == ref_zone:
found_zone = True
success = True
availability = zone['availability']
available = availability not in not_available_terms
available_status = ("" if available else "not ") + "available"
msg_model = 'Model %s in dc %s is marked as %s -> %s' % (
ref_product, ref_zone, availability, available_status)
log_msg += msg_model
print(msg_model, end="")
if available:
print(msg_model, end="")
break
print("%s (%s)" % (msg_model, ", ".join(zone_avails)), end="")

if not found_zone:
print_and_log("Zone %s was not found in data about product %s." % (ref_zone, ref_product))
if not found_product:
Expand Down

0 comments on commit 18cf2d4

Please sign in to comment.