I'm working with IIS on W2K server. I'm trying to
use module "wmi" in a CGI script but with no success.
The following works:
import cgitb; cgitb.enable()
cgi.test()
.... but the following isn't working:
import cgitb; cgitb.enable()
import wmi ## fails here, with msg "wmi undefined"
cgi.test()
Any ideas? I can import all the other modules (e.g. sys)
except "wmi". Also, when I run the same script in IDLE
(cgi stuff removed), it works. Sys.path has all the needed
directories, including script's directory, and WMI's
directory. 4 6284
MK wrote: I'm working with IIS on W2K server. I'm trying to use module "wmi" in a CGI script but with no success.
The following works:
import cgitb; cgitb.enable() cgi.test()
... but the following isn't working:
import cgitb; cgitb.enable() import wmi ## fails here, with msg "wmi undefined" cgi.test()
Does it really just say "wmi undefined"? If not, please
cut and paste the precise traceback which you really get.
-Peter
"Peter Hansen" <pe***@engcorp. com> wrote
[...]
Hello Peter! This is what I get back in browser's window:
com_error
Python 2.2.2: C:\python\pytho n.exe
Sun Jul 20 20:45:23 2003
A problem occurred in a Python script. Here is the sequence of function
calls leading up to the error, in the order they occurred.
----------------------------------------------------------------------------
----
C:\python\testc gi\index.pycgi
2 import cgitb; cgitb.enable()
3 import wmi [MK comment: this line colored with a bright color!]
4 import sys
5
6 cgi.test()
wmi undefined
----------------------------------------------------------------------------
----
C:\python\testc gi\wmi.py
114 # Do just enough to ensure constants are available
115 #
116 obj = win32com.client .GetObject ("winmgmts:" ) [MK comment: colored
with a bright color!]
117 win32com.client .gencache.Ensur eDispatch (obj._oleobj_)
118 del obj
obj undefined, win32com = <module 'win32com' from
'C:\python\lib\ site-packages\win32c om\__init__.pyc '>, win32com.client =
<module 'win32com.clien t' from
'C:\python\lib\ site-packages\win32c om\client\__ini t__.pyc'>,
win32com.client .GetObject = <function GetObject at 0x00A42DA8>
----------------------------------------------------------------------------
----
C:\python\lib\s ite-packages\win32c om\client\__ini t__.py in
GetObject(Pathn ame='winmgmts:' , Class=None, clsctx=23)
71 return GetActiveObject (Class, clsctx)
72 else:
73 return Moniker(Pathnam e, clsctx) [MK comment: colored with a
bright color!]
74
75 def GetActiveObject (Class, clsctx = pythoncom.CLSCT X_ALL):
global Moniker = <function Moniker at 0x00A3D210>, Pathname = 'winmgmts:',
clsctx = 23
----------------------------------------------------------------------------
----
C:\python\lib\s ite-packages\win32c om\client\__ini t__.py in
Moniker(Pathnam e='winmgmts:', clsctx=23)
86 Python friendly version of GetObject's moniker functionality.
87 """
88 moniker, i, bindCtx = pythoncom.MkPar seDisplayName(P athname)
89 dispatch = moniker.BindToO bject(bindCtx, None,
pythoncom.IID_I Dispatch)
90 return __WrapDispatch( dispatch, Pathname, clsctx = clsctx)
moniker undefined, i undefined, bindCtx undefined, global pythoncom =
<module 'pythoncom' from 'C:\WINNT\Syste m32\pythoncom22 .dll'>,
pythoncom.MkPar seDisplayName = <built-in function MkParseDisplayN ame>,
Pathname = 'winmgmts:'
com_error: (-2147217405, 'OLE error 0x80041003', None, None)
__doc__ = None
__getitem__ = <bound method com_error.__get item__ of
<pywintypes.com _error instance at 0x005A72E0>>
__init__ = <bound method com_error.__ini t__ of <pywintypes.com _error
instance at 0x005A72E0>>
__module__ = 'pywintypes'
__str__ = <bound method com_error.__str __ of <pywintypes.com _error
instance at 0x005A72E0>>
args = (-2147217405, 'OLE error 0x80041003', None, None)
MK wrote: This is what I get back in browser's window:
Browser? What are you trying to do, that runs Python code in the
browser window? Try running your code directly instead of through
CGI and see what happens. It's easier to debug that way.
C:\python\lib\s ite-packages\win32c om\client\__ini t__.py in Moniker(Pathnam e='winmgmts:', clsctx=23)
com_error: (-2147217405, 'OLE error 0x80041003', None, None)
The above two snippets suggest that you are trying to access some
COM object called "winmgmts:" but don't have permission. I have
no idea about COM/ActiveX so I can't help, but perhaps someone
else can. Searching on Google for the above error code gives
lots of results, including:
In the call to pWbemServices->GetObject an error of 0x80041003 is
returned which according to MSDN documentation is
WBEM_E_ACCESS_D ENIED
The current user does not have permission to perform the action
I'd suggest you (a) learn more about Python, since you don't seem
to know how to interpret error tracebacks, and (b) describe in more
detail what you are trying to accomplish, because the problem is
not with the "wmi" module per se, but at a lower level, and appears
to be related to your not having the correct user permissions for
the object you are accessing.
Sorry I can't help more.
-Peter
"Peter Hansen" <pe***@engcorp. com> wrote
[...] I'd suggest you (a) learn more about Python, since you don't seem to know how to interpret error tracebacks, and (b) describe in more detail what you are trying to accomplish, because the problem is not with the "wmi" module per se, but at a lower level, and appears to be related to your not having the correct user permissions for the object you are accessing.
Fair enough. Thanks for suggestions!
I will keep digging.
MK This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tubby Tudor |
last post by:
What is the best way to call one python script from within another
python script? For example:
one.py finishes succesfully and calls two.py which finishes OK and then
calls three.py
Thanks guys!
|
by: Paul Winkler |
last post by:
This is driving me up the wall... any help would be MUCH appreciated.
I have a module that I've whittled down into a 65-line script in
an attempt to isolate the cause of the problem.
(Real domain names have been removed in everything below.)
SYNOPSIS:
I have 2 target servers, at https://A.com and https://B.com.
I have 2 clients, wget and my python script.
|
by: phoolimin |
last post by:
Dear all,
I am trying to embed python into another scripting language, to do this
I need to solve a number of problems on importing or compiling python
script. First let me state what exactly I want to do, that is, I want
the following syntax to be supported in the host language which I am
developing:
######################################################
# scripts in the host language
|
by: Efrat Regev |
last post by:
Hello,
I need to call GNU/make from within a Python script. This raised some
problems:
1. The script is not in the directory of the makefile, and changing the
locations of either is not an option. Consequently, the makefile fails,
since it can't find the targets/dependencies.
2. After searching around, it seems that os.system(..) should be avoided
if there's an alternative. Is there one in this case?
|
by: Viewer T. |
last post by:
I am trying to write a script that deletes certain files based on
certain criteria.
What I am trying to do is to automate the process of deleting certain
malware files that disguise themselves as system files and hidden
files. When I use os.remove() after importing the os module is raises
a Windows Error: Access denied probably because the files have
disguised themselves as system files. Is there anway to get adequate
privileges under...
| |
by: Chris8Boyd |
last post by:
I am embedding Python in a MSVC++ (2005) application. The application
creates some environment and then launches a Python script that will
call some functions exported from the MSVC++ application.
I want to be able to debug the Python script by using a debug server,
like Winpdb (winpdb.org).
I use ActivePython 2.5.2.2, Microsoft Visual Studio 2005, and Winpdb
1.3.8.
|
by: Basha J P M |
last post by:
I am beginner in python.
I am working through the tutorial examples from http://www.swig.org/ and
have run into some problems. I took the following command instructions from
the tutorial on swig.org:
http://www.swig.org/tutorial.html
I have written example.c and example.i as described in the above tutorial.
My first attempt at compiling the libraries was this:
|
by: replysonika |
last post by:
Hello,
I run a Java app with subprocess from Python script. This python
script is called from another Python Wrapper.
python = subprocess.Popen(,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
|
by: Stef le Breton |
last post by:
Hi,
I need to compile a pyhton tool into an executable as the destination plateform (Solaris, Linux) are not deployed with Python or not all needed modules.
I found pyinstaller and follow the classical tutorial.
First executable starts correctly under Linux but not under windows.
Second it crashes right after due to unknown module that haev to be loaded.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |