|
|
@@ -12,6 +12,7 @@ import custom_email
|
|
|
from tabulate import tabulate
|
|
|
from configparser import ConfigParser
|
|
|
from os import path
|
|
|
+import logging
|
|
|
|
|
|
### TO DO ###
|
|
|
#
|
|
|
@@ -67,10 +68,11 @@ class Search:
|
|
|
else:
|
|
|
return ''
|
|
|
|
|
|
+
|
|
|
# def __init__(self, county: list, lower_price=0, upper_price=500000, \
|
|
|
# lower_acres=5, upper_acres=15, type=['farm','land','home'], lower_sqft='', upper_sqft='', \
|
|
|
# lower_bedrooms='', upper_bedrooms=''):
|
|
|
- def __init__(self, file = '../landsearch.conf'):
|
|
|
+ def __init__(self, file = 'landsearch.conf'):
|
|
|
self.file = file
|
|
|
if not path.exists(self.file):
|
|
|
raise FileNotFoundError("The config file cannot be opened", self.file)
|
|
|
@@ -78,11 +80,20 @@ class Search:
|
|
|
config = ConfigParser()
|
|
|
config.read(self.file)
|
|
|
search_params = config['Search']
|
|
|
+ log_params = config['Logging']
|
|
|
except FileNotFoundError as err:
|
|
|
print(err, "Using default search parameters.")
|
|
|
except Exception as err:
|
|
|
print(err, "Using default search parameters.")
|
|
|
|
|
|
+ logging.basicConfig(filename=log_params.get('log_file'), \
|
|
|
+ level=log_params.get('logging_level', 30), \
|
|
|
+ format='%(asctime)s %(levelname)-8s %(message)s', \
|
|
|
+ datefmt='%Y-%m-%d %H:%M:%S') ## Default log level WARNING (30)
|
|
|
+ logging.getLogger("urllib3").setLevel(logging.WARNING) ## Supress Requests method logging
|
|
|
+ logging.debug("Log level set to %s", logging.root.level)
|
|
|
+
|
|
|
+
|
|
|
county = search_params.get('county', ['Gwinnett', 'Hall', 'Jackson', 'Walton', 'Barrow'])
|
|
|
if isinstance(county, str):
|
|
|
county = county.split(", ")
|
|
|
@@ -114,7 +125,7 @@ class Search:
|
|
|
assert property_type in self.types, ("Unknown type '" + property_type + "'. Property Type must be of type: " + str(self.types))
|
|
|
|
|
|
## FOR TESTING, PRINT ALL ATTRIBUTES OF SEARCH ##
|
|
|
-# print(vars(self))
|
|
|
+ logging.debug(vars(self))
|
|
|
|
|
|
|
|
|
class ImproperSearchError(Exception):
|