示例#1
0
    def addcontext(self, message_file, config):
        ''' Determine whether the timestamp is in local or UTC time, and whether it uses a 12- or 24-hour clock. '''

        if self.time_format == 'utc' or 'UTC' and self.time_hours == '24':
            zone = findtimezone(config)
            message_file.write(
                str(datetime.datetime.utcnow().strftime(
                    '%A, %B %d, %Y %H:%M UTC in ') + str(zone) + '\n'))
        elif self.time_format == 'utc' or 'UTC' and self.time_hours == '12':
            zone = findtimezone(config)
            message_file.write(
                str(datetime.datetime.utcnow().strftime(
                    '%A, %B %d, %Y %I:%M %p UTC in ') + str(zone) + '\n'))
        elif self.time_format == 'local' and self.time_hours == '24':
            zone = findtimezone(config)
            message_file.write(
                str(datetime.datetime.now().strftime('%A, %B %d, %Y %H:%M in ')
                    + str(zone) + '\n'))
        elif self.time_format == 'local' and self.time_hours == '12':
            zone = findtimezone(config)
            message_file.write(
                str(datetime.datetime.now().strftime(
                    '%A, %B %d, %Y %I:%M %p in ') + str(zone) + '\n'))
        else:
            message_file.write(
                'Time format could not be determined. Please specify UTC or local time, and a 12- or 24-hour clock in your configuration file. \n'
            )
示例#2
0
    def addcontext(self, message_file, config):
        """ Add weather information to the commit message. Looks for
            weather_city: first in the config information but if that is not
            set, will try to use the system time zone to identify a city. """
        if config.location_location == None and self.city == None:
            zone = findtimezone(config)
            if zone == None:
                city = None
            else:
                city = self.__parsecity(zone)
        else:
            if config.location_location == None:
                city = self.city
            else:
                city = config.location_location

        if None == city:
            message_file.write('Couldn\'t determine city to fetch weather.\n')
            return False

        if self.appid == None:
            message_file.write('Open Weather Map requires an API key. For more information see: https://github.com/commandline/flashbake/wiki/Plugins')
            return False

        # call the open weather map API with the city
        weather = self.__getweather(city, self.appid, self.units)

        if len(weather) > 0:
            message_file.write('Current weather for %(city)s: %(description)s. %(temp)i%(temp_units)s. %(humidity)s%% humidity\n'
                    % weather)
        else:
            message_file.write('Couldn\'t fetch current weather for city, %s.\n' % city)
        return len(weather) > 0
示例#3
0
    def addcontext(self, message_file, config):
        """ Add weather information to the commit message. Looks for
            weather_city: first in the config information but if that is not
            set, will try to use the system time zone to identify a city. """
        if config.location_location == None and self.city == None:
            zone = findtimezone(config)
            if zone == None:
                city = None
            else:
                city = self.__parsecity(zone)
        else:
            if config.location_location == None:
                city = self.city
            else:
                city = config.location_location

        if None == city:
            message_file.write('Couldn\'t determine city to fetch weather.\n')
            return False

        # call the Google weather API with the city
        weather = self.__getweather(city)

        if len(weather) > 0:
            # there is also an entry for the key, wind_condition, in the weather
            # dictionary
            message_file.write('Current weather for %(city)s is %(condition)s (%(temp_f)sF/%(temp_c)sC) %(humidity)s\n'\
                    % weather)
        else:
            message_file.write('Couldn\'t fetch current weather for city, %s.\n' % city)
        return len(weather) > 0
示例#4
0
    def addcontext(self, message_file, config):
        """ Add weather information to the commit message. Looks for
            weather_city: first in the config information but if that is not
            set, will try to use the system time zone to identify a city. """
        if config.location_location == None and self.city == None:
            zone = findtimezone(config)
            if zone == None:
                city = None
            else:
                city = self.__parsecity(zone)
        else:
            if config.location_location == None:
                city = self.city
            else:
                city = config.location_location

        if None == city:
            message_file.write('Couldn\'t determine city to fetch weather.\n')
            return False

        # call the Google weather API with the city
        weather = self.__getweather(city)

        if len(weather) > 0:
            # there is also an entry for the key, wind_condition, in the weather
            # dictionary
            message_file.write('Current weather for %(city)s is %(condition)s (%(temp_f)sF/%(temp_c)sC) %(humidity)s\n'\
                    % weather)
        else:
            message_file.write(
                'Couldn\'t fetch current weather for city, %s.\n' % city)
        return len(weather) > 0
示例#5
0
    def addcontext(self, message_file, config):
        """ Add weather information to the commit message. Looks for
            weather_city: first in the config information but if that is not
            set, will try to use the system time zone to identify a city. """
        if config.location_location == None and self.city == None:
            zone = findtimezone(config)
            if zone == None:
                city = None
            else:
                city = self.__parsecity(zone)
        else:
            if config.location_location == None:
                city = self.city
            else:
                city = config.location_location

        if None == city:
            message_file.write('Couldn\'t determine city to fetch weather.\n')
            return False

        # call the open weather map API with the city
        weather = self.__getweather(city, self.units)

        if len(weather) > 0:
            message_file.write(
                'Current weather for %(city)s: %(description)s. %(temp)i%(temp_units)s. %(humidity)s%% humidity\n'
                % weather)
        else:
            message_file.write(
                'Couldn\'t fetch current weather for city, %s.\n' % city)
        return len(weather) > 0
示例#6
0
    def addcontext(self, message_file, config):

        ''' Determine whether the timestamp is in local or UTC time, and whether it uses a 12- or 24-hour clock. '''

        if self.time_format == 'utc' or 'UTC' and self.time_hours == '24':
           zone = findtimezone(config)
           message_file.write(str(datetime.datetime.utcnow().strftime('%A, %B %d, %Y %H:%M UTC in ') + str(zone) + '\n'))
        elif self.time_format == 'utc' or 'UTC' and self.time_hours == '12':
           zone = findtimezone(config)
           message_file.write(str(datetime.datetime.utcnow().strftime('%A, %B %d, %Y %I:%M %p UTC in ') + str(zone) + '\n'))
        elif self.time_format == 'local' and self.time_hours == '24':
           zone = findtimezone(config)
           message_file.write(str(datetime.datetime.now().strftime('%A, %B %d, %Y %H:%M in ') + str(zone) + '\n'))
        elif self.time_format == 'local' and self.time_hours == '12':
           zone = findtimezone(config)
           message_file.write(str(datetime.datetime.now().strftime('%A, %B %d, %Y %I:%M %p in ') + str(zone) + '\n'))
        else:
           message_file.write('Time format could not be determined. Please specify UTC or local time, and a 12- or 24-hour clock in your configuration file. \n')