# Path: gslib/exception.py
# class CommandException(StandardError):
#   """Exception raised when a problem is encountered running a gsutil command.
# 
#   This exception should be used to signal user errors or system failures
#   (like timeouts), not bugs (like an incorrect param value). For the
#   latter you should raise Exception so we can see where/how it happened
#   via gsutil -D (which will include a stack trace for raised Exceptions).
#   """
# 
#   def __init__(self, reason, informational=False):
#     """Instantiate a CommandException.
# 
#     Args:
#       reason: Text describing the problem.
#       informational: Indicates reason should be printed as FYI, not a failure.
#     """
#     StandardError.__init__(self)
#     self.reason = reason
#     self.informational = informational
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'CommandException: %s' % self.reason


from calendar import timegm
from gslib.exception import CommandException
from gslib.tz_utc import UTC
from gslib.utils.metadata_util import CreateCustomMetadata
from gslib.utils.metadata_util import GetValueFromObjectCustomMetadata
from gslib.utils.system_util import IS_WINDOWS
from gslib.utils.unit_util import SECONDS_PER_DAY
import getpass
import logging
import os
import re
import time
import six
  import grp
  import pwd
      mtime_tmp = os.stat(path).st_mtime
      os.utime(path, (atime, mtime_tmp))
    elif atime <= NA_TIME and mtime > NA_TIME:
      # mtime is valid but atime isn't
      atime_tmp = os.stat(path).st_atime
      os.utime(path, (atime_tmp, mtime))
    if IS_WINDOWS:
      # Windows doesn't use POSIX uid/gid/mode unlike other systems. So there's
      # no point continuing.
      return
    # Only root can change ownership.
    if found_uid and os.geteuid() == 0:
      uid = int(uid)
    else:
      uid = NA_ID
    if found_gid:
      gid = int(gid)
    if uid > NA_ID and gid > NA_ID:
      # Set both uid and gid.
      os.chown(path, uid, gid)
    elif uid > NA_ID and gid <= NA_ID:
      # uid is valid but gid isn't.
      os.chown(path, uid, -1)
    elif uid <= NA_ID and gid > NA_ID:
      # gid is valid but uid isn't.
      os.chown(path, -1, gid)
    if found_mode:
      mode = int(str(mode), 8)
      os.chmod(path, mode)
  except ValueError:

# Path: gslib/exception.py
# class CommandException(StandardError):
#   """Exception raised when a problem is encountered running a gsutil command.
# 
#   This exception should be used to signal user errors or system failures
#   (like timeouts), not bugs (like an incorrect param value). For the
#   latter you should raise Exception so we can see where/how it happened
#   via gsutil -D (which will include a stack trace for raised Exceptions).
#   """
# 
#   def __init__(self, reason, informational=False):
#     """Instantiate a CommandException.
# 
#     Args:
#       reason: Text describing the problem.
#       informational: Indicates reason should be printed as FYI, not a failure.
#     """
#     StandardError.__init__(self)
#     self.reason = reason
#     self.informational = informational
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'CommandException: %s' % self.reason


# Path: gslib/utils/posix_util.py
from calendar import timegm
from gslib.exception import CommandException
from gslib.tz_utc import UTC
from gslib.utils.metadata_util import CreateCustomMetadata
from gslib.utils.metadata_util import GetValueFromObjectCustomMetadata
from gslib.utils.system_util import IS_WINDOWS
from gslib.utils.unit_util import SECONDS_PER_DAY
import getpass
import logging
import os
import re
import time
import six
  import grp
  import pwd

      mtime_tmp = os.stat(path).st_mtime
      os.utime(path, (atime, mtime_tmp))
    elif atime <= NA_TIME and mtime > NA_TIME:
      # mtime is valid but atime isn't
      atime_tmp = os.stat(path).st_atime
      os.utime(path, (atime_tmp, mtime))
    if IS_WINDOWS:
      # Windows doesn't use POSIX uid/gid/mode unlike other systems. So there's
      # no point continuing.
      return
    # Only root can change ownership.
    if found_uid and os.geteuid() == 0:
      uid = int(uid)
    else:
      uid = NA_ID
    if found_gid:
      gid = int(gid)
    if uid > NA_ID and gid > NA_ID:
      # Set both uid and gid.
      os.chown(path, uid, gid)
    elif uid > NA_ID and gid <= NA_ID:
      # uid is valid but gid isn't.
      os.chown(path, uid, -1)
    elif uid <= NA_ID and gid > NA_ID:
      # gid is valid but uid isn't.
      os.chown(path, -1, gid)
    if found_mode:
      mode = int(str(mode), 8)
      os.chmod(path, mode)
  except ValueError:

    raise CommandException('Check POSIX attribute values for %s' %