Basic debugging questions

I’m trying to write a simple addon to export Blender files as C structs to be easily used by opengl as described by Apple as their preferred method for use on the iPhone/iPad. I’m new to python and blender scripting, and thought it would be relatively simple to follow along some existing scripts and just modify their output for my own uses. However, even before I’m delving into the real meat and potatoes part of it, I’m having problems getting my script to enable in blender. Specifically, I’m having problems with menu_func, which even though I copied over pretty much verbatim from similar scripts, seems to screw things up and blender won’t let me enable my barebones script with it included. I’m sort of lost as to what the problem is, like I said I’m new to python and blender scripting, and as far as I can tell there’s no way within blender to get any debugging information when attempting to enable a script. Also like I said, 95% of this is just copied over from a working script, all I’ve done so far is change the class names and I’m already running into problems. So first, can anyone tell me what my specific problem with this code is (look at the comments at the very bottom for what is causing the problem), and second, for the future, what’s the best way to debug these scripts?

bl_info = {
"name": "Export C Header With Animation (.h)",
"author": "",
"version": (1, 0),
"blender": (2, 5, 7),
"api": 35622,
"location": "File > Export",
"description": "Export Model and Animation to C Header file",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Import-Export"}

'''
    Usage Notes:
    
    
    '''
import bpy
from bpy.props import *
import mathutils, math, struct
import os
from os import remove
import time
from io_utils import ExportHelper
import time
import shutil
import bpy
import mathutils

class Export_animated_c_header(bpy.types.Operator, ExportHelper):
    '''Exports the selected mesh and armature with animation data'''
    
    bl_idname = "animatedheader.c"
    bl_label = "Export Mesh and Animation Data Header (.h)"
    
    @classmethod
    
    def poll(cls, context):
        return True
    
    def execute(self, context):
        return {'FINISHED'}
    
    def invoke(self, context, event):
        wm = context.window_manager
            
        if True:
        # File selector
            wm.fileselect_add(self) # will run self.execute()
            return {'RUNNING_MODAL'}
        elif True:
        # search the enum
            wm.invoke_search_popup(self)
            return {'RUNNING_MODAL'}
        elif False:
        # Redo popup
            return wm.invoke_props_popup(self, event) #
        elif False:
            return self.execute(context)

### REGISTER ###
def menu_func(self, context): #these lines need to be commented out or 
    self.layout.operator(Export_animated_c_header.bl_idname, text="C Header Animated (.h)") #the script won't allow itself to be enabled

def register():
    bpy.utils.register_module(__name__)

    bpy.types.INFO_MT_file_export.append(menu_func) #needs to be commented out

def unregister():
    bpy.utils.unregister_module(__name__)

    bpy.types.INFO_MT_file_export.remove(menu_func) #needs to be commented out

if __name__ == "__main__":
    register()

bl_info = {
"name": "Export C Header With Animation (.h)",
"author": "",
"version": (1, 0),
"blender": (2, 5, 7),
"api": 35622,
"location": "File > Export",
"description": "Export Model and Animation to C Header file",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Import-Export"}

'''
    Usage Notes:
    
    
    '''
import bpy
from bpy.props import *
import mathutils, math, struct
import os
from os import remove
import time
from io_utils import ExportHelper
import time
import shutil
import bpy
import mathutils

class Export_animated_c_header(bpy.types.Operator, ExportHelper):
    '''Exports the selected mesh and armature with animation data'''
    filename_ext = ".h"
    filter_glob = StringProperty(default="*.h", options={'HIDDEN'})

        
    filepath = bpy.props.StringProperty(name="File Path", 
        maxlen=1024, default="")
    bl_idname = "animatedheader.c"
    bl_label = "Export Mesh and Animation Data Header (.h)"
    
    @classmethod
    
    def poll(cls, context):
        return True
    
    def execute(self, context):
        return {'FINISHED'}
    
    def invoke(self, context, event):
        wm = context.window_manager
            
        if True:
        # File selector
            wm.fileselect_add(self) # will run self.execute()
            return {'RUNNING_MODAL'}
        elif True:
        # search the enum
            wm.invoke_search_popup(self)
            return {'RUNNING_MODAL'}
        elif False:
        # Redo popup
            return wm.invoke_props_popup(self, event) #
        elif False:
            return self.execute(context)

### REGISTER ###
def menu_func(self, context): #these lines need to be commented out or 
    self.layout.operator(Export_animated_c_header.bl_idname, text="C Header Animated (.h)") #the script won't allow itself to be enabled

def register():
    bpy.utils.register_module(__name__)

    bpy.types.INFO_MT_file_export.append(menu_func) #needs to be commented out

def unregister():
    bpy.utils.unregister_module(__name__)

    bpy.types.INFO_MT_file_export.remove(menu_func) #needs to be commented out

if __name__ == "__main__":
    register()

I have a small part of what you need. The “error console” to which the add-on manager posts messages relating to a failure to initialize an add-on is…hidden! On windows, launch a command console and use the command-line interface to launch blender.exe. This is where Blender will tell you why it can’t use your addon.
I came here seeking help with debugging a running script, when I read your post. If only Blender’s scripting window had a full debugging IDE! I’ll get back to you if I find more info.

You start off importing the same modules multiple times, good style would be to keep them arranged by bpy related, then additional modules (or the other way around, but preferably not mixed)


<b>#pep8 suggests a new line for each import, but it also says not to blindly follow all guides</b>

import bpy
import mathutils
from bpy.props import *
from io_utils import ExportHelper

import os, time, shutil, math, struct
from os import remove

as for debugging python: