def __init__(self, name, google_key, locale, units, timezone, time_limit, max_attempts, location, quiet, filter_file, geofence_file, alarm_file, debug): # Set the name of the Manager self.__name = str(name).lower() log.info("----------- Manager '{}' is being created.".format( self.__name)) self.__debug = debug # Get the Google Maps API self.__google_key = None self.__loc_service = None if str(google_key) != 'none': self.__google_key = google_key self.__loc_service = LocationService(google_key, locale, units) else: log.warning( "NO GOOGLE API KEY SET - Reverse Location and Distance Matrix DTS will NOT be detected." ) self.__locale = Locale(locale) # Setup the language-specific stuff self.__units = units # type of unit used for distances self.__timezone = timezone # timezone for time calculations self.__time_limit = time_limit # Minimum time remaining for stops and pokemon # Set up the Location Specific Stuff self.__location = None # Location should be [lat, lng] (or None for no location) if str(location).lower() != 'none': self.set_location(location) else: log.warning( "NO LOCATION SET - this may cause issues with distance related DTS." ) # Quiet mode self.__quiet = quiet # Load and Setup the Pokemon Filters self.__pokemon_settings, self.__pokestop_settings, self.__gym_settings = {}, {}, {} self.__raid_settings, self.__egg_settings = {}, {} self.__pokemon_hist, self.__pokestop_hist, self.__gym_hist, self.__raid_hist = {}, {}, {}, {} self.__gym_info = {} self.load_filter_file(get_path(filter_file)) # Create the Geofences to filter with from given file self.__geofences = [] if str(geofence_file).lower() != 'none': self.__geofences = load_geofence_file(get_path(geofence_file)) # Create the alarms to send notifications out with self.__alarms = [] self.load_alarms_file(get_path(alarm_file), int(max_attempts)) # Initialize the queue and start the process self.__queue = multiprocessing.Queue() self.__process = None log.info("----------- Manager '{}' successfully created.".format( self.__name))
def __init__(self, name, google_key, locale, units, timezone, time_limit, location, quiet, filter_file, geofence_file, alarm_file, debug): # Set the name of the Manager self.__name = str(name).lower() log.info("----------- Manager '{}' is being created.".format( self.__name)) self.__debug = debug # Get the Google Maps API self.__google_key = google_key self.__gmaps_client = googlemaps.Client( key=self.__google_key, timeout=1) if google_key is not None else None self.__api_req = { 'REVERSE_LOCATION': False, 'WALK_DIST': False, 'BIKE_DIST': False, 'DRIVE_DIST': False } # Setup the language-specific stuff self.__locale = locale self.__pokemon_name, self.__move_name, self.__team_name = {}, {}, {} self.update_locales() self.__units = units # type of unit used for distances self.__timezone = timezone # timezone for time calculations self.__time_limit = time_limit # Minimum time remaining for stops and pokemon self.__latlng = self.get_lat_lng_from_name( location) # Array with Lat, Lng for the Manager # Quiet mode self.__quiet = quiet # Load and Setup the Pokemon Filters self.__pokemon_settings, self.__pokestop_settings, self.__gym_settings = {}, {}, {} self.__pokemon_hist, self.__pokestop_hist, self.__gym_hist = {}, {}, {} self.load_filter_file(get_path(filter_file)) # Create the Geofences to filter with from given file self.__geofences = [] log.debug(geofence_file) if str(geofence_file).lower() != 'none': self.load_geofence_file(get_path(geofence_file)) # Create the alarms to send notifications out with self.__alarms = [] self.load_alarms_file(get_path(alarm_file)) # Initialize the queue and start the process self.__queue = multiprocessing.Queue() self.__process = None log.info("----------- Manager '{}' successfully created.".format( self.__name))
def __init__(self, language): # Load in English as the default with open(os.path.join(get_path('locales'), 'en.json')) as f: default = json.loads(f.read()) # Now load in the actual language we want (unnecessary for English but we don't want to discriminate) with open(os.path.join(get_path('locales'), '{}.json'.format(language))) as f: info = json.loads(f.read()) # Pokemon ID -> Name self.__pokemon_names = {} pokemon = info.get("pokemon", {}) for id_, val in default["pokemon"].iteritems(): self.__pokemon_names[int(id_)] = pokemon.get(id_, val) # Move ID -> Name self.__move_names = {} moves = info.get("moves", {}) for id_, val in default["moves"].iteritems(): self.__move_names[int(id_)] = moves.get(id_, val) # Team ID -> Name self.__team_names = {} teams = info.get("teams", {}) for id_, val in default["teams"].iteritems(): self.__team_names[int(id_)] = teams.get(id_, val) # Weather ID -> Name self.__weather_names = {} weather = info.get("weather", {}) for id_, val in default["weather"].iteritems(): self.__weather_names[int(id_)] = weather.get(id_, val) # Team ID -> Team Leaders self.__leader_names = {} leaders = info.get("leaders", {}) for id_, val in default["leaders"].iteritems(): self.__leader_names[int(id_)] = leaders.get(id_, val) # Pokemon ID -> { Form ID -> Form Name) self.__form_names = {} all_forms = info.get("forms", {}) for pkmn_id, forms in default["forms"].iteritems(): self.__form_names[int(pkmn_id)] = {} pkmn_forms = all_forms.get(pkmn_id, {}) for form_id, form_name in forms.iteritems(): self.__form_names[int(pkmn_id)][int(form_id)] = pkmn_forms.get( form_id, form_name) log.debug("Loaded '{}' locale successfully!".format(language))
def update(self, opts): path = get_path(opts) + '/project.properties' if len(path) > 0: libs = self.get_projects(path) for lib in libs: os.system('svn up ' + lib) else: print 'need to specify the path of project.properties' return
def generate_build(self, opts): path = get_path(opts) + '/project.properties' if len(path) > 0: libs = self.get_projects(path) for lib in libs: os.system('android update project -p %s -t android-22 -n %s --subprojects' % (lib, lib[lib.rindex('/') + 1:])) else: print 'need to specify the path of project.properties' return
def __init__(self, name, google_key, filters, geofences, alarms, location, locale, units, time_limit, timezone): # Set the name of the Manager self.__name = str(name).lower() log.info("Setting up {} process.".format(self.__name)) # Set up the Google API self.__google_key = google_key self.__gmaps_client = googlemaps.Client(key=self.__google_key, timeout=1) if self.__google_key is not None else None # Set up the rules on filtering notifications from given file self.__pokemon_filter = None self.__pokemon_hist = {} self.__pokestop_filter = None self.__pokestop_hist = {} self.__gym_filter = None self.__gym_hist = {} self.create_filters(get_path(filters)) # Create the Geofences to filter with from given file self.__geofences = [] self.__geofences_config = geofences if str(geofences).lower() != 'none' else None # Create the alarms to send notifications out with self.__api_req = {'REVERSE_LOCATION': False, 'WALK_DIST': False, 'BIKE_DIST': False, 'DRIVE_DIST': False} self.__alarms = [] self.__alarms_file = get_path(alarms) # Set the location self.__latlng = self.get_lat_lng_by_name(location) if location is not None else None # Set the locale to use for names and moves self.__pokemon_name, self.__move_name, self.__team_name = {}, {}, {} self.__locale = locale self.update_locales() # Set the units to be used self.__units = units
def update_locales(self): locale_path = os.path.join(get_path('locales'), '{}'.format(self.__locale)) # Update pokemon names with open(os.path.join(locale_path, 'pokemon.json'), 'r') as f: names = json.loads(f.read()) for pkmn_id, value in names.iteritems(): self.__pokemon_name[int(pkmn_id)] = value # Update move names with open(os.path.join(locale_path, 'moves.json'), 'r') as f: moves = json.loads(f.read()) for move_id, value in moves.iteritems(): self.__move_name[int(move_id)] = value # Update team names with open(os.path.join(locale_path, 'teams.json'), 'r') as f: teams = json.loads(f.read()) for team_id, value in teams.iteritems(): self.__team_name[int(team_id)] = value
def intialize_process(self): # Update config config.update(**self.__config) config['TIMEZONE'] = self.__timezone config['API_KEY'] = self.__google_key config['UNITS'] = self.__units # Hush some new loggers logging.getLogger('requests').setLevel(logging.WARNING) logging.getLogger('urllib3').setLevel(logging.WARNING) if config['DEBUG'] is True: logging.getLogger().setLevel(logging.DEBUG) # Make the Alarms self.create_alarms(self.__alarms_file) if self.__geofences_config is not None: self.create_geofences(get_path(self.__geofences_config))
def __init__(self, name, google_key, locale, units, timezone, time_limit, max_attempts, location, quiet, cache_type, filter_file, geofence_file, alarm_file, debug): # Set the name of the Manager self.__name = str(name).lower() log.info("----------- Manager '{}' ".format(self.__name) + " is being created.") self.__debug = debug # Get the Google Maps API self.__google_key = google_key self.__loc_service = location_service_factory("GoogleMaps", self.__google_key, locale, units) self.__locale = Locale(locale) # Setup the language-specific stuff self.__units = units # type of unit used for distances self.__timezone = timezone # timezone for time calculations self.__time_limit = time_limit # Minimum time remaining # Location should be [lat, lng] (or None for no location) self.__location = None if str(location).lower() != 'none': self.set_location(location) else: log.warning("NO LOCATION SET - " + " this may cause issues with distance related DTS.") # Quiet mode self.__quiet = quiet # Create cache self.__cache = cache_factory(cache_type, self.__name) # Load and Setup the Pokemon Filters self.__mons_enabled, self.__mon_filters = False, OrderedDict() self.__stops_enabled, self.__stop_filters = False, OrderedDict() self.__gyms_enabled, self.__gym_filters = False, OrderedDict() self.__ignore_neutral = False self.__eggs_enabled, self.__egg_filters = False, OrderedDict() self.__raids_enabled, self.__raid_filters = False, OrderedDict() self.__weather_enabled, self.__weather_filters = False, OrderedDict() self.__quest_enabled, self.__quest_filters = False, OrderedDict() self.load_filter_file(get_path(filter_file)) # Create the Geofences to filter with from given file self.geofences = None if str(geofence_file).lower() != 'none': self.geofences = load_geofence_file(get_path(geofence_file)) # Create the alarms to send notifications out with self.__alarms = [] self.load_alarms_file(get_path(alarm_file), int(max_attempts)) # Initialize Rules self.__mon_rules = {} self.__stop_rules = {} self.__gym_rules = {} self.__egg_rules = {} self.__raid_rules = {} self.__weather_rules = {} self.__quest_rules = {} # Initialize the queue and start the process self.__queue = Queue() self.__event = Event() self.__process = None log.info("----------- Manager '{}' ".format(self.__name) + " successfully created.")
def __init__(self, name, google_key, locale, units, timezone, time_limit, max_attempts, location, cache_type, geofence_file, debug): # Set the name of the Manager self.name = str(name).lower() self._log = self._create_logger(self.name) self._rule_log = self.get_child_logger('rules') self.__debug = debug # Get the Google Maps AP# TODO: Improve error checking self._google_key = None self._gmaps_service = None if str(google_key).lower() != 'none': self._google_key = google_key self._gmaps_service = GMaps(google_key) self._gmaps_reverse_geocode = False self._gmaps_distance_matrix = set() self._language = locale self.__locale = Locale(locale) # Setup the language-specific stuff self.__units = units # type of unit used for distances self.__timezone = timezone # timezone for time calculations self.__time_limit = time_limit # Minimum time remaining # Location should be [lat, lng] (or None for no location) self.__location = None if str(location).lower() != 'none': self.set_location(location) else: self._log.warning("NO LOCATION SET - this may cause issues " "with distance related DTS.") # Create cache self.__cache = cache_factory(self, cache_type) # Load and Setup the Pokemon Filters self._mons_enabled, self._mon_filters = False, OrderedDict() self._stops_enabled, self._stop_filters = False, OrderedDict() self._gyms_enabled, self._gym_filters = False, OrderedDict() self._ignore_neutral = False self._eggs_enabled, self._egg_filters = False, OrderedDict() self._raids_enabled, self._raid_filters = False, OrderedDict() self._weather_enabled, self._weather_filters = False, OrderedDict() # Create the Geofences to filter with from given file self.geofences = None if str(geofence_file).lower() != 'none': self.geofences = load_geofence_file(get_path(geofence_file)) # Create the alarms to send notifications out with self._alarms = {} self._max_attempts = int(max_attempts) # TODO: Move to alarm level # Initialize Rules self.__mon_rules = {} self.__stop_rules = {} self.__gym_rules = {} self.__egg_rules = {} self.__raid_rules = {} self.__weather_rules = {} # Initialize the queue and start the process self.__queue = Queue() self.__event = Event() self.__process = None
def __init__(self, name, google_key, filters, geofences, alarms, location, locale, units, time_limit, timezone): # Set the name of the Manager self.__name = str(name).lower() log.info("Setting up {} process.".format(self.__name)) # Set up the Google API self.__google_key = google_key self.__gmaps_client = googlemaps.Client( key=self.__google_key) if self.__google_key is not None else None # Set up the rules on filtering notifications from given file self.__pokemon_filter = None self.__pokemon_hist = {} self.__pokestop_filter = None self.__pokestop_hist = {} self.__gym_filter = None self.__gym_hist = {} self.create_filters(get_path(filters)) # Create the Geofences to filter with from given file self.__geofences = [] self.__geofences_config = geofences if str( geofences).lower() != 'none' else None # Create the alarms to send notifications out with self.__api_req = { 'REVERSE_LOCATION': False, 'WALK_DIST': False, 'BIKE_DIST': False, 'DRIVE_DIST': False } self.__alarms = [] self.__alarms_file = get_path(alarms) # Set the location self.__latlng = self.get_lat_lng_by_name( location) if location is not None else None # Set the locale to use for names and moves self.__pokemon_name, self.__move_name, self.__team_name = {}, {}, {} self.__locale = locale self.update_locales() # Set the units to be used self.__units = units # Set the minimum time_limit to send a notification (for pkmn/lures) self.__time_limit = time_limit # Set the timezone to use self.__timezone = timezone # Initialize the queue and start the process self.__config = config self.__threads = [] # Notification threads self.__queue = multiprocessing.Queue() self.__process = gipc.start_process(target=self.run, args=(), name=self.__name)
def __init__(self, language): # Load in English as the default with open(os.path.join(get_path('locales'), 'en.json')) as f: default = json.loads(f.read()) # Now load in the actual language we want # (unnecessary for English but we don't want to discriminate) with open(os.path.join(get_path('locales'), '{}.json'.format(language))) as f: info = json.loads(f.read()) # Pokemon ID -> Name self.__pokemon_names = {} pokemon = info.get("pokemon", {}) for id_, val in default["pokemon"].iteritems(): self.__pokemon_names[int(id_)] = pokemon.get(id_, val) # Move ID -> Name self.__move_names = {} moves = info.get("moves", {}) for id_, val in default["moves"].iteritems(): self.__move_names[int(id_)] = moves.get(id_, val) # Team ID -> Name self.__team_names = {} teams = info.get("teams", {}) for id_, val in default["teams"].iteritems(): self.__team_names[int(id_)] = teams.get(id_, val) # Team ID -> Team Leaders self.__leader_names = {} leaders = info.get("leaders", {}) for id_, val in default["leaders"].iteritems(): self.__leader_names[int(id_)] = leaders.get(id_, val) # Weather ID -> Name self.__weather_names = {} weather = info.get("weather", {}) for id_, val in default["weather"].iteritems(): self.__weather_names[int(id_)] = weather.get(id_, val) # Size ID -> Size Name self.__size_names = {} sizes = info.get("sizes", {}) for id_, val in default["sizes"].iteritems(): self.__size_names[int(id_)] = sizes.get(id_, val) # Type ID -> Type Name self.__type_names = {} types = info.get("types", {}) for id_, val in default["types"].iteritems(): self.__type_names[int(id_)] = types.get(id_, val) # Pokemon ID -> { Costume ID -> Costume Name} self.__costume_names = {} all_costumes = info.get("costumes", {}) for pkmn_id, costumes in default["costumes"].iteritems(): self.__costume_names[int(pkmn_id)] = {} pkmn_costumes = all_costumes.get(pkmn_id, {}) for costume_id, costume_name in costumes.iteritems(): self.__costume_names[int(pkmn_id)][int( costume_id)] = pkmn_costumes.get(costume_id, costume_name) # Pokemon ID -> { Form ID -> Form Name} self.__form_names = {} all_forms = info.get("forms", {}) for pkmn_id, forms in default["forms"].iteritems(): self.__form_names[int(pkmn_id)] = {} pkmn_forms = all_forms.get(pkmn_id, {}) for form_id, form_name in forms.iteritems(): self.__form_names[int(pkmn_id)][int(form_id)] = pkmn_forms.get( form_id, form_name) # Rarity ID -> Rarity Name self.__rarity_names = {} rarity_names = info.get("rarity", {}) for _id, rarity in default["rarity"].iteritems(): self.__rarity_names[int(_id)] = rarity_names.get(_id, rarity) # Severity ID -> Severity Name self.__severity_names = {} severities = info.get("severity", {}) for id_, val in default["severity"].iteritems(): self.__severity_names[int(id_)] = severities.get(id_, val) # Day or Night ID -> Day or Night Name self.__day_or_night_names = {} day_or_night = info.get('day_or_night', {}) for id_, val in default['day_or_night'].iteritems(): self.__day_or_night_names[int(id_)] = day_or_night.get(id_, val) log.debug("Loaded '{}' locale successfully!".format(language)) self.__misc = info.get('misc', {})
def __init__(self, name, google_key, locale, units, timezone, time_limit, max_attempts, location, cache_type, geofence_file, debug): # Set the name of the Manager self.name = str(name).lower() self._log = self._create_logger(self.name) self._rule_log = self.get_child_logger('rules') self.__debug = debug # Get the Google Maps AP# TODO: Improve error checking self._google_key = None self._gmaps_service = None if str(google_key).lower() != 'none': self._google_key = google_key self._gmaps_service = GMaps(google_key) self._gmaps_reverse_geocode = False self._gmaps_distance_matrix = set() self._language = locale self.__locale = Locale(locale) # Setup the language-specific stuff self.__units = units # type of unit used for distances self.__timezone = timezone # timezone for time calculations self.__time_limit = time_limit # Minimum time remaining # Location should be [lat, lng] (or None for no location) self.__location = None if str(location).lower() != 'none': self.set_location(location) else: self._log.warning( "NO LOCATION SET - this may cause issues " "with distance related DTS.") # Create cache self.__cache = cache_factory(self, cache_type) # Load and Setup the Pokemon Filters self._mons_enabled, self._mon_filters = False, OrderedDict() self._stops_enabled, self._stop_filters = False, OrderedDict() self._gyms_enabled, self._gym_filters = False, OrderedDict() self._ignore_neutral = False self._eggs_enabled, self._egg_filters = False, OrderedDict() self._raids_enabled, self._raid_filters = False, OrderedDict() self._weather_enabled, self._weather_filters = False, OrderedDict() # Create the Geofences to filter with from given file self.geofences = None if str(geofence_file).lower() != 'none': self.geofences = load_geofence_file(get_path(geofence_file)) # Create the alarms to send notifications out with self._alarms = {} self._max_attempts = int(max_attempts) # TODO: Move to alarm level # Initialize Rules self.__mon_rules = {} self.__stop_rules = {} self.__gym_rules = {} self.__egg_rules = {} self.__raid_rules = {} self.__weather_rules = {} # Initialize the queue and start the process self.__queue = Queue() self.__event = Event() self.__process = None
def __init__(self, language): # Load in English as the default with open(os.path.join(get_path('locales'), 'en.json')) as f: default = json.loads(f.read()) # Now load in the actual language we want # (unnecessary for English but we don't want to discriminate) with open(os.path.join( get_path('locales'), '{}.json'.format(language))) as f: info = json.loads(f.read()) # Pokemon ID -> Name self.__pokemon_names = {} pokemon = info.get("pokemon", {}) for id_, val in default["pokemon"].iteritems(): self.__pokemon_names[int(id_)] = pokemon.get(id_, val) # Move ID -> Name self.__move_names = {} moves = info.get("moves", {}) for id_, val in default["moves"].iteritems(): self.__move_names[int(id_)] = moves.get(id_, val) # Team ID -> Name self.__team_names = {} teams = info.get("teams", {}) for id_, val in default["teams"].iteritems(): self.__team_names[int(id_)] = teams.get(id_, val) # Team ID -> Team Leaders self.__leader_names = {} leaders = info.get("leaders", {}) for id_, val in default["leaders"].iteritems(): self.__leader_names[int(id_)] = leaders.get(id_, val) # Weather ID -> Name self.__weather_names = {} weather = info.get("weather", {}) for id_, val in default["weather"].iteritems(): self.__weather_names[int(id_)] = weather.get(id_, val) # Size ID -> Size Name self.__size_names = {} sizes = info.get("sizes", {}) for id_, val in default["sizes"].iteritems(): self.__size_names[int(id_)] = sizes.get(id_, val) # Type ID -> Type Name self.__type_names = {} types = info.get("types", {}) for id_, val in default["types"].iteritems(): self.__type_names[int(id_)] = types.get(id_, val) # Pokemon ID -> { Costume ID -> Costume Name} self.__costume_names = {} all_costumes = info.get("costumes", {}) for pkmn_id, costumes in default["costumes"].iteritems(): self.__costume_names[int(pkmn_id)] = {} pkmn_costumes = all_costumes.get(pkmn_id, {}) for costume_id, costume_name in costumes.iteritems(): self.__costume_names[int(pkmn_id)][int( costume_id)] = pkmn_costumes.get(costume_id, costume_name) # Pokemon ID -> { Form ID -> Form Name} self.__form_names = {} all_forms = info.get("forms", {}) for pkmn_id, forms in default["forms"].iteritems(): self.__form_names[int(pkmn_id)] = {} pkmn_forms = all_forms.get(pkmn_id, {}) for form_id, form_name in forms.iteritems(): self.__form_names[int(pkmn_id)][int(form_id)] = pkmn_forms.get( form_id, form_name) # Rarity ID -> Rarity Name self.__rarity_names = {} rarity_names = info.get("rarity", {}) for _id, rarity in default["rarity"].iteritems(): self.__rarity_names[int(_id)] = rarity_names.get(_id, rarity) # Severity ID -> Severity Name self.__severity_names = {} severities = info.get("severity", {}) for id_, val in default["severity"].iteritems(): self.__severity_names[int(id_)] = severities.get(id_, val) # Day or Night ID -> Day or Night Name self.__day_or_night_names = {} day_or_night = info.get('day_or_night', {}) for id_, val in default['day_or_night'].iteritems(): self.__day_or_night_names[int(id_)] = day_or_night.get(id_, val) log.debug("Loaded '{}' locale successfully!".format(language)) self.__misc = info.get('misc', {})
def clean(opts): path = get_path(opts) os.system('ant -f %s clean' % path)
def release(opts): path = get_path(opts) os.system('ant -f %s release' % path) return