def lGetOptionsArgs(): oParser = oOptionParser(__doc__.strip()) ( oOptions, lArgs, ) = oParser.parse_args() assert int(oOptions.iSubPubPort) > 0 and int(oOptions.iSubPubPort) < 66000 # if iReqRepPort is > 0 then request a Zmq version query assert int(oOptions.iReqRepPort) >= 0 and int(oOptions.iReqRepPort) < 66000 oOptions.iDebugLevel = int(oOptions.iDebugLevel) assert 0 <= oOptions.iDebugLevel <= 5 assert oOptions.sHostAddress sMt4Dir = oOptions.sMt4Dir if sMt4Dir: sMt4Dir = os.path.expanduser(os.path.expandvars(sMt4Dir)) if not os.path.isdir(sMt4Dir): vWarn("sMt4Dir not found: " + sMt4Dir) else: sMt4Dir = os.path.join(sMt4Dir, 'MQL4', 'Python') if not os.path.isdir(os.path.join(sMt4Dir, 'OTMql427')): vWarn("sMt4Dir/MQL4/Python/OTMql427 not found: " + sMt4Dir) elif sMt4Dir not in sys.path: sys.path.insert(0, sMt4Dir) return ( oOptions, lArgs, )
def lGetOptionsArgs(): oParser = oOptionParser(__doc__.strip()) (oOptions, lArgs,) = oParser.parse_args() assert int(oOptions.iSubPubPort) > 0 and int(oOptions.iSubPubPort) < 66000 # if iReqRepPort is > 0 then request a Zmq version query assert int(oOptions.iReqRepPort) >= 0 and int(oOptions.iReqRepPort) < 66000 oOptions.iDebugLevel = int(oOptions.iDebugLevel) assert 0 <= oOptions.iDebugLevel <= 5 assert oOptions.sHostAddress sMt4Dir = oOptions.sMt4Dir if sMt4Dir: sMt4Dir = os.path.expanduser(os.path.expandvars(sMt4Dir)) if not os.path.isdir(sMt4Dir): vWarn("sMt4Dir not found: " + sMt4Dir) else: sMt4Dir = os.path.join(sMt4Dir, 'MQL4', 'Python') if not os.path.isdir(os.path.join(sMt4Dir, 'OTMql427')): vWarn("sMt4Dir/MQL4/Python/OTMql427 not found: " + sMt4Dir) elif sMt4Dir not in sys.path: sys.path.insert(0, sMt4Dir) return (oOptions, lArgs,)
def zPopFromPending(self, sString): from OTMql427.SimpleFormat import gRetvalToPython global dPENDING lElts = sString.split('|') if len(lElts) <= 4: vWarn("not enough | found in: %s" % (sString,)) return "" if sString.startswith('tick') or sString.startswith('timer'): print sString return "" if sString.startswith('retval'): sMarkOut = lElts[3] if sMarkOut not in dPENDING.keys(): print "WARN: %s not found in: %r" % (sMarkOut, dPENDING.keys()) else: del dPENDING[sMarkOut] sType = lElts[4] sVal = lElts[5] print "INFO: " +sMarkOut +" "+ sString if sType == "cmd": # there's still a null that comes back on ReqRep sNull = self.oReqRepSocket.recv() # zmq.error.ZMQError try: gRetval = gRetvalToPython(lElts) except Exception as e: vError("zPopFromPending: error in gRetvalToPython " +sString +str(e)) else: return gRetval else: vWarn("Unrecognized message: " + sString) return ""