Beispiel #1
0
    def __init__(self, computer, name):
        core._WinSysObject.__init__(self)
        self.computer = computer or "."
        self.name = name
        try:
            key = registry.registry(self.REG_ROOT % self.computer).get_key(self.name)
        except exc.x_winsys as err:
            warnings.warn("Registry access failed with error: %s; log access may still be possible" % err.args[-1])
            values = dict()
        else:
            if key:
                values = dict(key.values())
            else:
                raise exc.x_not_found(None, "EventLog", r"\\%s\%s" % (self.computer, self.name))

        self.auto_backup_log_files = values.get("AutoBackupLogFiles")
        self.display_name_file = values.get("DisplayNameFile")
        self.display_name_id = values.get("DisplayNameID")
        self.file = values.get("File")
        self.max_size = values.get("MaxSize")
        self.primary_module = values.get("PrimaryModule")
        self.restrict_guest_access = values.get("RestrictGuestAccess")
        self.retention = values.get("Retention")
        self.sources = values.get("Sources")
        self._handle = wrapped(win32evtlog.OpenEventLog, self.computer, self.name)
Beispiel #2
0
    def __init__(self, computer, name):
        core._WinSysObject.__init__(self)
        self.computer = computer or "."
        self.name = name
        try:
            key = registry.registry(self.REG_ROOT % self.computer).get_key(
                self.name)
        except exc.x_winsys as err:
            warnings.warn(
                "Registry access failed with error: %s; log access may still be possible"
                % err.args[-1])
            values = dict()
        else:
            if key:
                values = dict(key.values())
            else:
                raise exc.x_not_found(None, "EventLog",
                                      r"\\%s\%s" % (self.computer, self.name))

        self.auto_backup_log_files = values.get("AutoBackupLogFiles")
        self.display_name_file = values.get("DisplayNameFile")
        self.display_name_id = values.get("DisplayNameID")
        self.file = values.get("File")
        self.max_size = values.get("MaxSize")
        self.primary_module = values.get("PrimaryModule")
        self.restrict_guest_access = values.get("RestrictGuestAccess")
        self.retention = values.get("Retention")
        self.sources = values.get("Sources")
        self._handle = wrapped(win32evtlog.OpenEventLog, self.computer,
                               self.name)
Beispiel #3
0
    def pyobject(self):
        """Lazily return an internal registry key handle according to the instance's
        access requirements.

        :raises: :exc:`x_not_found` if the registry path the key refers to does not exist
        """
        if self.hKey is None:
            hKey, moniker, _ = self._from_string(self.moniker, access=self.access, accept_value=False)
            utils._set(self, "hKey", hKey)
            if self.hKey is None:
                raise exc.x_not_found(errctx="Registry.pyobject", errmsg="Registry path %s not found" % moniker)
        return self.hKey
Beispiel #4
0
    def pyobject(self):
        """Lazily return an internal registry key handle according to the instance's
        access requirements.

        :raises: :exc:`x_not_found` if the registry path the key refers to does not exist
        """
        if self.hKey is None:
            hKey, moniker, _ = self._from_string(self.moniker,
                                                 access=self.access,
                                                 accept_value=False)
            utils._set(self, "hKey", hKey)
            if self.hKey is None:
                raise exc.x_not_found(errctx="Registry.pyobject",
                                      errmsg="Registry path %s not found" %
                                      moniker)
        return self.hKey
Beispiel #5
0
 def __init__(self, computer, log_name, source_name):
     core._WinSysObject.__init__(self)
     self.computer = computer or "."
     self.log_name = log_name or DEFAULT_LOG_NAME
     self.name = source_name
     key = registry.registry(
         r"%s\%s\%s" %
         (EventLog.REG_ROOT % self.computer, self.log_name, self.name))
     if not key:
         raise exc.x_not_found(
             None, "EventSource",
             r"\\%s\%s\%s" % (self.computer, self.log_name, self.name))
     self._handle = None
     values = dict(key.values())
     types = dict((name, type)
                  for (name, value, type) in key.values(_want_types=True))
     self.category_count = values.get("CategoryCount")
     self.category_message_file = values.get("CategoryMessageFile")
     self.event_message_file = values.get("EventMessageFile")
     self.parameter_message_file = values.get("ParameterMessageFile")
     types_supported = values.get("TypesSupported") or 0
     #
     # This is messy because, although TypeSupported is specified
     # as a DWORD and constitutes a set of flags, it seems to be
     # implemented in any number of ingenious ways, including
     # binary data representing a number and a string representing
     # the hexadecimal value of the flags.
     #
     try:
         self.types_supported = int(types_supported or 0)
     except ValueError:
         types_type = types.get("TypesSupported")
         if types_type == registry.REGISTRY_VALUE_TYPE.REG_SZ:
             if types_supported.startswith("0x"):
                 self.types_supported = int(types_supported, 16)
             else:
                 self.types_supported = int(types_supported, 10)
         elif types_type == registry.REGISTRY_VALUE_TYPE.REG_BINARY:
             self.types_supported, = struct.unpack("L", types_supported)
         else:
             raise x_event_logs(None, None,
                                "Can't determine types supported")
Beispiel #6
0
 def __init__(self, computer, log_name, source_name):
     core._WinSysObject.__init__(self)
     self.computer = computer or "."
     self.log_name = log_name or DEFAULT_LOG_NAME
     self.name = source_name
     key = registry.registry(r"%s\%s\%s" % (EventLog.REG_ROOT % self.computer, self.log_name, self.name))
     if not key:
         raise exc.x_not_found(None, "EventSource", r"\\%s\%s\%s" % (self.computer, self.log_name, self.name))
     self._handle = None
     values = dict(key.values())
     types = dict((name, type) for (name, value, type) in key.values(_want_types=True))
     self.category_count = values.get("CategoryCount")
     self.category_message_file = values.get("CategoryMessageFile")
     self.event_message_file = values.get("EventMessageFile")
     self.parameter_message_file = values.get("ParameterMessageFile")
     types_supported = values.get("TypesSupported") or 0
     #
     # This is messy because, although TypeSupported is specified
     # as a DWORD and constitutes a set of flags, it seems to be
     # implemented in any number of ingenious ways, including
     # binary data representing a number and a string representing
     # the hexadecimal value of the flags.
     #
     try:
         self.types_supported = int(types_supported or 0)
     except ValueError:
         types_type = types.get("TypesSupported")
         if types_type == registry.REGISTRY_VALUE_TYPE.REG_SZ:
             if types_supported.startswith("0x"):
                 self.types_supported = int(types_supported, 16)
             else:
                 self.types_supported = int(types_supported, 10)
         elif types_type == registry.REGISTRY_VALUE_TYPE.REG_BINARY:
             self.types_supported, = struct.unpack("L", types_supported)
         else:
             raise x_event_logs(None, None, "Can't determine types supported")
Beispiel #7
0
  REG_ROOT = r"\\%s\HKLM\SYSTEM\CurrentControlSet\Services\Eventlog"

  def __init__ (self, computer, name):
    core._WinSysObject.__init__ (self)
    self.computer = computer or "."
    self.name = name
    try:
      key = registry.registry (self.REG_ROOT % self.computer).get_key (self.name)
    except exc.x_winsys, err:
      warnings.warn ("Registry access failed with error: %s; log access may still be possible" % err.args[-1])
      values = dict ()
    else:
      if key:
        values = dict (key.values ())
      else:
        raise exc.x_not_found (None, "EventLog", r"\\%s\%s" % (self.computer, self.name))

    self.auto_backup_log_files = values.get ("AutoBackupLogFiles")
    self.display_name_file = values.get ("DisplayNameFile")
    self.display_name_id = values.get ("DisplayNameID")
    self.file = values.get ("File")
    self.max_size = values.get ("MaxSize")
    self.primary_module = values.get ("PrimaryModule")
    self.restrict_guest_access = values.get ("RestrictGuestAccess")
    self.retention = values.get ("Retention")
    self.sources = values.get ("Sources")
    self._handle = wrapped (win32evtlog.OpenEventLog, self.computer, self.name)

  def as_string (self):
    return r"%s\%s" % (self.computer, self.name)
        core._WinSysObject.__init__(self)
        self.computer = computer or "."
        self.name = name
        try:
            key = registry.registry(self.REG_ROOT % self.computer).get_key(
                self.name)
        except exc.x_winsys, err:
            warnings.warn(
                "Registry access failed with error: %s; log access may still be possible"
                % err.args[-1])
            values = dict()
        else:
            if key:
                values = dict(key.values())
            else:
                raise exc.x_not_found(None, "EventLog",
                                      r"\\%s\%s" % (self.computer, self.name))

        self.auto_backup_log_files = values.get("AutoBackupLogFiles")
        self.display_name_file = values.get("DisplayNameFile")
        self.display_name_id = values.get("DisplayNameID")
        self.file = values.get("File")
        self.max_size = values.get("MaxSize")
        self.primary_module = values.get("PrimaryModule")
        self.restrict_guest_access = values.get("RestrictGuestAccess")
        self.retention = values.get("Retention")
        self.sources = values.get("Sources")
        self._handle = wrapped(win32evtlog.OpenEventLog, self.computer,
                               self.name)

    def as_string(self):
        return r"%s\%s" % (self.computer, self.name)