def uptime(total_seconds):
    """
    Gives a human-readable uptime string
    Thanks to http://thesmithfam.org/blog/2005/11/19/python-uptime-script/
    (modified to look like the real uptime command)
    """
    total_seconds = float(total_seconds)

    # Helper vars:
    MINUTE = 60
    HOUR = MINUTE * 60
    DAY = HOUR * 24

    # Get the days, hours, etc:
    days = int(total_seconds / DAY)
    hours = int((total_seconds % DAY) / HOUR)
    minutes = int((total_seconds % HOUR) / MINUTE)

    # 14 days,  3:53
    # 11 min

    s = ''
    if days > 0:
        s += str(days) + " " + (days == 1 and "day" or "days") + ", "
    if len(s) > 0 or hours > 0:
        s += '{}:{}'.format(str(hours).rjust(2), str(minutes).rjust(2, '0'))
    else:
        s += '{} min'.format(str(minutes))
    return s