-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributes_processor.py
63 lines (51 loc) · 2.43 KB
/
attributes_processor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from selenium.webdriver.common.by import By
import time
from includes.AttributeManager import AttributeManager
from includes.SiteProcessor import SiteProcessor
from includes import globals
from includes.logging_config import setup_logging
from includes.constants import DEFAULT_TIMEOUT, RMS_CATEGORY_URL, RMS_XPaths
from includes.BaseAutomation import BaseAutomation
from includes.argument_parser_utility import create_base_parser, add_property_arguments
class AttributesProcessor(BaseAutomation):
def __init__(self, username: str, password: str, property_name: str, start_number: int = 1, debug: bool = False):
super().__init__(username, password, debug)
self.property_name = property_name
self.start_number = start_number
self.attribute_manager = None
self.site_processor = None
def setup(self):
super().setup()
self.attribute_manager = AttributeManager(self.selenium_helper)
self.site_processor = SiteProcessor(self.selenium_helper, self.attribute_manager, None)
def perform_automation(self):
self.navigate_to_page(RMS_CATEGORY_URL)
self.selenium_helper.wait_for_element(By.XPATH, RMS_XPaths.MAIN_WINDOW, timeout=DEFAULT_TIMEOUT)
self.logger.info("Main window loaded")
globals.wait_for_dropdown_and_select(self.driver, self.property_name)
time.sleep(2)
current_number = self.start_number - 1
container_xpath = RMS_XPaths.CONTAINER
while True:
next_row, next_number, _ = self.site_processor.find_next_site(current_number, container_xpath)
if not next_row:
self.logger.info(f"No more sites found after number {current_number}. Ending process.")
break
self.site_processor.process_site_attrs(next_row, next_number, attributes_to_add, attributes_to_remove)
current_number = next_number
def main():
parser = create_base_parser("RMS Cloud Attributes Processor Automation Script")
parser = add_property_arguments(parser)
args = parser.parse_args()
setup_logging(f"attributes_processor_{args.property}")
processor = AttributesProcessor(args.username, args.password, args.property, args.start, args.debug)
processor.run()
if __name__ == "__main__":
attributes_to_add = [
"Pet Friendly",
# Add other attributes as needed
]
attributes_to_remove = [
# Add attributes to remove as needed
]
main()