Exemplo n.º 1
0
def check_commands():
    # Executing query
    q = ("SELECT * FROM server WHERE os='{}'".format(platform.lower()))
    db['cursor'].execute(q)

    # Going through status and start/stop appropriate bots
    commands = db['cursor']
    for command in commands:
        if command['restart'] == 1:
            print("MANAGER RESTARTING (r)")
            update_command_db('restart', 0, platform.lower())
            exit(99)
        if command['update1'] == 1:
            print("UPDATING BOT (r)")
            update_command_db('update1', 0, platform.lower())
            my_func.gitfetch(my_func.path())
            time.sleep(5)
        if command['server_restart'] == 1:
            print("RESTARTING SERVER (r)")
            update_command_db('server_restart', 0, platform.lower())
            my_telegram.send_mess_tg(get_admin_tg(), "⚠️ SERVER going to restart")
            os.system('reboot')
Exemplo n.º 2
0
import my_database
import my_telegram
import my_func
import time

my_telegram.send_mess_tg(my_database.get_admin_tg(),
                         "✅ Manager started on {}".format(my_func.platform()))

my_func.gitfetch(my_func.path())

not_notify = my_database.fill_not_notify_array()

# Set all actual values to 0 in database.
my_database.set_actual_zero()

while True:

    my_database.check_commands()

    # Get statuses from database and start/stop bots
    my_database.get_bots_status(not_notify=not_notify)

    # Check running scripts. If closed - trying to restart
    my_func.checkrun()

    # Print running scripts
    my_func.print_running_array()
    if len(not_notify):
        print("--/--/-- N notif: {}".format(not_notify))

    # Clears a feedback_required array if needed. Used to
Exemplo n.º 3
0
"""
    Bot - Infinity location liker.
"""
import os
import sys
import time
import random
import argparse
from sys import platform  # mac or linux

from tqdm import tqdm

sys.path.append(os.path.join(sys.path[0], '../'))

import my_func
path_ = my_func.path()

sys.path.append(path_)
from instabot import Bot
import my_database


def like_location_feed(new_bot, new_location, amount=0):
    counter = 0
    max_id = ''
    with tqdm(total=amount) as pbar:
        while counter < amount:
            if new_bot.api.get_location_feed(new_location['location']['pk'],
                                             max_id=max_id):
                location_feed = new_bot.api.last_json
                for media in new_bot.filter_medias(
Exemplo n.º 4
0

def is_lock_free():
    global lock_socket
    lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
    try:
        lock_id = "kirillovmr.manager_control"  # this should be unique. using your username as a prefix is a convention
        lock_socket.bind('\0' + lock_id)
        logging.debug("Acquired lock %r" % (lock_id, ))
        return True
    except socket.error:
        # socket already locked, task must already be running
        logging.info("Failed to acquire lock %r" % (lock_id, ))
        return False


if not is_lock_free():
    sys.exit()

# then, either include the rest of your script below,
# or import it, if it's in a separate file:
print(my_func.mc_start_text)

start_manager_command = "{} {}/manager.py".format(my_func.python_version(),
                                                  my_func.path())

while True:
    manager = call(start_manager_command, shell=True)
    print(my_func.mc_restart_text)
    time.sleep(10)