예제 #1
0
        pid[0] = id(self)
        return S_OK

    def DTestDispServer_Exec(self, this, what):
        exec(what)
        return S_OK

    def DTestDispServer_Exec2(self, what):
        exec(what)

    _name = "spam, spam, spam"

    # Implementation of the DTestDispServer::Name propget
    def DTestDispServer__get_name(self, this, pname):
        pname[0] = self._name
        return S_OK

    # Implementation of the DTestDispServer::Name propput
    def DTestDispServer__set_name(self, this, name):
        self._name = name
        return S_OK

    # Implementation of the DTestDispServer::SetName method
    def DTestDispServer_sEtNaMe(self, name):
        self._name = name


if __name__ == "__main__":
    from comtypes.server.register import UseCommandLine
    UseCommandLine(TestDispServer)
예제 #2
0
        return self.bridge.load_model(str(modelSaveDir))

    def step(self, timestampStr, names, values):
        names = get_array(names)
        values = get_array(values)
        if timestampStr is not None:
            timestampStr = str(timestampStr)
        return self.bridge.step(timestampStr, names, values)

    def save_model(self, modelSaveDir):
        return self.bridge.save_model(str(modelSaveDir))

    def init(self, predictedField, predictedSteps):
        return self.bridge.init(str(predictedField), predictedSteps)

    def test(self, this=None):
        return self.bridge.test(this)


## Was necessary for Python.NET integration
#def create_nupic_bridge():
#    return NupicBridgeClass()
##
if __name__ == "__main__":
    if len(sys.argv) > 1 and sys.argv[1] == "test":
        bridge = nupic_bridge()
        bridge.test()
    else:
        from comtypes.server.register import UseCommandLine
        UseCommandLine(NupicBridgeImpl)
예제 #3
0
        pTextElement = NewObj(esriCarto.TextElement, esriCarto.ITextElement)
        pTextElement.Symbol = pTextSymbol
        pTextElement.Text = RandomQuote()
        pElement = CType(pTextElement, esriCarto.IElement)
        pElement.Geometry = pPoint
        pGC = CType(pMap, esriCarto.IGraphicsContainer)
        pGC.AddElement(pElement, 0)
        pGCSel = CType(pMap, esriCarto.IGraphicsContainerSelect)
        pGCSel.SelectElement(pElement)
        iOpt = esriCarto.esriViewGraphics + \
               esriCarto.esriViewGraphicSelection
        pAV.PartialRefresh(iOpt, None, None)
        return

    def Deactivate(self):
        return True


#**** Registration ****

if __name__ == "__main__":
    from comtypes.server.register import UseCommandLine
    sArg = ""
    if len(sys.argv) > 1:
        sArg = sys.argv[1]
    if sArg == "/unregserver" or sArg == "-unregserver":
        UnregisterCategory()
    UseCommandLine(MyToolImpl)
    if sArg == "/regserver" or sArg == "-regserver":
        RegisterCategory()
        return S_OK

    def ITestComServer__set_name(self, this, name):
        self._name = name
        return S_OK

##    def ITestComServer_SetName(self, this, name):
##        self._name = name
##        return S_OK

    def ITestComServer_sEtNaMe(self, this, name):
        # the method is spelled in a funny way to check case
        # insensitivity when implementing COM methods.
        self._name = name
        return S_OK

##    [id(18), helpstring("a method with [in] and [out] args in mixed order")]
##    HRESULT MixedInOut([in] int a, [out] int *b, [in] int c, [out] int *d);
    def MixedInOut(self, a, c):
        return a+1, c+1
    
if __name__ == "__main__":
    try:
        from comtypes.server.register import UseCommandLine
##    logging.basicConfig(level=logging.DEBUG)
        UseCommandLine(TestComServer)
    except Exception:
        import traceback
        traceback.print_exc()
        raw_input()
예제 #5
0
                    maxIm_obj.saveImage(
                        'C:\\Users\\astro\\Desktop\\Work\\polarimeter\\22June2020\\images\\image_{}_{}.fits'
                        .format(pol_filter, pol_position))

            # Home the polarimeter after exposing
            pol_obj.home()

            # Create a FITS cube and delete original images
            input = 'C:\\Users\\astro\\Desktop\\Work\\polarimeter\\22June2020\\images'
            output = 'C:\\Users\\astro\\Desktop\\Work\\polarimeter\\22June2020\\cubeImages'

            try:
                FitsCreationModified.SaveFitsFiles(input, output)
                FitsCreationModified.DeleteFitsFiles(input)
            except IOError:
                print("Missing files..")

        else:
            maxIm_obj.Expose(duration, light, filter)
            while maxIm_obj.ImageReady == False:
                time.sleep(1)
                print('waiting for exposure to be ready..')

        self.ReadyForDownload = True
        return True


if __name__ == "__main__":
    from comtypes.server.register import UseCommandLine
    UseCommandLine(PseudoMaxImImp)
예제 #6
0
                                          startOffset=None):
        # >= 0.5.1
        if startOffset == None:
            startOffset = dataOffset
            dataOffset = handle
            handle = unknown
            unknown = None

        return self._pyDbgEng.CreateThread(handle, unknown, dataOffset,
                                           startOffset)

    def IDebugEventCallbacks_ExitThread(self, unknown, exitCode=None):
        # >= 0.5.1
        if exitCode == None:
            exitCode = unknown
            unknown = None

        return self._pyDbgEng.ExitThread(unknown, exitCode)


if __name__ == "__main__":
    try:
        from comtypes.server.register import UseCommandLine
        UseCommandLine(DbgEngEventCallbacks)
    except Exception:
        import traceback
        traceback.print_exc()
        raw_input()

# end
예제 #7
0
import comtypes
import comtypes.server.localserver

from comtypes.client import GetModule
GetModule("mytypelib.tlb")

from comtypes.gen.MyTypeLib import MyObject

class MyObjectImpl(MyObject):
    # registry entries
    _reg_threading_ = "Both"
    _reg_progid_ = "MyTypeLib.MyObject.1"
    _reg_novers_progid_ = "MyTypeLib.MyObject"
    _reg_desc_ = "Simple COM server for testing"
    _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER
    _regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE

    def MyMethod(self, a, b):
        return a + b

if __name__ == "__main__":
    from comtypes.server.register import UseCommandLine
    UseCommandLine(MyObjectImpl)