Exemplo n.º 1
0
    def update_modules(self):
        reader = edmodulesinforeader.EDModulesInfoReader()
        modules_info = reader.process()
        stale = (self.slots_timestamp is
                 None) or (self.module_info_timestamp and
                           (self.slots_timestamp.as_py_epoch() <
                            self.module_info_timestamp.as_py_epoch()))
        if not stale:
            EDRLOG.log(u"Modules info: up-to-date", "DEBUG")
            return True

        if not modules_info or not modules_info.get("Modules", None):
            EDRLOG.log(u"No info on modules!", "DEBUG")
            return False

        timestamp = EDTime()
        timestamp.from_journal_timestamp(modules_info['timestamp'])
        if self.slots_timestamp and (
                timestamp.as_py_epoch() < self.slots_timestamp.as_py_epoch()
                or timestamp.as_py_epoch() <
                self.module_info_timestamp.as_py_epoch()):
            EDRLOG.log(
                u"Stale info in modulesinfo.json: {} vs. {})".format(
                    timestamp, self.slots_timestamp), "DEBUG")
            return False

        EDRLOG.log(
            u"Trying an update of modules: json@{}, slots@{}, panel looked@{}".
            format(timestamp, self.slots_timestamp,
                   self.module_info_timestamp), "DEBUG")
        updated = self.slots_timestamp is None
        EDRLOG.log(u"This will be our first time with actual info", "DEBUG")
        self.slots_timestamp = timestamp
        modules = modules_info.get("Modules", [])
        for module in modules:
            slot_name = module.get("Slot", None)
            if slot_name in self.slots:
                module_updated = self.slots[slot_name].update(module)
                if self.slots[slot_name].power_draw > 0:
                    if module_updated:
                        EDRLOG.log(
                            u"{} in {}: power_draw: {}, priority: {}".format(
                                self.slots[slot_name].cname, slot_name,
                                self.slots[slot_name].power_draw,
                                self.slots[slot_name].priority), "DEBUG")
                    updated |= module_updated
            else:
                the_module = edmodule.EDModule(module)
                self.slots[slot_name] = the_module
                if the_module.power_draw > 0 or the_module.power_generation > 0:
                    EDRLOG.log(
                        u"[New] {} in {}: power_draw: {}, priority: {}".format(
                            self.slots[slot_name].cname, slot_name,
                            self.slots[slot_name].power_draw,
                            self.slots[slot_name].priority), "DEBUG")
                updated |= the_module.power_draw > 0 or the_module.power_generation > 0
        return updated
Exemplo n.º 2
0
 def __probably_previously_prospected(self, entry):
     b = entry.copy()
     b["timestamp"] = ""
     b["Remaining"] = ""
     matching_entry = None
     for previous in self.prospected_raw_history:
         a = previous.copy()
         a["timestamp"] = ""
         a["Remaining"] = ""
         if a == b:
             matching_entry = previous
             break 
         
     if matching_entry:
         max_age = 60*5
         a_time = EDTime().from_journal_timestamp(matching_entry["timestamp"])
         b_time = EDTime().from_journal_timestamp(entry["timestamp"])
         return (b_time.as_py_epoch() - a_time.as_py_epoch()) <= max_age
     return False
Exemplo n.º 3
0
    def __process(self, fss_event):
        if fss_event.get("event", None) != "FSSSignalDiscovered":
            return False

        signal_name = fss_event.get("SignalName", None)
        if signal_name is None:
            return False

        if fss_event.get("SignalName_Localised", None) is None:
            self.__process_locations_fss(fss_event)
            self.noteworthy = True
            return True

        if signal_name in self.signals:
            self.signals[signal_name]["count"] += 1
            self.noteworthy = True
            return True
        elif signal_name in ["$USS;"]:
            uss_type = "misc"
            if  fss_event.get("USSType", None) in self.uss["variants"]:
                uss_type = fss_event["USSType"]
            self.uss["variants"][uss_type]["count"] += 1
            self.uss["available"] = True
            if "TimeRemaining" in fss_event:
                event_time = EDTime()
                event_time.from_journal_timestamp(fss_event["timestamp"])
                expires = event_time.as_py_epoch() + fss_event["TimeRemaining"]
                self.uss["variants"][uss_type]["expiring"].append(expires)
            self.noteworthy = True
            return True
        elif signal_name in self.combat_zones["variants"]:
            self.combat_zones["available"] = True
            self.combat_zones["variants"][signal_name]["count"] += 1
            return True
        elif signal_name in self.resource_extraction_sites["variants"]:
            self.resource_extraction_sites["available"] = True
            self.resource_extraction_sites["variants"][signal_name]["count"] += 1
            return True
        return False