Exemple #1
0
 def __init__(self, ansible_json, cookie):
     BaseService.__init__(self, ansible_json, cookie)
     self.get_zones_cmd = 'firewall-cmd --get-zones'
     self.get_service_cmd = 'firewall-cmd --get-services'
 def __init__(self, ansible_json, cookie):
     BaseService.__init__(self, ansible_json, cookie)
     self.get_user_cmd = 'cat /etc/passwd'
Exemple #3
0
 def __init__(self, cookie, async_api_url, init_json):
     BaseService.__init__(self, cookie, async_api_url, init_json)
     self.ansible_json = self.task_args
Exemple #4
0
    def boss_nature_protection_summary(cls, log_id, boss_name):
        fight_list, msg = BaseService.get_fight_list(log_id=log_id,
                                                     name=boss_name)
        if not fight_list or len(fight_list) == 0:
            return True, 'no %s fight in this log' % boss_name

        log_object, msg = BaseService.get_wcl_log_by_id(log_id=log_id)
        if not log_object:
            return False, msg

        for fight in fight_list:
            # 先获取该场boss站所有的参加人员
            success, result = WclApiService.get_api(
                api=CONSTANT_SERVICE.FIGHT_API,
                code=log_object.code,
                view=None,
                params=None)
            if not success:
                return success, result

            enemy_obj, msg = BaseService.get_enemy_by_name(log_id=log_id,
                                                           name=fight.name)
            if not enemy_obj:
                continue
            fight_id_dict = {"id": fight.fight_id}
            total_result_dict = dict()
            friendlies = result.get("friendlies")
            for friendly in friendlies:
                if fight_id_dict in friendly["fights"]:
                    # this player joined the fight
                    total_result_dict[friendly["id"]] = {
                        "nature_protection_absorb": 0,
                        "nature_protection_cast": 0,
                        "nature_protection_uptime": 0.00,
                        "major_nature_protection_absorb": 0,
                        "major_nature_protection_cast": 0,
                        "major_nature_protection_uptime": 0.00,
                    }

            start = fight.start
            end = fight.end
            time = end - start

            # 小自然抗
            params = {
                "start": start,
                "end": end,
                "abilityid": CONSTANT_SERVICE.Nature_Protection_id
            }

            success, result = WclApiService.get_api(
                api=CONSTANT_SERVICE.TABLES_API,
                view=CONSTANT_SERVICE.HEALING_VIEW,
                code=log_object.code,
                params=params)

            if not success:
                return False, result

            if len(result.get("entries")) > 0:
                for entry in result.get("entries"):
                    total = entry.get("total", 0)
                    uptime = entry.get('uptime', 0)
                    friendly_id = entry.get('id', 0)
                    if friendly_id in total_result_dict.keys():
                        total_result_dict[friendly_id][
                            "nature_protection_absorb"] = total
                        total_result_dict[friendly_id][
                            "nature_protection_uptime"] = round(
                                uptime * 100 / time, 2)

            success, result = WclApiService.get_api(
                api=CONSTANT_SERVICE.TABLES_API,
                view=CONSTANT_SERVICE.CASTS_VIEW,
                code=log_object.code,
                params=params)

            if not success:
                return False, result

            if len(result.get("entries")) > 0:
                for entry in result.get("entries"):
                    total = entry.get("total", 0)
                    friendly_id = entry.get('id', 0)
                    if friendly_id in total_result_dict.keys():
                        total_result_dict[friendly_id][
                            "nature_protection_cast"] = total

            # 大自然抗
            params = {
                "start": start,
                "end": end,
                "abilityid": CONSTANT_SERVICE.Major_Nature_Protection_id
            }

            success, result = WclApiService.get_api(
                api=CONSTANT_SERVICE.TABLES_API,
                view=CONSTANT_SERVICE.HEALING_VIEW,
                code=log_object.code,
                params=params)

            if not success:
                return False, result

            if len(result.get("entries")) > 0:
                for entry in result.get("entries"):
                    total = entry.get("total", 0)
                    uptime = entry.get('uptime', 0)
                    friendly_id = entry.get('id', 0)
                    if friendly_id in total_result_dict.keys():
                        total_result_dict[friendly_id][
                            "major_nature_protection_absorb"] = total
                        total_result_dict[friendly_id][
                            "major_nature_protection_uptime"] = round(
                                uptime * 100 / time, 2)

            success, result = WclApiService.get_api(
                api=CONSTANT_SERVICE.TABLES_API,
                view=CONSTANT_SERVICE.CASTS_VIEW,
                code=log_object.code,
                params=params)

            if not success:
                return False, result

            if len(result.get("entries")) > 0:
                for entry in result.get("entries"):
                    total = entry.get("total")
                    friendly_id = entry.get('id')
                    if friendly_id in total_result_dict.keys():
                        total_result_dict[friendly_id][
                            "major_nature_protection_cast"] = total

            # import json
            # print(json.dumps(total_result_dict))
            for key, value in total_result_dict.items():
                friendly_obj, msg = BaseService.get_friendly_by_id(
                    friendly_id=key, log_id=log_id)
                if not friendly_obj:
                    continue
                bossNatureProtection = BossNatureProtection()
                bossNatureProtection.friendly = friendly_obj
                bossNatureProtection.log = log_object
                bossNatureProtection.fight = fight
                bossNatureProtection.enemy = enemy_obj
                bossNatureProtection.name = friendly_obj.name
                bossNatureProtection.nature_protection_absorb = value.get(
                    "nature_protection_absorb", 0)
                bossNatureProtection.nature_protection_cast = value.get(
                    "nature_protection_cast", 0)
                bossNatureProtection.nature_protection_uptime = value.get(
                    "nature_protection_uptime", 0)
                bossNatureProtection.major_nature_protection_absorb = value.get(
                    "major_nature_protection_absorb", 0)
                bossNatureProtection.major_nature_protection_cast = value.get(
                    "major_nature_protection_cast", 0)
                bossNatureProtection.major_nature_protection_uptime = value.get(
                    "major_nature_protection_uptime", 0)
                if boss_name == CONSTANT_SERVICE.Hururan_name:
                    if friendly_obj.is_melee():
                        # melee
                        if bossNatureProtection.nature_protection_absorb > 0 and bossNatureProtection.major_nature_protection_cast == 0:
                            bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L1
                        elif bossNatureProtection.nature_protection_absorb > 0 or bossNatureProtection.major_nature_protection_cast == 0:
                            bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L2
                        else:
                            bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L3
                    else:
                        if bossNatureProtection.nature_protection_absorb > 0:
                            bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L1
                        else:
                            bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L3
                else:
                    if bossNatureProtection.nature_protection_absorb > 0:
                        bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L1
                    else:
                        bossNatureProtection.importance = BossNatureProtection.IMPORTANCE_L3

                bossNatureProtection.save()

        return True, ''
Exemple #5
0
 def __init__(self, ansible_json):
     BaseService.__init__(self, ansible_json)
Exemple #6
0
 def __init__(self, setting):
     self.name = "task_user_cubes"
     self.primary_key = "id"
     BaseService.__init__(self, self.name, self.get_task_sql, self.name, self.primary_key, UserCube, setting)
Exemple #7
0
 def __init__(self, setting):
     BaseService.__init__(self, train_code_sql, update_train_state,
                          update_train_task, StationTask, setting)