Ejemplo n.º 1
0
 def wrapper(parser, reddit):
     try:
         function(parser, reddit)
         logging.info("Successfully logged in as u/%s." %
                      reddit.user.me())
         logging.info("")
     except PrawcoreException as error:
         Errors.p_title(error)
         logging.critical("LOGIN FAILED.")
         logging.critical("PRAWCORE EXCEPTION: %s." % error)
         logging.critical("ABORTING URS.\n")
         parser.exit()
Ejemplo n.º 2
0
    def validate_user(parser, reddit):
        """
        Check if PRAW credentials are valid, then print rate limit PrettyTable.

        Parameters
        ----------
        parser: ArgumentParser
            argparse ArgumentParser object
        reddit: Reddit object
            Reddit instance created by PRAW API credentials

        Returns
        -------
        None
        """

        login_spinner = Halo(color="white", text="Logging in.")
        login_spinner.start()

        try:
            redditor = reddit.user.me()

            login_spinner.succeed(Style.BRIGHT + Fore.GREEN +
                                  "Successfully logged in as u/%s." % redditor)
            print()

            Validation.print_rate_limit(reddit)

            logging.info("Successfully logged in as u/%s." % redditor)
            logging.info("")
        except PrawcoreException as error:
            login_spinner.fail(Style.BRIGHT + Fore.RED + "Failed to log in.")

            Errors.p_title(error)
            logging.critical("LOGIN FAILED.")
            logging.critical("PRAWCORE EXCEPTION: %s." % error)
            logging.critical("ABORTING URS.\n")
            parser.exit()