(io_lib, assertion_type,
                         assertion_level, assertion_reason)
return assertion_error, assertion_id
Creates a power assertion.

  IOPMAssertionCreate allows a process to assert a 'power assertion' to
  prevent display or system sleep while the assertion is active.

  The command-line equivalent for power assertions is '/usr/bin/pmset'.
  NB: it is not possible to create an assertion which prevents a forced
  system sleep, such as a lid close, low battery sleep, thermal sleep, etc.

  For more information on IOPMLib calls, see Apple's IOPMLib.h Reference:
  https://developer.apple.com/library/mac/#documentation/IOKit
      /Reference/IOPMLib_header_reference

  Args:
    io_lib: IOKit library from ConfigureIOKit()
    assertion_type: str, IOPMAssertionType:
        PreventUserIdleSystemSleep
        PreventUserIdleDisplaySleep
        PreventSystemSleep
        NoIdleSleepAssertion - preferred assertion, enforces screen lock
        NoDisplaySleepAssertion
    assertion_level: int, 0-255
    assertion_reason: str, reason for assertion, which will be displayed to the
        user when 'pmset -g assertions' is invoked

  Returns:
    assertion_error: 0 if successful, stderr otherwise
    assertion_id: c_uint, assertion identification number
Creates a power assertion.
Creates a power assertion .
def CreatePowerAssertion(io_lib, assertion_type,
                         assertion_level, assertion_reason):
  """Creates a power assertion.

  IOPMAssertionCreate allows a process to assert a 'power assertion' to
  prevent display or system sleep while the assertion is active.

  The command-line equivalent for power assertions is '/usr/bin/pmset'.
  NB: it is not possible to create an assertion which prevents a forced
  system sleep, such as a lid close, low battery sleep, thermal sleep, etc.

  For more information on IOPMLib calls, see Apple's IOPMLib.h Reference:
  https://developer.apple.com/library/mac/#documentation/IOKit
      /Reference/IOPMLib_header_reference

  Args:
    io_lib: IOKit library from ConfigureIOKit()
    assertion_type: str, IOPMAssertionType:
        PreventUserIdleSystemSleep
        PreventUserIdleDisplaySleep
        PreventSystemSleep
        NoIdleSleepAssertion - preferred assertion, enforces screen lock
        NoDisplaySleepAssertion
    assertion_level: int, 0-255
    assertion_reason: str, reason for assertion, which will be displayed to the
        user when 'pmset -g assertions' is invoked

  Returns:
    assertion_error: 0 if successful, stderr otherwise
    assertion_id: c_uint, assertion identification number
  """
  assertion_id = ctypes.c_uint32(0)
  assertion_type = StrToCFString(assertion_type)
  assertion_reason = StrToCFString(assertion_reason)
  assertion_error = io_lib.IOPMAssertionCreateWithName(
      assertion_type,
      assertion_level,
      assertion_reason,
      ctypes.byref(assertion_id))
  return assertion_error, assertion_id
def CreatePowerAssertion ( io_lib , assertion_type , assertion_level , assertion_reason ) : assertion_id = ctypes . c_uint32 ( 0 ) assertion_type = StrToCFString ( assertion_type ) assertion_reason = StrToCFString ( assertion_reason ) assertion_error = io_lib . IOPMAssertionCreateWithName ( assertion_type , assertion_level , assertion_reason , ctypes . byref ( assertion_id ) ) return assertion_error , assertion_id