home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2737 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.6 KB  |  30 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. usage = 'testDCOM.py - Simple DCOM test\nUsage: testDCOM.py serverName\n\nAttempts to start the Python.Interpreter object on the named machine,\nand checks that the object is indeed running remotely.\n\nRequires the named server be configured to run DCOM (using dcomcnfg.exe),\nand the Python.Interpreter object installed and registered on that machine.\n\nThe Python.Interpreter object must be installed on the local machine,\nbut no special DCOM configuration should be necessary.\n'
  5. import pythoncom
  6. import win32com.client as win32com
  7. import win32api
  8. import string
  9. import sys
  10.  
  11. def test(serverName):
  12.     if string.lower(serverName) == string.lower(win32api.GetComputerName()):
  13.         print 'You must specify a remote server name, not the local machine!'
  14.         return None
  15.     clsctx = pythoncom.CLSCTX_SERVER & ~(pythoncom.CLSCTX_INPROC_SERVER)
  16.     ob = win32com.client.DispatchEx('Python.Interpreter', serverName, clsctx = clsctx)
  17.     ob.Exec('import win32api')
  18.     actualName = ob.Eval('win32api.GetComputerName()')
  19.     if string.lower(serverName) != string.lower(actualName):
  20.         print "Error: The object created on server '%s' reported its name as '%s'" % (serverName, actualName)
  21.     else:
  22.         print "Object created and tested OK on server '%s'" % serverName
  23.  
  24. if __name__ == '__main__':
  25.     if len(sys.argv) == 2:
  26.         test(sys.argv[1])
  27.     else:
  28.         print usage
  29.  
  30.