Skip to content

Instantly share code, notes, and snippets.

@sebcagnon
sebcagnon / passThroughOptionParser.py
Last active November 22, 2016 06:47
OptionParser that lets optional arguments go through. Useful when pre-processing then giving the rest to another program.
from optparse import (OptionParser,BadOptionError,AmbiguousOptionError)
class PassThroughOptionParser(OptionParser):
"""
An unknown option pass-through implementation of OptionParser.
When unknown arguments are encountered, bundle with largs and try again,
until rargs is depleted.
sys.exit(status) will still be called if a known argument is passed
@sebcagnon
sebcagnon / signal connect
Last active January 19, 2016 10:00
In a Python box with the onStopped output set to "string"
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
#put initialization code here
self.id = None
def onUnload(self):
#put clean-up code here
@sebcagnon
sebcagnon / loadNaoImageDBBox.py
Created August 25, 2015 02:02
the code to put in your Choregraphe box to load the Image Recognition Database on your Nao or Pepper
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
def onLoad(self):
self.reco = ALProxy("ALVisionRecognition")
self.fmgr = ALProxy("ALFrameManager")
def onUnload(self):
pass