Exemplo n.º 1
0
 def __init__(self):
     #Intialize as Thread
     super(Alarm_Manager, self).__init__()
     #Import settings from Alarms.json
     with open(get_path(config['CONFIG_FILE'])) as file:
         settings = json.load(file)
         alarm_settings = settings["alarms"]
         config["NOTIFY_LIST"] = make_notify_list(settings["pokemon"])
         out = ""
         output_list = notify_list_lines(config["NOTIFY_LIST"], 4)
         if len(output_list) == 0:
             log.info("No pokemon are set for notification.")
         else:
             log.info("You will be notified of the following pokemon:")
             for line in output_list:
                 log.info(line)
         output_list_twitter = notify_list_multi_msgs(
             config["NOTIFY_LIST"], 140)
         self.stop_list = make_pokestops_list(settings["pokestops"])
         self.gym_list = make_gym_list(settings["gyms"])
         self.pokemon, self.pokestops, self.gyms = {}, {}, {}
         self.alarms = []
         self.queue = Queue.Queue()
         self.data = {}
         self.lock = threading.Lock()
         for alarm in alarm_settings:
             if alarm['active'] == "True":
                 if alarm['type'] == 'boxcar':
                     from Boxcar import Boxcar_Alarm
                     self.alarms.append(Boxcar_Alarm(alarm))
                 elif alarm['type'] == 'pushbullet':
                     from Pushbullet import Pushbullet_Alarm
                     self.alarms.append(Pushbullet_Alarm(alarm))
                 elif alarm['type'] == 'pushover':
                     from Pushover import Pushover_Alarm
                     self.alarms.append(Pushover_Alarm(alarm))
                 elif alarm['type'] == 'slack':
                     from Slack import Slack_Alarm
                     self.alarms.append(Slack_Alarm(alarm))
                 elif alarm['type'] == 'telegram':
                     from Telegram import Telegram_Alarm
                     self.alarms.append(Telegram_Alarm(alarm))
                 elif alarm['type'] == 'twilio':
                     from Twilio import Twilio_Alarm
                     self.alarms.append(Twilio_Alarm(alarm))
                 elif alarm['type'] == 'twitter':
                     from Twitter import Twitter_Alarm
                     self.alarms.append(Twitter_Alarm(alarm))
                 else:
                     log.info("Alarm type not found: " + alarm['type'])
                 set_optional_args(str(alarm))
             else:
                 log.info("Alarm not activated: " + alarm['type'] +
                          " because value not set to \"True\"")
Exemplo n.º 2
0
 def __init__(self):
     #Intialize as Thread
     super(Alarm_Manager, self).__init__()
     #Import settings from Alarms.json
     with open(get_path(config['CONFIG_FILE'])) as file:
         settings = json.load(file)
         alarm_settings = settings["alarms"]
         self.set_pokemon(settings["pokemon"])
         log.info("The following pokemon are set:")
         for id in sorted(self.pokemon_list.keys()):
             log.info(
                 "{name}: max_dist({max_dist}), min_iv({min_iv}), move1({move_1}), move2({move_2})"
                 .format(**self.pokemon_list[id]))
         self.stop_list = make_pokestops_list(settings["pokestops"])
         self.gym_list = make_gym_list(settings["gyms"])
         self.pokemon, self.pokestops, self.gyms = {}, {}, {}
         self.alarms = []
         self.queue = Queue.Queue()
         self.data = {}
         self.lock = threading.Lock()
         for alarm in alarm_settings:
             if alarm['active'] == "True":
                 if alarm['type'] == 'boxcar':
                     from Boxcar import Boxcar_Alarm
                     self.alarms.append(Boxcar_Alarm(alarm))
                 elif alarm['type'] == 'pushbullet':
                     from Pushbullet import Pushbullet_Alarm
                     self.alarms.append(Pushbullet_Alarm(alarm))
                 elif alarm['type'] == 'pushover':
                     from Pushover import Pushover_Alarm
                     self.alarms.append(Pushover_Alarm(alarm))
                 elif alarm['type'] == 'slack':
                     from Slack import Slack_Alarm
                     self.alarms.append(Slack_Alarm(alarm))
                 elif alarm['type'] == 'telegram':
                     from Telegram import Telegram_Alarm
                     self.alarms.append(Telegram_Alarm(alarm))
                 elif alarm['type'] == 'twilio':
                     from Twilio import Twilio_Alarm
                     self.alarms.append(Twilio_Alarm(alarm))
                 elif alarm['type'] == 'twitter':
                     from Twitter import Twitter_Alarm
                     self.alarms.append(Twitter_Alarm(alarm))
                 elif alarm['type'] == 'discord':
                     from Discord import Discord_Alarm
                     self.alarms.append(Discord_Alarm(alarm))
                 else:
                     log.info("Alarm type not found: " + alarm['type'])
                 set_optional_args(str(alarm))
             else:
                 log.info("Alarm not activated: " + alarm['type'] +
                          " because value not set to \"True\"")
Exemplo n.º 3
0
 def __init__(self, queue):
     #Intialize as Thread
     super(Alarm_Manager, self).__init__()
     #Import settings from Alarms.json
     filepath = config['ROOT_PATH']
     with open(os.path.join(filepath, config['CONFIG_FILE'])) as file:
         settings = json.load(file)
         alarm_settings = settings["alarms"]
         self.notify_list = make_notify_list(settings["pokemon"])
         out = ""
         for id in self.notify_list:
             out = out + "{}, ".format(get_pkmn_name(id))
         log.info("You will be notified of the following pokemon: \n" +
                  out[:-2])
         self.seen = {}
         self.alarms = []
         self.queue = queue
         for alarm in alarm_settings:
             if alarm['active'] == "True":
                 if alarm['type'] == 'pushbullet':
                     from Pushbullet import Pushbullet_Alarm
                     self.alarms.append(Pushbullet_Alarm(alarm))
                 elif alarm['type'] == 'pushover':
                     from Pushover import Pushover_Alarm
                     self.alarms.append(Pushover_Alarm(alarm))
                 elif alarm['type'] == 'slack':
                     from Slack import Slack_Alarm
                     self.alarms.append(Slack_Alarm(alarm))
                 elif alarm['type'] == 'telegram':
                     from Telegram import Telegram_Alarm
                     self.alarms.append(Telegram_Alarm(alarm))
                 elif alarm['type'] == 'twilio':
                     from Twilio import Twilio_Alarm
                     self.alarms.append(Twilio_Alarm(alarm))
                 elif alarm['type'] == 'twitter':
                     from Twitter import Twitter_Alarm
                     self.alarms.append(Twitter_Alarm(alarm))
                 elif alarm['type'] == 'blynk':
                     from blynk import blynk_alarm
                     self.alarms.append(blynk_alarm(alarm))
                 else:
                     log.info("Alarm type not found: " + alarm['type'])
                 set_optional_args(str(alarm))
             else:
                 log.info("Alarm not activated: " + alarm['type'] +
                          " because value not set to \"True\"")