How to use the pastepwn.scraping.pastebin.exceptions.PasteEmptyException function in pastepwn

To help you get started, we’ve selected a few pastepwn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d-Rickyy-b / pastepwn / pastepwn / scraping / pastebin / pastebinscraper.py View on Github external
def _check_error(self, body, key=None):
        """Checks if an error occurred and raises an exception if it did"""
        pattern = r"^YOUR IP: ((\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})|((([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4}))) DOES NOT HAVE ACCESS\.\s+VISIT: https:\/\/pastebin\.com\/doc_scraping_api TO GET ACCESS!"

        if 131 >= len(body) and re.match(pattern, body):
            self._exception_event.set()
            raise IPNotRegisteredError(body)

        if body is None or body == "":
            raise PasteEmptyException("The paste '{0}' or its body was set to None!".format(key))
        if body == "File is not ready for scraping yet. Try again in 1 minute.":
            # The pastebin API was not ready yet to deliver this paste -
            # We raise an exception to re-download it again after some time has passed
            raise PasteNotReadyException("The paste '{0}' could not be fetched yet!".format(key))
        elif body == "Error, we cannot find this paste.":
            # The paste has been deleted before we could download it.
            # We raise an exception to delete the paste from the queue
            raise PasteDeletedException("The paste '{0}' has been deleted!".format(key))
github d-Rickyy-b / pastepwn / pastepwn / scraping / pastebin / pastebinscraper.py View on Github external
# if paste is not known, download the body and put it on the queue and into the list
                last_body_download_time = round(time.time(), 2)

                try:
                    body = self._get_paste_content(paste.key)
                except PasteNotReadyException:
                    self.logger.debug("Paste '{0}' is not ready for downloading yet. Enqueuing it again.".format(paste.key))
                    # Make sure to wait a certain time. If only one element in the queue, this can lead to loops
                    self._rate_limit_sleep(last_body_download_time)
                    self._tmp_paste_queue.put(paste)
                    continue
                except PasteDeletedException:
                    # We don't add a sleep here, because this can't lead to loops
                    self.logger.info("Paste '{0}' has been deleted before we could download it! Skipping paste.".format(paste.key))
                    continue
                except PasteEmptyException:
                    self.logger.info("Paste '{0}' is set to None! Skipping paste.".format(paste.key))
                    continue
                except Exception as e:
                    self.logger.error("An exception occurred while downloading the paste '{0}'. Skipping this paste! Exception is: {1}".format(paste.key, e))
                    continue

                paste.set_body(body)
                self.paste_queue.put(paste)

                self._rate_limit_sleep(last_body_download_time)
            except Empty:
                continue