feat: implement abstract base classes for stats plugins and add example plugin for stats setup and download
All checks were successful
Build and Push Docker Image / build (push) Successful in 12m3s
All checks were successful
Build and Push Docker Image / build (push) Successful in 12m3s
This commit is contained in:
31
plugins/example_plugin.py
Normal file
31
plugins/example_plugin.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import logging
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.remote.webdriver import WebDriver as Remote
|
||||
from utils.plugins_base import StatsSetupPlugin, StatsDownloadPlugin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ExampleStatsSetupPlugin(StatsSetupPlugin):
|
||||
def setup_stats(self, driver: webdriver.Chrome, url: str, retries: int = 5) -> webdriver.Chrome:
|
||||
logger.info("Running ExampleStatsSetupPlugin...")
|
||||
# Here you would implement the custom logic to setup stats
|
||||
# For example, you could click on a button to display stats.
|
||||
# You could also wait for an element to appear before continuing.
|
||||
# This is just an example
|
||||
|
||||
driver.get(url)
|
||||
|
||||
return driver
|
||||
|
||||
class ExampleStatsDownloadPlugin(StatsDownloadPlugin):
|
||||
def download_stats(self, driver: webdriver.Chrome, peersDict: dict, socket_url: str, socket_port: int):
|
||||
logger.info("Running ExampleStatsDownloadPlugin...")
|
||||
stats = {'message': 'Hello from ExampleStatsDownloadPlugin'}
|
||||
# Here you would implement the custom logic to download stats
|
||||
# and send them to the socket.
|
||||
# This is just an example
|
||||
|
||||
print(f"Sending stats: {stats} to {socket_url}:{socket_port}")
|
||||
|
||||
# Remember to call the saveStats method to send the stats to the socket
|
||||
super().saveStats([stats], socket_url, socket_port)
|
Reference in New Issue
Block a user