diff --git a/kicost/distributors/digikey/digikey.py b/kicost/distributors/digikey/digikey.py index 0999f005e..1059392b7 100644 --- a/kicost/distributors/digikey/digikey.py +++ b/kicost/distributors/digikey/digikey.py @@ -42,9 +42,9 @@ import pycountry class dist_digikey(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_digikey, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) def dist_get_price_tiers(self, html_tree): '''@brief Get the pricing tiers from the parsed tree of the Digikey product page. diff --git a/kicost/distributors/distributor.py b/kicost/distributors/distributor.py index 1c2b96f56..cdddfbde2 100644 --- a/kicost/distributors/distributor.py +++ b/kicost/distributors/distributor.py @@ -59,11 +59,10 @@ class distributor: start_time = time.time() - def __init__(self, name, domain, scrape_retries, log_level, throttle_delay): + def __init__(self, name, domain, scrape_retries, throttle_delay): self.name = name self.scrape_retries = scrape_retries self.logger = logger - self.log_level = log_level self.domain = domain # Don't create fake_browser for "local" distributor. @@ -128,9 +127,9 @@ def scrape_part(self, id, part): else: self.logger = multiprocessing.get_logger() handler = logging.StreamHandler(sys.stdout) - handler.setLevel(self.log_level) + handler.setLevel(1) self.logger.addHandler(handler) - self.logger.setLevel(self.log_level) + self.logger.setLevel(1) self.browser.logger = self.logger url = {} diff --git a/kicost/distributors/farnell/farnell.py b/kicost/distributors/farnell/farnell.py index b7289b2d0..78e6f05bc 100644 --- a/kicost/distributors/farnell/farnell.py +++ b/kicost/distributors/farnell/farnell.py @@ -42,9 +42,9 @@ __author__='Giacinto Luigi Cerone' class dist_farnell(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_farnell, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) def dist_get_price_tiers(self, html_tree): '''@brief Get the pricing tiers from the parsed tree of the farnell product page. diff --git a/kicost/distributors/local/local.py b/kicost/distributors/local/local.py index 20489d1b2..a203c2a2e 100644 --- a/kicost/distributors/local/local.py +++ b/kicost/distributors/local/local.py @@ -43,8 +43,8 @@ class dist_local(distributor.distributor): # Static variable which contains local part html. html = None - def __init__(self, name, scrape_retries, log_level, throttle_delay): - super(dist_local, self).__init__(name, None, scrape_retries, log_level, throttle_delay) + def __init__(self, name, scrape_retries, throttle_delay): + super(dist_local, self).__init__(name, None, scrape_retries, throttle_delay) def create_part_html(parts, distributors, logger): '''@brief Create HTML page containing info for local (non-webscraped) parts. diff --git a/kicost/distributors/mouser/mouser.py b/kicost/distributors/mouser/mouser.py index 1d95de231..60b813e5e 100644 --- a/kicost/distributors/mouser/mouser.py +++ b/kicost/distributors/mouser/mouser.py @@ -39,9 +39,9 @@ from urllib.parse import quote_plus as urlquote class dist_mouser(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_mouser, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) self.browser.add_cookie('.mouser.com', 'preferences', 'ps=www2&pl=en-US&pc_www2=USDe') def dist_get_price_tiers(self, html_tree): diff --git a/kicost/distributors/newark/newark.py b/kicost/distributors/newark/newark.py index 356053600..3aa69043c 100644 --- a/kicost/distributors/newark/newark.py +++ b/kicost/distributors/newark/newark.py @@ -39,9 +39,9 @@ from urllib.parse import quote_plus as urlquote class dist_newark(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_newark, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) def dist_get_price_tiers(self, html_tree): '''@brief Get the pricing tiers from the parsed tree of the Newark product page. diff --git a/kicost/distributors/rs/rs.py b/kicost/distributors/rs/rs.py index fd80265ef..f63109ce0 100644 --- a/kicost/distributors/rs/rs.py +++ b/kicost/distributors/rs/rs.py @@ -40,9 +40,9 @@ from urllib.parse import quote_plus as urlquote class dist_rs(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_rs, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) def dist_get_price_tiers(self, html_tree): '''@brief Get the pricing tiers from the parsed tree of the RS Components product page. diff --git a/kicost/distributors/tme/tme.py b/kicost/distributors/tme/tme.py index 21f8aa6d5..301434485 100644 --- a/kicost/distributors/tme/tme.py +++ b/kicost/distributors/tme/tme.py @@ -40,9 +40,9 @@ from urllib.parse import quote_plus as urlquote, urlencode class dist_tme(distributor.distributor): - def __init__(self, name, scrape_retries, log_level, throttle_delay): + def __init__(self, name, scrape_retries, throttle_delay): super(dist_tme, self).__init__(name, distributor_dict[name]['site']['url'], - scrape_retries, log_level, throttle_delay) + scrape_retries, throttle_delay) def __ajax_details(self, pn): '''@brief Load part details from TME using XMLHttpRequest. diff --git a/kicost/globals.py b/kicost/globals.py index d6e75fa12..54e78caf8 100644 --- a/kicost/globals.py +++ b/kicost/globals.py @@ -31,6 +31,7 @@ DEBUG_OBSESSIVE = logging.DEBUG-2 DEBUG_HTTP_HEADERS = logging.DEBUG-3 DEBUG_HTTP_RESPONSES = logging.DEBUG-4 +# Minimum possible log level is logging.DEBUG-9 ! SEPRTR = ':' # Delimiter between library:component, distributor:field, etc. diff --git a/kicost/kicost.py b/kicost/kicost.py index 5f121fb3f..8b567b158 100644 --- a/kicost/kicost.py +++ b/kicost/kicost.py @@ -233,7 +233,7 @@ def mt_init_dist(d, scrape): ctor = globals()['dist_local'] else: ctor = globals()['dist_'+d] - instance = ctor(d, scrape_retries, 5, throttling_delay) # TODO: log level + instance = ctor(d, scrape_retries, throttling_delay) except Exception as ex: logger.log(DEBUG_OVERVIEW, "Initialising %s failed with %s, exculding this distributor..." \ % (d, type(ex).__name__))