/usr/share/pyshared/flashbake/plugins/timezone.py is in flashbake 0.26.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # copyright 2009 Thomas Gideon
#
# This file is part of flashbake.
#
# flashbake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# flashbake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with flashbake. If not, see <http://www.gnu.org/licenses/>.
''' timezone.py - Stock plugin to find the system's time zone add to the commit message.'''
from flashbake.plugins import AbstractMessagePlugin
import logging
import os
PLUGIN_SPEC = 'flashbake.plugins.timezone:TimeZone'
class TimeZone(AbstractMessagePlugin):
def __init__(self, plugin_spec):
AbstractMessagePlugin.__init__(self, plugin_spec, False)
self.share_property('tz', plugin_spec=PLUGIN_SPEC)
def addcontext(self, message_file, config):
""" Add the system's time zone to the commit context. """
zone = findtimezone(config)
if zone == None:
message_file.write('Couldn\'t determine time zone.\n')
else:
message_file.write('Current time zone is %s\n' % zone)
return True
def findtimezone(config):
# check the environment for the zone value
zone = os.environ.get("TZ")
logging.debug('Zone from env is %s.' % zone)
# some desktops don't set the env var but /etc/timezone should
# have the value regardless
if None != zone:
logging.debug('Returning env var value.')
return zone
# this is common on many *nix variatns
logging.debug('Checking /etc/timezone')
if os.path.exists('/etc/timezone'):
zone_file = open('/etc/timezone')
try:
zone = zone_file.read()
finally:
zone_file.close()
zone = zone.replace("\n", "")
return zone
# this is specific to OS X
logging.debug('Checking /etc/localtime')
if os.path.exists('/etc/localtime'):
zone = os.path.realpath('/etc/localtime')
(zone, city) = os.path.split(zone);
(zone, continent) = os.path.split(zone);
zone = os.path.join(continent, city)
return zone
logging.debug('Checking .flashbake')
if 'timezone' in config.__dict__:
zone = config.timezone
return zone
logging.warn('Could not get TZ from env var, /etc/timezone, or .flashbake.')
zone = None
return zone
|