Esempio n. 1
0
def get_server_logs(command):
    output = do_the_linux_command(command)

    # Обрезаем инфу самого systemctl
    index_command = output.find(command)
    if index_command != -1:
        output = output[index_command + len(command) + 1:]
    else:
        start_command = f"{BASE_DIR}/venv/bin/uwsgi --ini {BASE_DIR}/config/uwsgi.ini"
        index_command = output.rfind(start_command)
        if index_command != -1:
            output = output[index_command + len(start_command) + 1:]

    # Удаляем всё до старта
    start_string = "*** uWSGI is running in multiple interpreter mode ***"
    if output.find(start_string) != -1:
        output = output[output.find(start_string) + len(start_string):]

    # Удаляем везде вхождения этой ненужной строки
    index_removing = output.find("server python[")
    if index_removing != -1:
        for_removing = output[index_removing:output.
                              find(']', index_removing + 1) + 1]
        output = output.replace(for_removing, '')

    output = "Логи:\n" + output + "\n"
    words = [
        "GET", "POST", "spawned uWSGI", "Not Found:", "HEAD", "pidfile",
        "WSGI app 0", "Bad Request", "HTTP_HOST", "OPTIONS "
    ]
    for word in words:
        output = remove_rows_if_find_word(output, word)
    return output
Esempio n. 2
0
    def start(self):
        command = "sensors"
        output = do_the_linux_command(command)

        find_text = 'Adapter: ISA adapter\nPackage id 0:'
        output = f"AVG:{output[output.find(find_text) + len(find_text):].replace('(high = +80.0°C, crit = +100.0°C)', '')}"

        return output
Esempio n. 3
0
def get_terraria_server_info(port):
    command = "systemctl status terraria"
    response = do_the_linux_command(command)
    index1 = response.find("Active: ") + len("Active: ")
    index2 = response.find("(", index1) - 1
    status = response[index1:index2]
    if status == 'active':
        result = f"Террария запущена ✅ - {MAIN_DOMAIN}:{port}\n"
    else:
        result = "Террария остановлена ⛔"

    return result
Esempio n. 4
0
def get_bot_logs(command):
    output = do_the_linux_command(command)

    # Обрезаем инфу самого systemctl
    index_command = output.find(command)
    if index_command != -1:
        output = output[index_command + len(command) + 1:]

    index_removing = output.find("server python[")
    if index_removing != -1:
        for_removing = output[index_removing:output.
                              find(']', index_removing + 1) + 1]
        output = output.replace(for_removing, '')
    words = ["USER=root", "user root", "Stopped", "Started"]
    for word in words:
        output = remove_rows_if_find_word(output, word)
    output = "Логи:\n" + output + "\n"
    return output
Esempio n. 5
0
 def menu_terraria(self):
     self.check_sender(Role.TERRARIA)
     self.check_command_time('terraria', 10)
     do_the_linux_command('sudo systemctl start terraria')
     return "Стартуем террарию!"
Esempio n. 6
0
 def start(self):
     return do_the_linux_command(self.vk_event.original_args)
Esempio n. 7
0
 def _stop_local(self):
     do_the_linux_command(f'sudo systemctl stop minecraft_{self.version}')
Esempio n. 8
0
 def get_server_info(self):
     command = f"{BASE_DIR}/venv/bin/mcstatus {self.ip}:{self.port} json"
     self.server_info = json.loads(do_the_linux_command(command))
Esempio n. 9
0
 def start(self):
     command = "uptime"
     result = do_the_linux_command(command)
     return result
Esempio n. 10
0
 def menu_server():
     do_the_linux_command('sudo systemctl reboot -i')
     return 'Рестартим сервер'
Esempio n. 11
0
 def menu_web():
     do_the_linux_command('sudo systemctl restart xoma163site')
     return 'Рестартим веб'
Esempio n. 12
0
 def menu_bot(self):
     self.vk_bot.parse_and_send_msgs_thread(self.vk_event.peer_id,
                                            'Рестартим бота')
     do_the_linux_command('sudo systemctl restart xoma163bot')
     return 'Рестартим бота'