Skip to content

Commit

Permalink
FEATURE: Functionality to restart scrapers when adding a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed May 7, 2019
1 parent 5186431 commit de99892
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pastepwn/core/pastepwn.py
Expand Up @@ -46,10 +46,10 @@ def __init__(self, database=None, proxies=None):
else:
self.logger.info("No database provided!")

def add_scraper(self, scraper):
def add_scraper(self, scraper, restart_scraping=False):
"""Adds a scraper to the list of scrapers"""
scraper.init_exception_event(self.__exception_event)
self.scraping_handler.add_scraper(scraper)
self.scraping_handler.add_scraper(scraper, restart_scraping)

def add_analyzer(self, analyzer):
self.paste_dispatcher.add_analyzer(analyzer)
Expand Down
7 changes: 6 additions & 1 deletion pastepwn/core/scrapinghandler.py
Expand Up @@ -19,10 +19,15 @@ def __init__(self, paste_queue=None, exception_event=None):
self.__threads = []
self.scrapers = []

def add_scraper(self, scraper):
def add_scraper(self, scraper, restart_scraping=False):
"""Adds a scraper to the list of scrapers"""
self.scrapers.append(scraper)

if restart_scraping:
logging.info("Restarting scrapers...")
self.stop()
self.start()

def start(self):
"""Starts scraping pastes from the provided sources"""
with self.__lock:
Expand Down

0 comments on commit de99892

Please sign in to comment.