def test(self):
        self.failUnlessEqual(GUID(), GUID())
        self.failUnlessEqual(
            GUID("{00000000-0000-0000-C000-000000000046}"), GUID("{00000000-0000-0000-C000-000000000046}")
        )

        self.failUnlessEqual(
            str(GUID("{0002DF01-0000-0000-C000-000000000046}")), "{0002DF01-0000-0000-C000-000000000046}"
        )
        self.failUnlessEqual(
            repr(GUID("{0002DF01-0000-0000-C000-000000000046}")), 'GUID("{0002DF01-0000-0000-C000-000000000046}")'
        )

        self.assertRaises(WindowsError, GUID, "abc")
        self.assertRaises(WindowsError, GUID.from_progid, "abc")

        self.assertRaises(WindowsError, lambda guid: guid.as_progid(), GUID("{00000000-0000-0000-C000-000000000046}"))

        if os.name == "nt":
            self.failUnlessEqual(
                GUID.from_progid("InternetExplorer.Application"), GUID("{0002DF01-0000-0000-C000-000000000046}")
            )
            self.failUnlessEqual(
                GUID("{0002DF01-0000-0000-C000-000000000046}").as_progid(), u"InternetExplorer.Application.1"
            )
        elif os.name == "ce":
            self.failUnlessEqual(GUID.from_progid("JScript"), GUID("{f414c260-6ac0-11cf-b6d1-00aa00bbbb58}"))
            self.failUnlessEqual(GUID("{f414c260-6ac0-11cf-b6d1-00aa00bbbb58}").as_progid(), u"JScript")

        self.failIfEqual(GUID.create_new(), GUID.create_new())
Beispiel #2
0
 def __init__(self, guid=None, content=None):
     if guid is None:
         guid = str(GUID.create_new())
     elif isinstance(guid, Password):
         guid = guid.guid
     if content is not None:
         self.database[guid] = content
     self.guid = guid
Beispiel #3
0
 def GetData(self):
     from comtypes import GUID
     self.guid = str(GUID.create_new())
     self.time = str(time.time())
     attr = []
     attr.append(('Version', str(eg.Version.string)))
     attr.append(('Guid', self.guid))
     attr.append(('Time', self.time))
     return attr, None
Beispiel #4
0
 def GetData(self):
     from comtypes import GUID
     attr, text = ContainerItem.GetData(self)
     self.guid = str(GUID.create_new())
     self.time = str(time.time())
     attr.append(('Version', str(eg.revision)))
     attr.append(('Guid', self.guid))
     attr.append(('Time', self.time))
     return attr, text
    def test_derived(self):
        # XXX leaks 50 refs
        self.failUnlessEqual(method_count(IUnknown), 3)

        class IMyInterface(IUnknown):
            pass

        self.failUnlessEqual(method_count(IMyInterface), 3)

        # assigning _methods_ does not work until we have an _iid_!
        self.assertRaises(AttributeError, setattr, IMyInterface, "_methods_", [])
        IMyInterface._iid_ = GUID.create_new()
        IMyInterface._methods_ = []
        self.failUnlessEqual(method_count(IMyInterface), 3)

        IMyInterface._methods_ = [STDMETHOD(HRESULT, "Blah", [])]
        self.failUnlessEqual(method_count(IMyInterface), 4)
Beispiel #6
0
    def __init__(self,):
        self._config_filename = 'config.yaml'
        self._config_directory = os.path.dirname(os.path.abspath(__file__))

        self._expected_num_sliders = None
        self._com_port = None
        self._baud_rate = None
        self._slider_values = None

        self._settings = None

        self._load_settings()

        self._sessions = None
        self._master_session = None

        self._devices = None

        self._last_session_refresh = None

        self._config_observer = None
        self._stopped = False

        self._lpcguid = pointer(GUID.create_new())
Beispiel #7
0
def ExecAs(scriptPath, asAdministrator, funcName, *args, **kwargs):
    pipeName = "\\\\.\\pipe\\" + str(GUID.create_new())
    Msg("creating named pipe")
    hPipe = CreateNamedPipe(
        pipeName,
        PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
        PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
        PIPE_UNLIMITED_INSTANCES,
        BUFSIZE,
        BUFSIZE,
        0,
        None
    )
    if hPipe == INVALID_HANDLE_VALUE:
        raise Exception("Error in creating Named Pipe")
    overlapped = OVERLAPPED()
    overlapped.hEvent = CreateEvent(None, 1, 0, None)
    try:
        Msg("calling ConnectNamedPipe")
        ConnectNamedPipe(hPipe, byref(overlapped))
        localPath = dirname(__file__.decode('mbcs'))
        Msg("starting subprocess")
        hProcess = RunAs(
            abspath(join(localPath, "..", "..", "EventGhost.exe")),
            asAdministrator,
            "-execfile",
            GetUncPathOf(join(localPath, "PipedProcessClient.py")),
            pipeName,
            str(eg.debugLevel)
        )
        Msg("waiting for subprocess to connect")
        pHandles = (HANDLE * 2)(overlapped.hEvent, hProcess)
        ret = WaitForMultipleObjects(2, pHandles, 0, 25000)
        if ret == WAIT_OBJECT_0:
            # connect event
            Msg("got connect event")
        elif ret == WAIT_OBJECT_0 + 1:
            raise Exception("Unexpected end of subprocess.")
        elif ret == WAIT_TIMEOUT:
            raise Exception("Timeout in waiting for subprocess.")
        else:
            raise Exception("Unknown return value")

        Msg("sending startup message")
        WritePipeMessage(
            hPipe,
            MESSAGE_ARGS,
            (GetUncPathOf(scriptPath), funcName, args, kwargs)
        )
        chBuf = create_string_buffer(BUFSIZE)
        cbRead = DWORD(0)
        while True:
            fSuccess = ReadFile(hPipe, chBuf, BUFSIZE, byref(cbRead), None)
            if ((fSuccess == 1) or (cbRead.value != 0)):
                code, data = loads(chBuf.value)
                if code == MESSAGE_STDERR:
                    sys.stderr.write(data)
                elif code == MESSAGE_STDOUT:
                    sys.stdout.write(data)
                elif code == MESSAGE_RESULT:
                    result = data
                    break
                elif code == MESSAGE_EXCEPTION:
                    break
                else:
                    raise Exception("Unknown message type %r" % code)
        FlushFileBuffers(hPipe)
        DisconnectNamedPipe(hPipe)
    finally:
        CloseHandle(hPipe)
        CloseHandle(overlapped.hEvent)
    if code == MESSAGE_EXCEPTION:
        raise Exception("Child process raised an exception\n" + data)
    return result
Beispiel #8
0
def ExecAs(scriptPath, asAdministrator, funcName, *args, **kwargs):
    pipeName = "\\\\.\\pipe\\" + str(GUID.create_new())
    Msg("creating named pipe")
    hPipe = CreateNamedPipe(
        pipeName,
        PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
        PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
        PIPE_UNLIMITED_INSTANCES,
        BUFSIZE,
        BUFSIZE,
        0,
        None
    )
    if hPipe == INVALID_HANDLE_VALUE:
        raise Exception("Error in creating Named Pipe")
    overlapped = OVERLAPPED()
    overlapped.hEvent = CreateEvent(None, 1, 0, None)
    try:
        Msg("calling ConnectNamedPipe")
        ConnectNamedPipe(hPipe, byref(overlapped))
        localPath = dirname(__file__.decode('mbcs'))
        Msg("starting subprocess")
        hProcess = RunAs(
            abspath(join(localPath, "..", "..", "EventGhost.exe")),
            asAdministrator,
            "-execfile",
            GetUncPathOf(join(localPath, "PipedProcessClient.py")),
            pipeName,
            str(eg.debugLevel)
        )
        Msg("waiting for subprocess to connect")
        pHandles = (HANDLE * 2)(overlapped.hEvent, hProcess)
        ret = WaitForMultipleObjects(2, pHandles, 0, 25000)
        if ret == WAIT_OBJECT_0:
            # connect event
            Msg("got connect event")
        elif ret == WAIT_OBJECT_0 + 1:
            raise Exception("Unexpected end of subprocess.")
        elif ret == WAIT_TIMEOUT:
            raise Exception("Timeout in waiting for subprocess.")
        else:
            raise Exception("Unknown return value")

        Msg("sending startup message")
        WritePipeMessage(
            hPipe,
            MESSAGE_ARGS,
            (GetUncPathOf(scriptPath), funcName, args, kwargs)
        )
        chBuf = create_string_buffer(BUFSIZE)
        cbRead = DWORD(0)
        while True:
            fSuccess = ReadFile(hPipe, chBuf, BUFSIZE, byref(cbRead), None)
            if ((fSuccess == 1) or (cbRead.value != 0)):
                code, data = loads(chBuf.value)
                if code == MESSAGE_STDERR:
                    sys.stderr.write(data)
                elif code == MESSAGE_STDOUT:
                    sys.stdout.write(data)
                elif code == MESSAGE_RESULT:
                    result = data
                    break
                elif code == MESSAGE_EXCEPTION:
                    break
                else:
                    raise Exception("Unknown message type %r" % code)
        FlushFileBuffers(hPipe)
        DisconnectNamedPipe(hPipe)
    finally:
        CloseHandle(hPipe)
        CloseHandle(overlapped.hEvent)
    if code == MESSAGE_EXCEPTION:
        raise Exception("Child process raised an exception\n" + data)
    return result
Beispiel #9
0
 class IDerived(IBase):
     _iid_ = GUID.create_new()
Beispiel #10
0
 class IBase(IUnknown):
     _iid_ = GUID.create_new()