[nvda-addons] Re: How do I debug a global plugin?

  • From: "Pranav Lal" <pranav.lal@xxxxxxxxx>
  • To: <nvda-addons@xxxxxxxxxxxxx>
  • Date: Sun, 19 Jul 2015 08:20:48 +0530

Hi Tyler,
Many thanks. I incorporated your changes and the code works. I'll append the
code to the end of this message.
<snip 3. You're missing a super call in __init__. Forgetting this breaks your
keyboard in a really obvious way until you fix it; I've hit this more than once.
So add:
super(GlobalPlugin, self).__init__() to the top of the method.
PL] Is this true for all global plugins? If yes, then we need to update the
developer guide. Shall I raise a ticket?

import globalPluginHandler
from globalCommands import commands
import tones
from logHandler import log
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
def test(self):
log.info("test method running")
for key in commands._GlobalCommands__gestures:

log.info("the key name is " + key + " value is " +
commands._GlobalCommands__gestures[key])
tones.beep(550 , 100)
def __init__(self):
super(GlobalPlugin, self).__init__()
log.info("init method running")
self.test()
tones.beep(550 , 100)



-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Tyler Spivey
Sent: Sunday, July 19, 2015 7:18 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: How do I debug a global plugin?

1. You misspelled __init__ as __init___.
2. In the test method, you'll want
for key in commands._GlobalCommands__gestures:
log.info("the key name is" + key + "value is" +
commands._GlobalCommands__gestures[key])
This might not be what you want; if something starts with __ in python then it
takes some work to get at it.
3. You're missing a super call in __init__. Forgetting this breaks your
keyboard in a really obvious way until you fix it; I've hit this more than once.
So add:
super(GlobalPlugin, self).__init__() to the top of the method.
Once all that is fixed, we get output in the log like:
the key name iskb(laptop):NVDA+[value isleftMouseClick Which could use a few
more spaces. But that's cosmetic.
Also, NVDA indents with tabs and this uses spaces. Just something to be aware
of, but that's just a style issue. Could also be your mailer.
Hope this helps,
Tyler

On 7/18/2015 6:09 PM, Pranav Lal wrote:

Hi James,

You make a valid point. I have tried pasting multiple lines of code on the
console and only a single line has been pasted. Here is the code.

import globalPluginHandler
from globalCommands import commands
import tones
from logHandler import log
class GlobalPlugin(globalPluginHandler.GlobalPlugin):
def test(self):
log.info("test method running")
for key in commands.__gestures():
log.info("the key name is" + key + "value is" +
commands.__gestures[key])
tones.beep(550 , 100)
def __init___(self):
log.info("init method running")
self.test()
tones.beep(550 , 100)

Pranav

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of James Scholes
Sent: Sunday, July 19, 2015 3:41 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: How do I debug a global plugin?

Pranav Lal wrote:
One way I have used to debug code is to use the python console but I am
defining dictionaries etc here so cannot do that.

Why can't you define dictionaries in the Python console?

The best way to get help on this list is to share your code. There might be
something very simple wrong with it, something that someone will spot in a
quick code review, or there might not. But if you say you're doing
everything right, but it isn't working, where else can we go?

I don't mean any disrespect by this, and I hope you don't mind me being
blunt, but if you were doing everything right, your add-on would be working.
If your add-on needs external libraries or tools and it can't be used without
them, by all means make that clear. But without code, we can't tell you
what's wrong with it.

You can't run an NVDA add-on in an IDE as a standalone program, because it's
not a standalone program.
--
James Scholes
http://twitter.com/JamesScholes
----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting
bugs.

Community addons are available from: http://addons.nvda-project.org To
send a message to the list: nvda-addons@xxxxxxxxxxxxx To change your
list settings/unsubscribe: //www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting
bugs.

Community addons are available from: http://addons.nvda-project.org To
send a message to the list: nvda-addons@xxxxxxxxxxxxx To change your
list settings/unsubscribe: //www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx


----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting
bugs.

Community addons are available from: http://addons.nvda-project.org To send a
message to the list: nvda-addons@xxxxxxxxxxxxx To change your list
settings/unsubscribe: //www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

----------------------------------------------------------------
NVDA add-ons: A list to discuss add-on code enhancements and for reporting bugs.

Community addons are available from: http://addons.nvda-project.org
To send a message to the list: nvda-addons@xxxxxxxxxxxxx
To change your list settings/unsubscribe:
//www.freelists.org/list/nvda-addons
To contact list moderators: nvda-addons-moderators@xxxxxxxxxxxxx

Other related posts: