
import logging
import time

import base
from kcaa import screens


logger = logging.getLogger('kcaa.manipulators.automission')


class CheckMissionResult(base.Manipulator):

    def run(self):
        logger.info('Checking mission result')
        yield self.screen.check_mission_result()


class AutoCheckMissionResult(base.AutoManipulator):

    @classmethod
    def can_trigger(cls, owner):
        if not screens.in_category(owner.screen_id, screens.PORT):
            return
        mission_list = owner.objects.get('MissionList')
        if not mission_list:
            return
        now = int(1000 * time.time())
        count = 0
        for mission in mission_list.missions:
            # Make sure the ETA has passed 10000 milliseconds ago.
            if mission.eta and mission.eta + 10000 < now:
                count += 1
        if count != 0:
            return {'count': count}

    def run(self, count):
        for _ in xrange(count):
            yield self.do_manipulator(CheckMissionResult)


import logging
import time

import base
from kcaa import screens


logger = logging.getLogger('kcaa.manipulators.automission')


class CheckMissionResult(base.Manipulator):

    def run(self):
        logger.info('Checking mission result')
        yield self.screen.check_mission_result()


class AutoCheckMissionResult(base.AutoManipulator):

    @classmethod
    def can_trigger(cls, owner):
        if not screens.in_category(owner.screen_id, screens.PORT):
            return
        mission_list = owner.objects.get('MissionList')
        if not mission_list:
            return
        now = int(1000 * time.time())
        count = 0
        for mission in mission_list.missions:
            if mission.eta and mission.eta < now:
                count += 1
        if count != 0:
            return {'count': count}

    def run(self, count):
        for _ in xrange(count):
            yield self.do_manipulator(CheckMissionResult)

Stop confirming ETA is 10 seconds ago, as it's possible that AutoFleetCharge interrupt within that duration.
Stop confirming ETA is 10 seconds ago, as it's possible that AutoFleetCharge
interrupt within that duration.

  
  import logging
  import time
  
  import base
  from kcaa import screens
  
  
  logger = logging.getLogger('kcaa.manipulators.automission')
  
  
  class CheckMissionResult(base.Manipulator):
  
      def run(self):
          logger.info('Checking mission result')
          yield self.screen.check_mission_result()
  
  
  class AutoCheckMissionResult(base.AutoManipulator):
  
      @classmethod
      def can_trigger(cls, owner):
          if not screens.in_category(owner.screen_id, screens.PORT):
              return
          mission_list = owner.objects.get('MissionList')
          if not mission_list:
              return
          now = int(1000 * time.time())
          count = 0
          for mission in mission_list.missions:
-             # Make sure the ETA has passed 10000 milliseconds ago.
-             if mission.eta and mission.eta + 10000 < now:
+             if mission.eta and mission.eta < now:
                  count += 1
          if count != 0:
              return {'count': count}
  
      def run(self, count):
          for _ in xrange(count):
              yield self.do_manipulator(CheckMissionResult)
  
Stop confirming ETA is 10 seconds ago, as it's possible that AutoFleetCharge interrupt within that duration.
## Code Before:

import logging
import time

import base
from kcaa import screens


logger = logging.getLogger('kcaa.manipulators.automission')


class CheckMissionResult(base.Manipulator):

    def run(self):
        logger.info('Checking mission result')
        yield self.screen.check_mission_result()


class AutoCheckMissionResult(base.AutoManipulator):

    @classmethod
    def can_trigger(cls, owner):
        if not screens.in_category(owner.screen_id, screens.PORT):
            return
        mission_list = owner.objects.get('MissionList')
        if not mission_list:
            return
        now = int(1000 * time.time())
        count = 0
        for mission in mission_list.missions:
            # Make sure the ETA has passed 10000 milliseconds ago.
            if mission.eta and mission.eta + 10000 < now:
                count += 1
        if count != 0:
            return {'count': count}

    def run(self, count):
        for _ in xrange(count):
            yield self.do_manipulator(CheckMissionResult)

## Instruction:
Stop confirming ETA is 10 seconds ago, as it's possible that AutoFleetCharge interrupt within that duration.
## Code After:

import logging
import time

import base
from kcaa import screens


logger = logging.getLogger('kcaa.manipulators.automission')


class CheckMissionResult(base.Manipulator):

    def run(self):
        logger.info('Checking mission result')
        yield self.screen.check_mission_result()


class AutoCheckMissionResult(base.AutoManipulator):

    @classmethod
    def can_trigger(cls, owner):
        if not screens.in_category(owner.screen_id, screens.PORT):
            return
        mission_list = owner.objects.get('MissionList')
        if not mission_list:
            return
        now = int(1000 * time.time())
        count = 0
        for mission in mission_list.missions:
            if mission.eta and mission.eta < now:
                count += 1
        if count != 0:
            return {'count': count}

    def run(self, count):
        for _ in xrange(count):
            yield self.do_manipulator(CheckMissionResult)
