[Dextrose] [PATCH 52/54] sl#2713: Add last updated on field to CP/About my computer

Bernie Innocenti bernie at sugarlabs.org
Wed Nov 9 15:20:52 EST 2011


On Tue, 2011-11-08 at 23:19 +0530, Anish Mangal wrote:

> +    # If we reached here, we have the last-update-time, but it's in
> +    # timestamp format.
> +    # Using python-subprocess-module (no shell involved), to convert
> +    # it into readable date-format; the hack being used (after
> +    # removing '-u' option) is the first one mentioned at :
> +    # http://www.commandlinefu.com/commands/view/3719/convert-unix-timestamp-to-date
> +    environment = os.environ.copy()
> +    environment['PATH'] = '%s:/usr/sbin' % (environment['PATH'], )

Why we need to add /usr/sbin to the path?


> +    last_update_readable_format = {}
> +    try:
> +        last_update_readable_format = \
> +                 subprocess.Popen(['date', '-d',
> +                                   '1970-01-01 + ' +
> +                                   strlast_update_unix_seconds) +
> +                                   ' seconds'],
> +                                   stdout=subprocess.PIPE,
> +                                   env=environment).stdout.readlines()[0]
> +    except:
> +        msg_str = ('There was some error in the processing of'
> +                  '\nlast-update-time. Please contact Support.')
> +        _logger.exception(msg_str)
> +        return _(msg_str)
> +
> +    if not last_update_readable_format:
> +        return _('There was some error in the processing of\n'
> +                 'last-update-time. Please contact Support.')

Why not replace all the above with:

   import time
   time.asctime(time.localtime(last_update_unix_seconds))

-- 
Bernie Innocenti
Sugar Labs Infrastructure Team
http://wiki.sugarlabs.org/go/Infrastructure_Team



More information about the Dextrose mailing list