def check_update(logger: Logger, repo: str, rpath: str, last_update: float): if not can_check: logger.warning(f"cant check update of {repo} - {rpath}") key = f"{repo} - {rpath}" cache = _storage.data.setdefault('cache', dict()).setdefault(key, dict()) headers_ = headers.copy() headers_["If-None-Match"] = cache.setdefault('etag', '') try: q = get(f"{domain}/repos/{repo}/commits", {'path': rpath, 'page': '1', 'per_page': '1', }, headers=headers_) except Exception as e: logger.warning(f"cant check update of {repo} - {rpath}: {e}") else: if q.status_code != 304: data = q.json() if q.status_code != 200: logger.warning(q.json()["message"]) return cache['etag'] = q.headers['ETag'] new_timestamp = datetime.strptime(data[0]["commit"]["author"]["date"], '%Y-%m-%dT%H:%M:%SZ').replace(tzinfo=timezone.utc).timestamp() cache['timestamp'] = int(new_timestamp) _storage.save() t = cache['timestamp'] if t > last_update: logger.warning(f"There is a update at {datetime.fromtimestamp(t)} on https://github.com/{repo}") else: logger.debug(f"{repo} - {rpath} is up to date") _storage.save()
def get_last_update(name: Optional[str], current_hash: str, logger: Logger): if name is None: data_dir = _storage.data.setdefault('core', dict()) else: data_dir = _storage.data.setdefault('plugins', dict()).setdefault(name, dict()) if 'time' not in data_dir or 'hash' not in data_dir or data_dir['hash'] != current_hash: logger.debug("last update time update") data_dir['time'] = time() data_dir['hash'] = current_hash _storage.save() return data_dir['time']
'action_id': c_ushort, 'skill_type': c_ubyte, 'unk0': c_ubyte, 'unk1': c_uint, 'cast_time': c_float, 'target_id': c_uint, 'rotation': c_float, 'unk2': c_uint, 'x': c_ushort, 'y': c_ushort, 'z': c_ushort, 'unk3': c_ushort, }) size = sizeof(ServerActorCast) _logger.debug("size: %d" % size) class RecvActorCastEvent(RecvNetworkEventBase): id = "network/actor_cast" name = "network actor cast event" def __init__(self, msg_time, header, raw_msg): super().__init__(msg_time, header, raw_msg) self.source_id = header.actor_id self.target_id = raw_msg.target_id self.action_id = raw_msg.action_id self.cast_time = raw_msg.cast_time def text(self): return f"{hex(self.source_id)[2:]} is casting {self.action_id} on {hex(self.target_id)[2:]} on {self.cast_time}s"
} class UndefinedRecv(RecvNetworkEventBase): def __init__(self, msg_time, raw_msg): self.header = ServerMessageHeader.from_buffer(raw_msg) super().__init__(msg_time, raw_msg[header_size:]) def text(self): return f"opcode:{self.header.msg_type} len:{len(self.raw_msg)}" processors = dict() _undefined_evt_class = dict() version_opcodes = opcodes.setdefault(FFxiv_Version, dict()) for key, opcode in version_opcodes.items(): if key not in _processors: _logger.debug( f"load recv opcode of [{key}]({hex(opcode)}) - no processor defined" ) processors[opcode] = type( f'RecvUndefined_{key}', (UndefinedRecv, ), { 'id': f"network/undefined_recv/{key}", 'name': f"network undefined recv - {key}", }) else: _logger.debug(f"load recv opcode of [{key}]({hex(opcode)})") processors[opcode] = _processors[key]
from FFxivPythonTrigger.Logger import Logger from FFxivPythonTrigger import FFxiv_Version from . import Ping from .Opcodes import opcodes _logger = Logger("XivNetwork/SendProcessors") _processors = { 'Ping': Ping.get_event, } processors = dict() _opcodes = opcodes.setdefault(FFxiv_Version, dict()) for k, p in _processors.items(): if k not in _opcodes: continue _logger.debug(f"load opcode of [{k}]({hex(_opcodes[k])})") processors[_opcodes[k]] = p
from FFxivPythonTrigger.Logger import Logger from .Struct import * from ...Structs import RecvNetworkEventBase as EventBase _logger = Logger("XivNetwork/ProcessAbility") a1_size = sizeof(ServerActionEffect1) a8_size = sizeof(ServerActionEffect8) a16_size = sizeof(ServerActionEffect16) a24_size = sizeof(ServerActionEffect24) a32_size = sizeof(ServerActionEffect32) _logger.debug( f"a1_size:{a1_size} a8_size:{a8_size} a16_size:{a16_size} a24_size:{a24_size} a32_size:{a32_size} " ) class ActionEffect(object): def __init__(self, effect_entry): self.raw_entry = effect_entry self.tags = set() self.param = 0 if effect_entry.type in SWING_TYPES: self.tags = SWING_TYPES[effect_entry.type].copy() self.param = effect_entry.main_param if self.tags.intersection(TYPE_HAVE_AMOUNT): if effect_entry.param5 == 64: self.param += effect_entry.param4 * 65535