Exemplo n.º 1
0
def remove_old():
    loginfo = load_json_file("logs_info.json")
    result = {
        "msgs-actual": loginfo["msgs-actual"],
        "status-actual": loginfo["status-actual"],
        "msgs-saved": {},
        "status-saved": {}
    }
    result = check_age(result, "msgs", "logs/messages/", loginfo)
    result = check_age(result, "status", "logs/status/", loginfo)
    dump_json_file("logs_info.json", result)
Exemplo n.º 2
0
def send_notifications():
    global bot
    global json_answers
    jsonfile = load_json_file("allowed_users.json")
    if get_notification_status():
        for user, notification in jsonfile["notify"].items():
            if len(notification) > 1:
                bot.sendMessage(
                    user, json_answers["notification_pc"].format(
                        json_answers["pc-stages"][int(notification[0])],
                        notification[1]))
            elif notification in ["0", "1", "2"]:
                bot.sendMessage(
                    user, json_answers["notification_cam"].format(
                        json_answers["cams"][int(notification)]))
                take_snapshot(bot, user, int(notification))
    jsonfile["notify"] = {}
    dump_json_file("allowed_users.json", jsonfile)
Exemplo n.º 3
0
homePath = os.path.join(nowPath, '../')
sys.path.append(homePath)

## 从全局变量中引用railwayfreight变量
from config import railwayfreight, hive_conn, query

## 从全局函数中调用hive查询, 列表去重模块
from functions import spark_hive_query, mysql_update, load_yaml_file, load_json_file

## 获取yaml数据
yamlFile = railwayfreight.yamlFile
yamlDict = load_yaml_file(yamlFile)

## 获取json数据,从坐标文件
jsonFile = query.coordQueryFile
jsonDict = load_json_file(jsonFile)


def main():
    ## 获取yaml数据
    textTagList = yamlDict.get('textTagList')
    colorMin = yamlDict.get('colorMin')
    colorMax = yamlDict.get('colorMax')
    titleName = yamlDict.get('titleName')
    subName = yamlDict.get('subName')
    subLink = yamlDict.get('subLink')
    yUnit = yamlDict.get('yUnit')
    divUnit = yamlDict.get('divUnit')
    picType = yamlDict.get('picType')

    ##获取hive连接信息
Exemplo n.º 4
0
                bot.sendMessage(
                    user, json_answers["notification_pc"].format(
                        json_answers["pc-stages"][int(notification[0])],
                        notification[1]))
            elif notification in ["0", "1", "2"]:
                bot.sendMessage(
                    user, json_answers["notification_cam"].format(
                        json_answers["cams"][int(notification)]))
                take_snapshot(bot, user, int(notification))
    jsonfile["notify"] = {}
    dump_json_file("allowed_users.json", jsonfile)


## SATRTUP FUNCTION (well, better call it code than function)
if __name__ == "__main__":
    config_log = load_json_file("config.json")
    bot = telepot.Bot(config_log["telegram-token"])

    json_file = load_json_file("lang-" + config_log["main-language"] + ".json")
    json_answers = json_file["answers"]
    json_commands = json_file["commands"]

    ph = PlayListHandler(get_path() + "playlists.json")
    ph.main_folder = config_log["music-folder"] + "/"

    #STARTS BOT, AND INFINITE LOOP TO KEEP IT RUNNING
    MessageLoop(bot, handle).run_as_thread()

    while True:
        for _ in range(10):
            sleep(1)
Exemplo n.º 5
0
def notify(key):
    loginfo = load_json_file("allowed_users.json")
    for admin in loginfo["op-3"].keys():
        loginfo["notify"][admin] = key
    dump_json_file("allowed_users.json", loginfo)