def do_GET(self): if self.path == '/module/list': # list the different modules self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() # List the different shared object of ecto_opencv for module in ['ecto_opencv']: m = __import__(module) ms = [(module,m)] for loader, module_name, is_pkg in pkgutil.walk_packages(m.__path__): #print loader,module_name,is_pkg module = loader.find_module(module_name).load_module(module_name) ms.append((module_name,module)) # list the different modules ecto_cells = [] for module_name,x in ms: ecto_cells += ecto.list_ecto_module(x) # loop over each module and get info about them module_infos = [] for module in ecto_cells: module_info = {'name': module.name()} for property_name, property in [ ('inputs', module.inputs), ('outputs', module.outputs), ('params', module.params) ]: module_info[property_name] = [ {'name': tendril.key(), 'doc': tendril.data().doc, 'type': tendril.data().type_name, 'has_default': tendril.data().has_default, 'user_supplied': tendril.data().user_supplied, 'required': tendril.data().required, 'dirty': tendril.data().dirty} for tendril in property ] module_infos.append(module_info) print json.dumps(module_infos) self.wfile.write(json.dumps(module_infos)) return else: try: if self.path.endswith(".html") or self.path.endswith(".js"): f = open(curdir + sep + self.path) #self.path has /test.html #note that this potentially makes every file on your computer readable by the internet self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() return if self.path.endswith(".esp"): #our dynamic content self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write("hey, today is the" + str(time.localtime()[7])) self.wfile.write(" day in the year " + str(time.localtime()[0])) return return except IOError: self.send_error(404,'File Not Found: %s' % self.path)
#!/bin/python import ecto #import ecto_opencv.cv_bp as opencv from ecto_opencv import highgui, calib, imgproc, features2d ecto.list_ecto_module(features2d) ecto.list_ecto_module(highgui) ecto.list_ecto_module(calib) ecto.list_ecto_module(imgproc)
#!/bin/python import ecto from ecto_opencv import pcl import time #import orb as imgproc debug = True ecto.list_ecto_module(pcl) plasm = ecto.Plasm() grabber = pcl.KinectGrabber() voxel = pcl.VoxelGrid(leaf_size=0.01) viewer = pcl.CloudViewer() plasm.connect(grabber, "output", voxel , "input") plasm.connect(voxel, "output", viewer , "input") if debug: print plasm.viz() ecto.view_plasm(plasm) prev = time.time() count = 0 while not viewer.outputs.stop: plasm.execute() now = time.time() if(count == 200):
# import ecto import os import pkgutil usage = """ Prints the doc strings for a given ecto module. ecto_doc.py [my_ecto_module] where my_ecto_module is in the PYTHONPATH and is a ecto extension. """ if __name__ == '__main__': if len(os.sys.argv) == 2: module = os.sys.argv[1] m = __import__(module) ms = [(module, m)] for loader, module_name, is_pkg in pkgutil.walk_packages(m.__path__): #print loader,module_name,is_pkg module = loader.find_module(module_name).load_module(module_name) ms.append((module_name, module)) ecto_cells = [] for module_name, x in ms: print "..", module_name + '\n' ecto_cells += ecto.list_ecto_module(x) #print ecto_cells else: print usage
def do_GET(self): path = urlparse.urlparse(self.path).path print path if path == '/module/list': # list the different modules self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() # List the different shared object of ecto_opencv for module in ['ecto_opencv']: m = __import__(module) ms = [(module,m)] for loader, module_name, is_pkg in pkgutil.walk_packages(m.__path__): #print loader,module_name,is_pkg module = loader.find_module(module_name).load_module(module_name) ms.append((module_name,module)) # list the different modules ecto_cells = [] for module_name,x in ms: ecto_cells += ecto.list_ecto_module(x) # loop over each module and get info about them module_infos = [] for module in ecto_cells: module_info = {'name': module.name()} for property_name, property in [ ('inputs', module.inputs), ('outputs', module.outputs), ('params', module.params) ]: module_info[property_name] = [ {'name': tendril.key(), 'doc': tendril.data().doc, 'type': tendril.data().type_name, 'has_default': tendril.data().has_default, 'user_supplied': tendril.data().user_supplied, 'required': tendril.data().required, 'dirty': tendril.data().dirty} for tendril in property ] module_infos.append(module_info) print json.dumps(module_infos) self.wfile.write(json.dumps(module_infos)) return elif path.startswith('/module/graph'): # list the different modules self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() # Read the DOT file format that was sent self.rfile.read(dot_string) print dot_string svg_graph = [] self.wfile.write(json.dumps(svg_graph)) return else: try: if path.endswith(".html") or path.endswith(".js") or path.endswith(".css") or path.endswith(".png"): f = open(curdir + sep + path) self.send_response(200) if path.endswith(".js"): self.send_header('Content-type', 'text/javascript') elif path.endswith(".css"): self.send_header('Content-type', 'text/css') elif path.endswith(".png"): self.send_header('Content-type', 'image/png') else: self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() return return except IOError: self.send_error(404,'File Not Found: %s' % self.path)
#!/usr/bin/env python import ecto import os import pkgutil usage = """ Prints the doc strings for a given ecto module. ecto_doc.py [my_ecto_module] where my_ecto_module is in the PYTHONPATH and is a ecto extension. """ if __name__ == '__main__': if len(os.sys.argv) == 2: module = os.sys.argv[1] m = __import__(module) ms = [(module,m)] for loader, module_name, is_pkg in pkgutil.walk_packages(m.__path__): #print loader,module_name,is_pkg module = loader.find_module(module_name).load_module(module_name) ms.append((module_name,module)) ecto_cells = [] for module_name,x in ms: print "..",module_name +'\n' ecto_cells += ecto.list_ecto_module(x) #print ecto_cells else : print usage
def test_list_modules(self): ecto.list_ecto_module(features2d) ecto.list_ecto_module(highgui) ecto.list_ecto_module(calib) ecto.list_ecto_module(imgproc)
def test_inspection(): ecto.list_ecto_module(ecto_test) ecto.list_ecto_module(pyecto)
def do_GET(self): """ When called, give back the requested file or info """ path = urlparse.urlparse(self.path).path if path == "/cell/list": # list the different cells self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() # List the different shared object of ecto_opencv # TODO ls of sys.path for ecto_*.so ? cell_infos = [] import os for module_name in ["ecto_opencv"]: m = __import__(module_name) ms = [(module_name, m)] for loader, sub_module_name, is_pkg in pkgutil.walk_packages(m.__path__, module_name + "."): try: module = importlib.import_module(sub_module_name) ms.append((sub_module_name, module)) except: pass # list the different cells for sub_module_name, x in ms: ecto_cells = ecto.list_ecto_module(x) # loop over each cell and get info about them for obj in ecto_cells: cell = obj.inspect() cell_info = {"name": cell.name(), "module": sub_module_name, "doc": cell.short_doc()} for property_name, property in [ ("inputs", cell.inputs), ("outputs", cell.outputs), ("params", cell.params), ]: cell_info[property_name] = [] for tendril in property: dic = { "name": tendril.key(), "doc": tendril.data().doc, "type": tendril.data().type_name, "has_default": tendril.data().has_default, "user_supplied": tendril.data().user_supplied, "required": tendril.data().required, "dirty": tendril.data().dirty, } if property_name == "params": # special case of an enum tendril_type = type(tendril.data().val) if "values" in tendril_type.__dict__: dic["type"] = "enum" dic["values"] = {} for key, value in tendril_type.values.iteritems(): dic["values"][key] = str(value) if str(value) == str(tendril.data().val): dic["value"] = key else: dic["value"] = tendril.data().val cell_info[property_name].append(dic) # deal with the special case of boost::python::api::object if tendril.data().type_name == "boost::python::api::object" and dic["value"] is None: dic["value"] = "" try: json.dumps(cell_info) cell_infos.append(cell_info) except: pass self.wfile.write(json.dumps(cell_infos)) return else: # simply send back the file that is asked for if path == "/": path = "/index.html" # deal with the favicon if path.endswith(".ico"): path = "/image/" + path print path try: if path.endswith(".html") or path.endswith(".js") or path[-4:] in [".css", ".png", ".jpg", ".ico"]: f = open(curdir + sep + "../html/" + path) self.send_response(200) if path.endswith(".js"): self.send_header("Content-type", "text/javascript") elif path.endswith(".css"): self.send_header("Content-type", "text/css") elif path.endswith(".png"): self.send_header("Content-type", "image/png") elif path.endswith(".jpg"): self.send_header("Content-type", "image/jpeg") elif path.endswith(".ico"): self.send_header("Content-type", "image/vnd.microsoft.icon") else: self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(f.read()) f.close() return return except IOError: self.send_error(404, "File Not Found: %s" % self.path)
#!/bin/python import ecto from ecto_opencv import pcl import time #import orb as imgproc debug = True ecto.list_ecto_module(pcl) plasm = ecto.Plasm() grabber = pcl.KinectGrabber() voxel = pcl.VoxelGrid(leaf_size=0.01) viewer = pcl.CloudViewer() plasm.connect(grabber, "output", voxel, "input") plasm.connect(voxel, "output", viewer, "input") if debug: print plasm.viz() ecto.view_plasm(plasm) prev = time.time() count = 0 while not viewer.outputs.stop: plasm.execute() now = time.time() if (count == 200): print "%f fps" % (1 / ((now - prev) / count))
#!/usr/bin/env python import ecto import os import pkgutil usage = """ Prints the doc strings for a given ecto module. ecto_doc.py [my_ecto_module] where my_ecto_module is in the PYTHONPATH and is a ecto extension. """ if __name__ == '__main__': if len(os.sys.argv) == 2: module = os.sys.argv[1] m = __import__(module) ecto.list_ecto_module(m) else : print usage