How to use getActionName method in fMBT

Best Python code snippet using fMBT_python

ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.py

Source:ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.py Github

copy

Full Screen

...108 transition_value_list = i.getTransitionValueList()109 if not transition_value_list:110 continue111 for t in transition_value_list:112 if t.getActionName():113 #adding a context in msg_id for more precise translation114 msg_id = getMessageIdWithContext(t.getActionName(),'transition',i.getId())115 add_message(msg_id, portal_url.getRelativeContentURL(t))116 # also use action box name as msg_id for compatibility117 add_message(t.getActionName(), portal_url.getRelativeContentURL(t))118 if t.getTitle():119 #adding a context in msg_id for more precise translation120 msg_id = getMessageIdWithContext(t.getTitle(),'transition',i.getId())121 add_message(msg_id, portal_url.getRelativeContentURL(t))122 # also use transition title as msg_id for compatibility123 add_message(t.getTitle(), portal_url.getRelativeContentURL(t))124 for worklist in i.getWorklistValueList():125 add_message(worklist.getActionName(), portal_url.getRelativeContentURL(worklist))126#127# Portal Type128#129for i in context.portal_types.objectValues():130 add_message(i.id, 'portal type')131#132# Action133#134for action_title, action_provider_id in context.Base_getActionTitleListFromAllActionProvider(context.getPortalObject()):135 add_message(action_title, action_provider_id)136#137# ZODB Property Sheet138#139for property_sheet in context.portal_property_sheets.objectValues():...

Full Screen

Full Screen

proxy.py

Source:proxy.py Github

copy

Full Screen

...36 super(BlockedAction, self).__init__(write)37 self.setPassed(False)38 def process(self):39 self.write("Blocked command!\n")40 def getActionName(self):41 return "Blocked"42 def getColor(self):43 return "31"44class DelayAction(Action):45 def process(self):46 time.sleep(3)47 self.setPassed(True)48 print("delay ...\n")49 def getActionName(self):50 return "Delay"51 def getColor(self):52 return "34"53class AllowAction(Action):54 def process(self):55 self.setPassed(True)56 def getActionName(self):57 return "Allow"58 def getColor(self):59 return "32"60class InsultAction(Action):61 def __init__(self, clientIp, write):62 super(InsultAction, self).__init__(write)63 self.clientIp = clientIp64 self.setPassed(False)65 def process(self):66 location = self.getCountryCode()67 print("Insult Message! IP= %s/location=%s\n" % (self.clientIp, location))68 self.write(dao.getQRasshDao().getInsultMsg(location.lower()) + "\n")69 def getCountryCode(self):70 path, file = os.path.split(__file__)71 file_name = os.path.join(path, "geo_ip.dat")72 print("Load geo_ip.dat from " + file_name)73 geo_ip = pygeoip.GeoIP(file_name)74 return geo_ip.country_code_by_addr(self.clientIp)75 def getActionName(self):76 return "Insult"77 def getColor(self):78 return "38"79class FakeAction(Action):80 def __init__(self, command, write):81 super(FakeAction, self).__init__(write)82 self.command = command83 self.setPassed(False)84 def process(self):85 fake_output = dao.getQRasshDao().getFakeOutput(self.command)86 if fake_output is not None:87 self.write(fake_output + "\n")88 def getActionName(self):89 return "Fake"90 def getColor(self):91 return "33"92class ActionGenerator(object):93 def generate(self):94 '''95 :return: action96 '''97class RandomActionGenerator(ActionGenerator):98 def generate(self):99 return random.randrange(0, 4)100class RlActionGenerator(ActionGenerator):101 def generate(self):102 print ("get action by q-learning", rl_state.current_command)103 rl_agent.train(rl_state.current_command)104 return rl_agent.choose_action()105class ActionFactory(object):106 def __init__(self, write, listener, generator):107 self.write = write108 self.listener = listener109 self.generator = generator110 pass111 def getAction(self, cmd, clientIp):112 action = self.generator.generate()113 print("Receive action: ", action)114 self.listener.handle(action)115 if action == 0:116 return AllowAction(self.write)117 elif action == 1:118 return DelayAction(self.write)119 elif action == 2:120 return FakeAction(cmd, self.write)121 elif action == 3:122 return InsultAction(clientIp, self.write)123 elif action == 4:124 return BlockedAction(self.write)125class ActionValidator(object):126 def __init__(self, factory):127 self.factory = factory128 pass129 def validate(self, cmd, clientIp):130 self.action = self.factory.getAction(cmd, clientIp)131 self.action.process()132 return self.action.isPassed()133 def getActionName(self):134 return self.action.getActionName()135 def getActionColor(self):136 return self.action.getColor()137class ActionPersister(object):138 def save(self, actionState, cmd):139 if "initial_cmd" in actionState.keys():140 print("Save next_cmd: " + cmd)141 actionState["next_cmd"] = cmd142 dao.getQRasshDao().saveCase(actionState)143 print("Save initial_cmd: " + cmd)144 actionState["initial_cmd"] = cmd145class ActionListener(object):146 def __init__(self, store):147 self.store = store148 pass...

Full Screen

Full Screen

getFormular.py

Source:getFormular.py Github

copy

Full Screen

...18 data[layer][state] = 019 return data, environments[env.level][2]20def getName(layer: LayerType, isMinus1: bool = True):21 return f"\img{'{'}{layer.name}{'}'}^{'{'}{'t-1' if isMinus1 else 't'}{'}'}"22def getActionName(layer: LayerType, isMinus1: bool = True):23 return f"\img{'{'}{LayerType.Player.name}{'}'}^{'{'}{'t-1' if isMinus1 else 't'}{'}'}_{'{'}\imgSmall{'{'}{layer.name}{'}'}{'}'}"24def formatState(state: frozenset[LayerType]):25 try:26 return reduce(lambda p0, p1: p0 * p1, (symbols(getName(layer)) for layer in state))27 except:28 return Symbol('')29def handleFloat(v: float) -> Symbol:30 return Symbol(f" Bernoulli({str(round(v, 1))})")31def clean(r: Symbol, layer: LayerType) -> str:32 r: str = str(r)33 if "+" in r:34 r = f"({r})"35 r += "*" + getActionName(layer)36 r = r.replace('0*', '').replace('*', '\cdot').replace("Bernoulli(1.0)\cdot", "")37 if r.startswith("\cdot"):38 r = r[5:]39 return r40def draw(name: str):41 data, layers = test_graphTrain(name)42 print('\\begin{align*} ')43 for layer, info in data.items():44 l = symbols(getName(layer, isMinus1=False)) if layer != LayerType.Goal else symbols('T^t')45 r = clean(sum([formatState(state) * handleFloat(chance) for state, chance in info.items() if chance]), layer)46 if layer == LayerType.Goal:47 print(f"{symbols(getName(layer, isMinus1=False))} &= {r}*(1-{symbols('T^{t-1}')})\\\\".replace('*', "\cdot"))48 print(f"{l} &= {r}+{getName(layer) if layer != LayerType.Goal else symbols('T^{t-1}')}", end="\n" if layer == LayerType.Goal else "\\\\\n")49 print('\\end{align*}')50 print("$$" + "\,\,\,,\,\,\,".join([f"{symbols(getActionName(layer, isMinus1=False))}=0" for layer in list(layers) + [LayerType.Goal]]) + "$$\n")51draw("Diamonds1_0.0_UCB1")52draw("Diamonds1_0.5_UCB1")53draw("Diamonds2_0.0_UCB1")54draw("Diamonds2_0.5_UCB1")55draw("Diamonds3_0.0_UCB1")56draw("Diamonds3_0.5_UCB1")57draw("Diamonds4_0.0_UCB1")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful