Advertisement
Guest User

comtypes

a guest
Jul 18th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import logging
  2. formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
  3. logger = logging.getLogger()
  4. logger.setLevel(logging.DEBUG)
  5. fh = logging.FileHandler('log_filename.txt')
  6. fh.setLevel(logging.DEBUG)
  7. fh.setFormatter(formatter)
  8. logger.addHandler(fh)
  9.  
  10. ch = logging.StreamHandler()
  11. ch.setLevel(logging.DEBUG)
  12. ch.setFormatter(formatter)
  13. logger.addHandler(ch)
  14.  
  15.    
  16. from subprocess import Popen, PIPE, STDOUT, CREATE_NEW_CONSOLE
  17. import subprocess
  18. import comtypes
  19. # A little test server, complete with typelib, we can use for testing.
  20. # Originally submitted with bug:
  21. # [ 753154 ] memory leak wrapping object having _typelib_guid_ attribute
  22. # but modified by mhammond for use as part of the test suite.
  23. import sys, os
  24.  
  25. import comtypes
  26. import comtypes.server.localserver
  27.  
  28. from comtypes.client import GetModule
  29. # generate wrapper code for the type library, this needs
  30. # to be done only once (but also each time the IDL file changes)
  31. GetModule("pippo.tlb")
  32.  
  33. from comtypes.gen.TESTSERVERLib import Pippo
  34.  
  35. class CPippo(Pippo):
  36.     # registry entries
  37.     _reg_threading_ = "Both"
  38.     _reg_progid_ = "Python.Test.Pippo"
  39.     _reg_novers_progid_ = "Python.Test.Pippo.3"
  40.     _reg_desc_ = "Pippo Python test object1.1"
  41.     _reg_clsctx_ =  comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER
  42.     #_regcls_ = comtypes.server.localserver.REGCLS_MULTIPLEUSE
  43.  
  44.     def __init__(self):
  45.         self.MyProp1 = 10
  46.  
  47.     def Method1(self):
  48.         return wrap(CPippo())
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. if __name__=='__main__':
  56.     #main(sys.argv)
  57.     from comtypes.server.register import UseCommandLine
  58.     print comtypes.server.register.UseCommandLine(CPippo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement