예제 #1
0
파일: admin.py 프로젝트: anpavlov/diplom
def admin_page():
    user_id = utils.get_logged_user_id(request)
    if user_id is None:
        return redirect('/login')
    modules_count, new_modules_count, all_modules = utils.get_all_modules()
    ctx = {'modules_count': modules_count, 'all_modules': all_modules, 'new_modules_count': new_modules_count}
    return render_template("modules.html", **ctx)
예제 #2
0
def autoupdate_cp(request):
    global last_check
    print 'Last update check: ', last_check
    if request.method == 'GET' and \
        len([i for i in UPDATE_PATHS if i in  request.get_full_path()]) > 0:
        if last_check is None or last_check >= datetime.datetime.now() + \
            datetime.timedelta(weeks=1):
            for module_str in get_all_modules():
                try:
                    module = importlib.import_module(module_str)
                    remote = get_version_json_from_url(module.VERSION['remote_version'])
                    print "'%s' local version: %s" % (module_str, module.VERSION)
                    print "'%s' remote version: %s" % (module_str, remote)
                except ImportError:
                    print "'%s' version missing or specified incorrectly; skipping." % module_str
            last_check = datetime.datetime.now()
    return {}
예제 #3
0
import config
from bot.instabot import InstaBot, RUN
from utils import get_all_modules, get_config_from_module, Logger

if not os.path.exists(config.LOG_TO):
    os.makedirs(config.LOG_TO)


fh = logging.FileHandler(os.path.join(config.LOG_TO, config.LOGGER.get('file')))
fh.setLevel(config.LOGGER.get('level'))
fh.setFormatter(config.LOGGER.get('formatter'))

log = Logger("IBotManager", fh)


modules = get_all_modules()

threads = [Thread(target=InstaBot(**get_config_from_module(module_name[:-3])).new_auto_mod,
                  name=module_name[:-3]) for module_name in modules]


for t in threads:
    try:
        log.debug("Try start '%s' bot" % t.name)
        t.start()
        log.debug("Successfully start '%s' bot." % t.name)
    except Exception as ex:
        log.exception("Error during work bot")

[t.join() for t in threads if t.is_alive()]