示例#1
0
    def get(self):
        if self.request.get('clear') == 'T':
            logger.clear_log()
        if self.request.get('msg'):
            logger.log(self.request.get('msg'))

        self.response.write(logger.dump_log())
示例#2
0
    def get(self):
        if self.request.get('clear') == 'T':
            logger.clear_log()
        if self.request.get('msg'):
            logger.log(self.request.get('msg'))

        self.response.write(logger.dump_log())
示例#3
0
def reboot():
    """Reboots device and clear config state."""
    # Make sure to clear logcat before reboot occurs. In case of kernel crashes,
    # we use the log before reboot, so it is good to clear it when we are doing
    # the reboot explicitly.
    logger.clear_log()

    # Reboot.
    logs.log('Rebooting device.')
    adb.reboot()

    # Wait for boot to complete.
    adb.wait_until_fully_booted()

    # Start memory monitor script to prevent out-of-memory scenarios.
    setup_memory_monitor_script_if_needed()
示例#4
0
def config_init():
    import distort
    import translate
    global proxy_port
    global proxy_type

    if not os.path.isfile("polyglot.ini"):
        initdialog.init_dialog()

    config = configparser.ConfigParser()
    logger.clear_log()
    try:
        config.read("polyglot.ini")
        token = config["Polyglot"]["token"]
        log_key = config["Polyglot"]["key"]
        translate_verify = config["Polyglot"]["translate-verify"]
        # proxy_port = config["Polyglot"]["proxy"] Temporary disabled
        # proxy_type = config["Polyglot"]["proxy-type"]
        distort.max_inits = config["Distort"]["max-inits"]
        distort.attempts = config["Distort"]["attempts"]
        distort.cooldown = config["Distort"]["cooldown"]
    except Exception as e:
        logger.write_log("ERR: Config file was not found, not readable or incorrect! Bot will close!")
        logger.write_log("ERR: " + str(e) + "\n" + traceback.format_exc())
        sys.exit(1)

    if token == "":
        logger.write_log("ERR: Token is unknown! Bot will close!")
        sys.exit(1)
    if log_key == "":
        logger.write_log("WARN: Key isn't available! Unsafe mode!")

    if translate_verify == "true" or translate_verify == "True" or translate_verify == "1":
        translate_verify = True
    elif translate_verify == "false" or translate_verify == "False" or translate_verify == "0":
        translate_verify = False
    else:
        logger.write_log("Unknown value \"translate-verify\", value will be set to default")
        translate_verify = True

    logger.key = log_key
    translate.translate_verify = translate_verify
    distort.distort_init()
    return token
示例#5
0
文件: utils.py 项目: Allnorm/Polyglot
def download_clear_log(message, down_clear_check):
    if user_admin_checker(message) is False:
        return

    if down_clear_check:
        try:
            f = open(logger.current_log, 'r', encoding="utf-8")
            bot.send_document(message.chat.id, f)
            f.close()
            logging.info("log was downloaded successful by " +
                         logger.username_parser(message))
        except FileNotFoundError:
            logging.info("user " + logger.username_parser(message) +
                         " tried to download empty log\n" +
                         traceback.format_exc())
            bot.send_message(message.chat.id,
                             locales.get_text(message.chat.id, "logNotFound"))
        except IOError:
            logging.error(
                "user " + logger.username_parser(message) +
                " tried to download log, but something went wrong!\n" +
                traceback.format_exc())
            bot.send_message(
                message.chat.id,
                locales.get_text(message.chat.id, "logUploadError"))
    else:
        if logger.clear_log():
            logging.info("log was cleared by user " +
                         logger.username_parser(message) + ". Have fun!")
            bot.send_message(
                message.chat.id,
                locales.get_text(message.chat.id, "logClearSuccess"))
        else:
            logging.error("user " + logger.username_parser(message) +
                          " tried to clear log, but something went wrong\n!")
            bot.send_message(
                message.chat.id,
                locales.get_text(message.chat.id, "logClearError"))