K
kyosohma
Hi,
I am trying to create a post logon script which does various tasks,
like setup a printer based on location. While most of it works very
fast, I have a second Python script that I run that scans the PC using
WMI (among other things) and writes the following to a database: Name,
Username, Machine, IP, Login Date,CPU,Memory.
The problem I have is that since I import WMI, it takes a long time
and we have users complaining about it. So I stuck the import
statement into a separate thread and set it to a daemon so it could do
its thing in the background and the rest of the script would finish
and exit.
Unfortunately, I get the following error when I do this:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 444, in __bootstrap
self.run()
File "C:\Python24\lib\threading.py", line 424, in run
self.__target(*self.__args, **self.__kwargs)
File "//serverName/Scripts/PostLogon_MT.py", line 35, in InvThread
import db_inventory
File "\\serverName\PythonPackages\Utilities\db_inventory.py", line
3, in ?
import wmi
File "C:\Python24\lib\site-packages\wmi.py", line 204, in ?
obj = GetObject ("winmgmts:")
File "C:\Python24\lib\site-packages\win32com\client\__init__.py",
line 73, in GetObject
return Moniker(Pathname, clsctx)
File "C:\Python24\lib\site-packages\win32com\client\__init__.py",
line 88, in Moniker
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
com_error: (-2147221020, 'Invalid syntax', None, None)
If I import the module without using threading, it works fine, but
takes forever. Even after it threw that error above, the process
didn't stop and I had to kill it with a control+C.
I am using Windows XP with Python 2.4. Thanks for any help you can
give.
Mike
I am trying to create a post logon script which does various tasks,
like setup a printer based on location. While most of it works very
fast, I have a second Python script that I run that scans the PC using
WMI (among other things) and writes the following to a database: Name,
Username, Machine, IP, Login Date,CPU,Memory.
The problem I have is that since I import WMI, it takes a long time
and we have users complaining about it. So I stuck the import
statement into a separate thread and set it to a daemon so it could do
its thing in the background and the rest of the script would finish
and exit.
Unfortunately, I get the following error when I do this:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 444, in __bootstrap
self.run()
File "C:\Python24\lib\threading.py", line 424, in run
self.__target(*self.__args, **self.__kwargs)
File "//serverName/Scripts/PostLogon_MT.py", line 35, in InvThread
import db_inventory
File "\\serverName\PythonPackages\Utilities\db_inventory.py", line
3, in ?
import wmi
File "C:\Python24\lib\site-packages\wmi.py", line 204, in ?
obj = GetObject ("winmgmts:")
File "C:\Python24\lib\site-packages\win32com\client\__init__.py",
line 73, in GetObject
return Moniker(Pathname, clsctx)
File "C:\Python24\lib\site-packages\win32com\client\__init__.py",
line 88, in Moniker
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
com_error: (-2147221020, 'Invalid syntax', None, None)
If I import the module without using threading, it works fine, but
takes forever. Even after it threw that error above, the process
didn't stop and I had to kill it with a control+C.
I am using Windows XP with Python 2.4. Thanks for any help you can
give.
Mike