def _getModule(name, path): try: module = imp.load_source(name, path) except SyntaxError, err: ERR('Syntax Error : %s' % path) DBG(err) module = None
def main(option) : if option == 'dumplist' : PicamPortmap().dumpPortmap() ; elif option == 'install' : PicamPortmap().setPortmap().dumpPortmap() ; elif option == 'remove' : PicamPortmap().delPortmapAll() ; else : ERR('Notthing to do about %s.' % option) ;
def cliMain(self) : DBG('Start of cliMain') ; while self.m_fgRun : cmd = raw_input(Cli.PROMPT).strip().split() ; # DBG('CMD%s' % cmd) if cmd == [] : continue ; try : self.command[cmd[0]](None if len(cmd)==1 else cmd[1:]) ; except KeyError : ERR('Unknown Command, %s' % cmd) DBG('End of cliMain') ;
def getEndpointId(self): count = len(self.m_endpointArray) if count == 0: ERR('Empty Endpoint') return 0 elif count == 1: return self.m_endpointArray[0].getId() else: for epid in range(1, 256): ep = self.findendpoint(epid) if ep: return ep.getId()
def doQueryGetPortmap(self) : self.m_portmap = [] ; u = self.__getHandle() ; if u.discover() > 0 : try: u.selectigd() ; except Exception, e: ERR('Exception : %s', e) ; self.m_ipaddr = u.lanaddr ; i = 0 ; while True : p = u.getgenericportmapping(i) ; if p==None : break ; #(port, proto, (ihost,iport), desc, c, d, e) = p ; self.m_portmap.append(p) ; i = i + 1 ;
class ZbConfig: DEFAUT_CONFIG = 'zigbee_common' @staticmethod def _doVerify(configFile): if os.path.exists(configFile): # TODO : checking config file - syntax and import .... return configFile DBG('File Not Exist : %s - Using a default config file.' % configFile) return 'config/%s.py' % ZbConfig.DEFAUT_CONFIG @staticmethod def _doSendMessage(zbem, msgs, node=None): if type(msgs) is list: coEUI = zbem.m_zbHandle.getSwapEUI() swapCoEUI = zbem.m_zbHandle.getEUI() # print msgs ; countReport = 0 for msg in msgs: msg = msg.replace('IASCIE', swapCoEUI) msg = msg.replace('COEUI', coEUI) zbem.sendMsg(msg) countReport += msg.count('send-me-a-report') time.sleep(0.1) if node: node.setRequestedCount(countReport) @staticmethod def _getModule(name, path): try: module = imp.load_source(name, path) except SyntaxError, err: ERR('Syntax Error : %s' % path) DBG(err) module = None except Exception, err: ERR('Exception Error : %s' % path) DBG(err) module = None
def __cmdPrint(self, argv) : try : self.commandPrint[argv[0]](None if len(argv)==1 else argv[1:]) ; except KeyError : ERR('Unknown Print Command, %s' % ' '.join(argv)) ;