[python-win32] Python.AXScript (win32com) in Netstumbler

sam lee skynare at gmail.com
Thu Oct 12 14:18:41 CEST 2006


On 10/12/06, Mark Hammond <mhammond at skippinet.com.au> wrote:

> PlaySound will be a method on a "global" object.  Due to the way Python
> works, it is difficult to always make these methods truly global - hence in
> ASP, you need, eg, 'Response.Write' rather than the plain 'Write' other
> languages offer.  You need to find the name of the equivilent global
> variable in Netstumbler.
>
> Cheers,
>
> Mark
>
>

Thank you very much!

Now, I figured the name of the global object is NetStumbler.
NetStumbler.PlaySound("ns-signal-1.wav")
works beautifully.

So, NetStumbler will call NetStumbler.OnScanResult on some events.
I want to override that:

1st try:
NetStumbler.OnScanResult = lambda
SSID,BSSID,CapFlags,Signal,Noise,LastSeen:
NetStumbler.PlaySound("ns-signal-1.wav")

I get:
Python ActiveX Scripting Engine

Traceback (most recent call last):
  File "<Script Block >", line 18, in ?
    NetStumbler.OnScanResult = lambda
SSID,BSSID,CapFlags,Signal,Noise,LastSeen:
NetStumbler.PlaySound("ns-signal-1.wav")
  File "C:\Python24\Lib\site-packages\win32comext\axscript\client\pyscript.py",
line 155, in __setattr__
    raise AttributeError, attr
AttributeError: onscanresult

__setattr__ is:

	def __setattr__(self, attr, value):
		# XXX - todo - if a known item, then should call its default
		# dispatch method.
		attr=string.lower(attr)
		if self._scriptItem_.dispatchContainer:
			try:
				return setattr(self._scriptItem_.dispatchContainer,attr, value)
			except AttributeError:
				pass
		raise AttributeError, attr

I'm new to Python. So, I assume when the if condition is false, it
raises exception...

2nd try:
def OnScanResult(cls, SSID,BSSID,CapFlags,Signal,Noise,LastSeen):
    NetStumbler.PlaySound("ns-signal-1.wav")

NetStumbler.OnScanResult = classmethod(OnScanResult)

Same error results.

How would I override NetStumbler.OnScanResult?

Thank you.
Sam.


More information about the Python-win32 mailing list