Example #1
0
    def set_optional_args(self, line):
        # Reverse Location
        args = {
            'street', 'street_num', 'address', 'postal', 'neighborhood',
            'sublocality', 'city', 'county', 'state', 'country'
        }
        self.__api_req['REVERSE_LOCATION'] = self.__api_req[
            'REVERSE_LOCATION'] or contains_arg(line, args)
        log.debug("REVERSE_LOCATION set to %s" %
                  self.__api_req['REVERSE_LOCATION'])

        # Walking Time
        args = {'walk_dist', 'walk_time'}
        self.__api_req[
            'WALK_DIST'] = self.__api_req['WALK_DIST'] or contains_arg(
                line, args)
        log.debug("WALK_DIST set to %s" % self.__api_req['WALK_DIST'])

        # Biking Time
        args = {'bike_dist', 'bike_time'}
        self.__api_req[
            'BIKE_DIST'] = self.__api_req['BIKE_DIST'] or contains_arg(
                line, args)
        log.debug("BIKE_DIST set to %s" % self.__api_req['BIKE_DIST'])

        # Driving Time
        args = {'drive_dist', 'drive_time'}
        self.__api_req[
            'DRIVE_DIST'] = self.__api_req['DRIVE_DIST'] or contains_arg(
                line, args)
        log.debug("DRIVE_DIST set to %s" % self.__api_req['DRIVE_DIST'])
Example #2
0
    def set_optional_args(self, line):
        # Reverse Location
        args = {'street', 'street_num', 'address', 'postal',
                'neighborhood', 'sublocality', 'city', 'county', 'state', 'country'}
        if contains_arg(line, args):
            if self.__loc_service is None:
                log.critical("Reverse location DTS were detected but no API key was provided!")
                log.critical("Please either remove the DTS, add an API key, or disable the alarm and try again.")
                sys.exit(1)
            self.__loc_service.enable_reverse_location()

        # Walking Dist Matrix
        args = {'walk_dist', 'walk_time'}
        if contains_arg(line, args):
            if self.__location is None:
                log.critical("Walking Distance Matrix DTS were detected but no location was set!")
                log.critical("Please either remove the DTS, set a location, or disable the alarm and try again.")
                sys.exit(1)
            if self.__loc_service is None:
                log.critical("Walking Distance Matrix DTS were detected but no API key was provided!")
                log.critical("Please either remove the DTS, add an API key, or disable the alarm and try again.")
                sys.exit(1)
            self.__loc_service.enable_walking_data()

        # Biking Dist Matrix
        args = {'bike_dist', 'bike_time'}
        if contains_arg(line, args):
            if self.__location is None:
                log.critical("Biking Distance Matrix DTS were detected but no location was set!")
                log.critical("Please either remove the DTS, set a location, or disable the alarm and try again.")
                sys.exit(1)
            if self.__loc_service is None:
                log.critical("Biking Distance Matrix DTS were detected but no API key was provided!")
                log.critical("Please either remove the DTS, add an API key, or disable the alarm and try again.")
                sys.exit(1)
            self.__loc_service.enable_biking_data()

        # Driving Dist Matrix
        args = {'drive_dist', 'drive_time'}
        if contains_arg(line, args):
            if self.__location is None:
                log.critical("Driving Distance Matrix DTS were detected but no location was set!")
                log.critical("Please either remove the DTS, set a location, or disable the alarm and try again.")
                sys.exit(1)
            if self.__loc_service is None:
                log.critical("Driving Distance Matrix DTS were detected but no API key was provided!")
                log.critical("Please either remove the DTS, add an API key, or disable the alarm and try again.")
                sys.exit(1)
            self.__loc_service.enable_driving_data()