Exemple #1
0
    def __init__(
        self,
        behavior_js: str,
        tab: Tab,
        next_action_expression: str,
        loop: Optional[AbstractEventLoop] = None,
        collect_outlinks: bool = False,
        post_run_actions: bool = False,
        frame: Optional[Union[Frame, Callable[[], Frame]]] = None,
    ) -> None:
        """Initialize the new WRBehaviorRunner instance

        :param behavior_js: The behavior's JS
        :param tab: The tab the behavior's JS will be run in
        :param next_action_expression: The JS expression used to initiate a behavior's action
        :param loop: The event loop used by the automation
        :param collect_outlinks: Should outlinks be collected after each action
        :param post_run_actions: Should a screenshot be taken once the behavior is done
        :param frame: Optional reference to or callable returning a simplechrome.FrameManager.Frame
        that the behavior is to be run in
        """
        self.behavior_js: str = behavior_js
        self.tab: Tab = tab
        self.next_action_expression: str = next_action_expression
        self.collect_outlinks: bool = collect_outlinks
        self.post_run_actions: bool = post_run_actions
        self.frame: Optional[Union[Frame, Callable[[], Frame]]] = frame
        self.loop: AbstractEventLoop = Helper.ensure_loop(loop)
        self.logger: AutoLogger = create_autologger("behaviorRunner",
                                                    "WRBehaviorRunner")
        self._done: bool = False
        self._paused: bool = False
        self._did_init: bool = False
        self._running_task: Optional[Task] = None
        self._num_actions_performed: int = 0
Exemple #2
0
 def __init__(
     self,
     browser: Browser,
     tab_data: Dict[str, str],
     redis: Optional[Redis] = None,
     session: Optional[ClientSession] = None,
     *args: Any,
     **kwargs: Any,
 ) -> None:
     super().__init__(loop=Helper.ensure_loop(browser.loop))
     self.browser: Browser = browser
     self.redis = redis
     self.session = session
     self.tab_data: Dict[str, str] = tab_data
     self.client: Optional[Client] = None
     self.logger: AutoLogger = create_autologger("tabs",
                                                 self.__class__.__name__)
     self._url: str = self.tab_data["url"]
     self._id: str = self.tab_data["id"]
     self._timestamp: str = None
     self._behaviors_paused: bool = False
     self._connection_closed: bool = False
     self._running: bool = False
     self._reconnecting: bool = False
     self._graceful_shutdown: bool = False
     self._default_handling_of_dialogs: bool = True
     self._behavior_run_task: Optional[Task] = None
     self._reconnect_promise: Optional[Task] = None
     self._running_behavior: Optional[Behavior] = None
     self._close_reason: Optional[CloseReason] = None
     self._viewport: Optional[Dict] = None
Exemple #3
0
    def __init__(self, redis: Redis, keys: RedisKeys) -> None:
        """Initialize the new instance of RedisScope

        :param redis: The redis instance to be used
        :param keys: The redis keys class containing the keys for the automation
        """
        self.redis: Redis = redis
        self.keys: RedisKeys = keys
        self.rules: List[MatchRule] = []
        self.all_links: bool = False
        self.logger: AutoLogger = create_autologger("scope", "RedisScope")
        self._current_page: str = ""
Exemple #4
0
    def __init__(
        self,
        conf: AutomationConfig,
        session: ClientSession,
        loop: Optional[AbstractEventLoop] = None,
    ) -> None:
        """Initialize the new instance of RemoteBehaviorManager

        :param conf: The automation's config
        :param session: The HTTP session to use for making the behavior requests
        :param loop: The event loop for the automation
        """
        self.conf: AutomationConfig = conf
        self.session: ClientSession = session
        self.loop: AbstractEventLoop = Helper.ensure_loop(loop)
        self.logger: AutoLogger = create_autologger("remoteBehaviorManager",
                                                    "RemoteBehaviorManager")
Exemple #5
0
    def __init__(
        self,
        redis: Redis,
        config: AutomationConfig,
        loop: Optional[AbstractEventLoop] = None,
    ):
        """Initialize the new instance of RedisFrontier

        :param redis: The redis instance to be used
        :param config: The automation config
        :param loop: The event loop used by the automation
        """
        self.config: AutomationConfig = config
        self.crawl_depth: int = -1
        self.currently_crawling: Optional[Dict[str, Union[str, int]]] = None
        self.keys: RedisKeys = self.config.redis_keys
        self.logger: AutoLogger = create_autologger("frontier", "RedisFrontier")
        self.loop: AbstractEventLoop = Helper.ensure_loop(loop)
        self.redis: Redis = redis
        self.scope: RedisScope = RedisScope(self.redis, self.keys)
        self._did_wait: bool = False
    def __init__(self,
                 conf: AutomationConfig,
                 loop: Optional[AbstractEventLoop] = None) -> None:
        """Create a new driver

        :param conf: The automation configuration object
        :param loop: The event loop to be used
        """
        self.conf: AutomationConfig = conf
        self.loop: AbstractEventLoop = Helper.ensure_loop(loop)
        self.did_init: bool = False
        self.shutdown_condition: ShutdownCondition = ShutdownCondition(
            loop=self.loop)
        self.session: ClientSession = Helper.create_aio_http_client_session(
            loop)
        self.behavior_manager: RemoteBehaviorManager = RemoteBehaviorManager(
            conf=self.conf, session=self.session, loop=self.loop)
        self.redis: Redis = None
        self.logger: AutoLogger = create_autologger("drivers",
                                                    self.__class__.__name__)
        self._browser_exit_infos: List[BrowserExitInfo] = []
 def __init__(
     self,
     config: AutomationConfig,
     behavior_manager: BehaviorManager,
     session: Optional[ClientSession] = None,
     redis: Optional[Redis] = None,
     loop: Optional[AbstractEventLoop] = None,
 ) -> None:
     """
     :param config: The configuration of this automation
     :param loop: Optional reference to the running event loop
     :param redis: Optional instance of redis to use
     """
     super().__init__(loop=Helper.ensure_loop(loop))
     self.tab_datas: List[Dict] = None
     self.redis: Optional[Redis] = redis
     self.session: Optional[ClientSession] = session
     self.tabs: Dict[str, Tab] = {}
     self.tab_closed_reasons: Dict[str, TabClosedInfo] = {}
     self.running: bool = False
     self.logger: AutoLogger = create_autologger("chrome_browser", "Chrome")
     self._config: AutomationConfig = config
     self._behavior_manager: BehaviorManager = behavior_manager