How to use setactivity method in tox

Best Python code snippet using tox_python

Demonstration_Code.py

Source: Demonstration_Code.py Github

copy

Full Screen

1import bpmsim2import scipy.stats3import random45order = bpmsim.importBPMN(modelName="Order Fulfillment",6 withSubprocess=True,7 outputHelp=True,8 fileName="C:/​Users/​Droomelot/​Downloads/​Order Fulfillment.bpmn")910creditClerk = bpmsim.importBPMN(modelName="Credit Application Clerk",11 outputHelp=True,12 fileName="C:/​Users/​Droomelot/​Downloads/​Credit Application Clerk.bpmn")1314creditCreditOfficer = bpmsim.importBPMN(modelName="Credit Application Credit Officer",15 outputHelp=True,16 fileName="C:/​Users/​Droomelot/​Downloads/​Credit Application CreditOfficer.bpmn")1718clerk = bpmsim.resource(name="Clerk", capacity=3)19creditOfficer = bpmsim.resource(name="Credit Officer", capacity=2)20storeOrder = bpmsim.store(name="Order store", capacity=3, initial=3)21storeApplication = bpmsim.store(name="Application store", capacity=2400)2223#------------------------------------------------#24#----------SIMULATION ORDER FULFILLMENT----------#25#------------------------------------------------#2627# SET START28bpmsim.setStart(BPMN=order, name="Purchase Order Received", getStore=[storeOrder])2930# SET ACTIVITIES31priorOrder = 132def getNumber():33 number = random.randint(8,12)34 return(number)35 36bpmsim.setActivity(BPMN=order, name="Check stock availability", resources=[clerk], amount=[1],37 duration=lambda: scipy.stats.norm.rvs(loc=2,scale=0.5),38 fixedCost=5, variableCost=0.5, priority=priorOrder)39bpmsim.setActivity(BPMN=order, name="Retrieve product from warehouse", resources=[clerk], amount=[1],40 duration=lambda: getNumber(),41 fixedCost=5, variableCost=0.5, priority=priorOrder)42bpmsim.setActivity(BPMN=order, name="Manufacture Product", resources=[clerk], amount=[1],43 duration=lambda: scipy.stats.expon.rvs(loc=15),44 fixedCost=5, variableCost=0.5, priority=priorOrder)45bpmsim.setActivity(BPMN=order, name="Confirm Order", resources=[clerk], amount=[1],46 duration=lambda: scipy.stats.expon.rvs(loc=3),47 fixedCost=5, variableCost=0.5, priority=priorOrder)48bpmsim.setActivity(BPMN=order, name="Archive order", resources=[clerk], amount=[1],49 duration=lambda: scipy.stats.expon.rvs(loc=3),50 fixedCost=5, variableCost=0.5, priority=priorOrder)5152bpmsim.setActivity(BPMN=order, name="Check raw materials availability", resources=[clerk], amount=[1],53 duration=lambda: 20,54 fixedCost=5, variableCost=0.5, priority=priorOrder)55bpmsim.setActivity(BPMN=order, name="Request raw materials from supplier 1", resources=[clerk], amount=[1],56 duration=lambda: 10,57 fixedCost=5, variableCost=0.5, priority=priorOrder)58bpmsim.setActivity(BPMN=order, name="Obtain raw materials from supplier 1", resources=[clerk], amount=[1],59 duration=lambda: 5,60 fixedCost=5, variableCost=0.5, priority=priorOrder)61bpmsim.setActivity(BPMN=order, name="Request raw materials from supplier 2", resources=[clerk], amount=[1],62 duration=lambda: 12,63 fixedCost=5, variableCost=0.5, priority=priorOrder)64bpmsim.setActivity(BPMN=order, name="Obtain raw materials from supplier 2", resources=[clerk], amount=[1],65 duration=lambda: 7,66 fixedCost=5, variableCost=0.5, priority=priorOrder)6768bpmsim.setActivity(BPMN=order, name="Get shipment address", resources=[clerk], amount=[1],69 duration=lambda: scipy.stats.norm.rvs(loc=5,scale=1),70 fixedCost=5, variableCost=0.5, priority=priorOrder)71bpmsim.setActivity(BPMN=order, name="Emit invoice", resources=[clerk], amount=[1],72 duration=lambda: scipy.stats.norm.rvs(loc=4,scale=2),73 fixedCost=5, variableCost=0.5, priority=priorOrder)74bpmsim.setActivity(BPMN=order, name="Receive payment", resources=[clerk], amount=[1],75 duration=lambda: scipy.stats.norm.rvs(loc=6,scale=3),76 fixedCost=5, variableCost=0.5, priority=priorOrder)77bpmsim.setActivity(BPMN=order, name="Ship product", resources=[clerk], amount=[1],78 duration=lambda: scipy.stats.norm.rvs(loc=8,scale=2),79 fixedCost=5, variableCost=0.5, priority=priorOrder)8081# SET INTERMEDIATE EVENTS82bpmsim.setIntermediate(BPMN=order, name="Stock availability checked", duration=lambda: 0, getStore=[], putStore=[])83bpmsim.setIntermediate(BPMN=order, name="Raw materials acquired", duration=lambda: 0, getStore=[], putStore=[])84bpmsim.setIntermediate(BPMN=order, name="Order confirmed", duration=lambda: 0, getStore=[], putStore=[])85bpmsim.setIntermediate(BPMN=order, name="Order shipped and invoiced", duration=lambda: 0, getStore=[], putStore=[])8687# SET END88bpmsim.setEnd(BPMN=order, name="Order fulfilled", putStore=[storeOrder])8990# SET XOR SPLIT91bpmsim.setXORsplit(BPMN=order,name="in stock?",92 nextElementsNames=["Retrieve product from warehouse","Stock availability checked"],93 probabilities=[70,30])94bpmsim.setXORsplit(BPMN=order,name="supplier?",95 nextElementsNames=["Request raw materials from supplier 1","Request raw materials from supplier 2"],96 probabilities=[50,50])9798# CREATE INSTANCES99instancesOrder = bpmsim.createInstanceDistribution("Order Fulfillment", time=48000, number=800,100 distribution=lambda: scipy.stats.beta.rvs(a=2,b=5),101 between01=True, normalize=False)102103#-------------------------------------------------------#104#----------SIMULATION CREDIT APPLICATION CLERK----------#105#-------------------------------------------------------#106107# SET START108bpmsim.setStart(BPMN=creditClerk, name="Credit application received", getStore=[])109110# SET ACTIVITIES111bpmsim.setActivity(BPMN=creditClerk, name="Check credit history", resources=[clerk], amount=[1],112 duration=lambda: scipy.stats.norm.rvs(loc=10,scale=2),113 fixedCost=5, variableCost=0.5, priority=-1)114bpmsim.setActivity(BPMN=creditClerk, name="Check income sources", resources=[clerk], amount=[1],115 duration=lambda: scipy.stats.norm.rvs(loc=10,scale=4),116 fixedCost=5, variableCost=0.5, priority=0)117bpmsim.setActivity(BPMN=creditClerk, name="Send e-mail to customer", resources=[clerk], amount=[1],118 duration=lambda: scipy.stats.norm.rvs(loc=10,scale=2),119 fixedCost=5, variableCost=0.5)120121# SET INTERMEDIATE EVENTS122bpmsim.setIntermediate(BPMN=creditClerk, name="Credit Application checked",123 duration = lambda:0,putStore=[storeApplication])124125# SET END126bpmsim.setEnd(BPMN=creditClerk, name="Customer notified", putStore=[])127128# SET XOR SPLIT129130# CREATE INSTANCES131instancesClerk = bpmsim.createInstancesInterDistribution("Credit Application Clerk",132 startTime=0, time=None, number=2400,133 interval=lambda:scipy.stats.norm.rvs(loc=20,scale=1))134135#----------------------------------------------------------------#136#----------SIMULATION CREDIT APPLICATION CREDIT OFFICER----------#137#----------------------------------------------------------------#138139# SET START140bpmsim.setStart(BPMN=creditCreditOfficer, name="Credit application received", getStore=[storeApplication])141142# SET ACTIVITIES143bpmsim.setActivity(BPMN=creditCreditOfficer, name="Assess application", resources=[creditOfficer], amount=[1],144 duration=lambda: scipy.stats.expon.rvs(loc=20),145 fixedCost=5, variableCost=1)146bpmsim.setActivity(BPMN=creditCreditOfficer, name="Receive customer feedback")147bpmsim.setActivity(BPMN=creditCreditOfficer, name="Notify rejection", resources=[creditOfficer], amount=[1],148 duration=lambda: scipy.stats.norm.rvs(loc=10,scale=2),149 fixedCost=5, variableCost=1)150bpmsim.setActivity(BPMN=creditCreditOfficer, name="Make credit offer", resources=[creditOfficer], amount=[1],151 duration=lambda: scipy.stats.norm.rvs(loc=10,scale=2),152 fixedCost=5, variableCost=1)153154# SET INTERMEDIATE EVENTS155156# SET END157bpmsim.setEnd(BPMN=creditCreditOfficer, name="Credit application processed", putStore=[])158159# SET XOR SPLIT160bpmsim.setXORsplit(BPMN=creditCreditOfficer,name="decision review requested",161 nextElementsNames=["start loop","end join credit"],162 probabilities=[30,70])163bpmsim.setXORsplit(BPMN=creditCreditOfficer,name="application?",164 nextElementsNames=["Notify rejection","Make credit offer"],165 probabilities=[20,80])166167# CREATE INSTANCES168instancesCreditOfficer = bpmsim.createInstancesFixed("Credit Application Credit Officer",169 startTime=0, time=None, number=2400, interval=0)170171#-----------------------------------------#172#----------SIMULATION ALL MODELS----------#173#-----------------------------------------#174175# SET SIMULATION PARAMETERS176sim = bpmsim.simulation(instances=[instancesOrder, instancesClerk, instancesCreditOfficer],177 resources=[clerk, creditOfficer],stores=[storeOrder, storeApplication])178179# OUTPUT180sim.simulation(fileName="C:/​Users/​Droomelot/​Documents/​SCHOOL/​Masterproef/​DEMONSTRATION_output")181sim.simInfo(fileName="C:/​Users/​Droomelot/​Documents/​SCHOOL/​Masterproef/​DEMONSTRATION_info")182sim.simPlot(fileName="C:/​Users/​Droomelot/​Documents/​SCHOOL/​Masterproef/​DEMONSTRATION_plot")183184#--------------------------------------------------------#185#----------SIMULATION CREDIT APPLICATION MODELS----------#186#--------------------------------------------------------#187188# SET SIMULATION PARAMETERS189sim = bpmsim.simulation(instances=[instancesClerk, instancesCreditOfficer],190 resources=[clerk, creditOfficer],stores=[storeApplication])191192# OUTPUT193sim.simulation(fileName="C:/​Users/​Droomelot/​Documents/​SCHOOL/​Masterproef/​DEMONSTRATION_output_credit")194sim.simInfo(fileName="C:/​Users/​Droomelot/​Documents/​SCHOOL/​Masterproef/​DEMONSTRATION_info_credit") ...

Full Screen

Full Screen

classvk.py

Source: classvk.py Github

copy

Full Screen

1import vk_api2import lang3from vk_api.keyboard import VkKeyboard, VkKeyboardColor4from vk_api.utils import get_random_id5langs = lang.lang()6class VapeBot:7 cache = {}8 def __init__(self,token):9 self.token = token10 self.vk = vk_api.VkApi(token=token).get_api()11 def PrepareUser(self,uid):12 if not uid in self.cache:13 self.cache[uid] = {"activity":0}14 def SetActivity(self,uid,id):15 self.cache[uid]["activity"] = id16 def GetActivity(self,uid):17 return self.cache[uid]["activity"]18 def SetLocal(self,uid,key,value):19 self.cache[uid][key] = value20 def GetLocal(self,uid,key):21 return self.cache[uid][key]22 def SendMessage(self,uid,text):23 self.vk.messages.send(peer_id=int(uid),random_id=get_random_id(),message=text)24 def ShowMainKeyboard(self,uid):25 k = VkKeyboard(one_time=False)26 k.add_button(langs.sell, color=VkKeyboardColor.POSITIVE)27 k.add_button(langs.buy, color=VkKeyboardColor.POSITIVE)28 k.add_line()29 k.add_button(langs.items, color=VkKeyboardColor.PRIMARY)30 self.vk.messages.send(peer_id=int(uid),random_id=get_random_id(),message=langs.menu,keyboard=k.get_keyboard())31 self.SetActivity(uid,0)32 33 def StartSell(self,uid):34 k = VkKeyboard(one_time=False)35 k.add_button(langs.back, color=VkKeyboardColor.NEGATIVE)36 self.vk.messages.send(peer_id=int(uid),random_id=get_random_id(),message=langs.sell_stage_1,keyboard=k.get_keyboard())37 self.SetActivity(uid,11)38 def BackScript(self,uid):39 if self.GetActivity(uid) > 0:40 self.ShowMainKeyboard(uid)41 def SellScript(self,uid,message):42 if self.GetActivity(uid) == 11:43 if len(message) > 4:44 self.SetLocal(uid,"POD_NAME",message)45 self.SetActivity(uid,12)46 self.SendMessage(uid,langs.sell_stage_2)47 return 148 else:49 self.SendMessage(uid,langs.sell_stage_1_error)50 return 151 if self.GetActivity(uid) == 12:52 if len(message) > 10:53 self.SetLocal(uid,"POD_DESC",message)54 self.SetActivity(uid,13)55 self.SendMessage(uid,langs.sell_stage_3)56 return 157 else:58 self.SendMessage(uid,langs.sell_stage_2_error)59 return 160 if self.GetActivity(uid) == 13:61 if message.isdigit():62 self.SetLocal(uid,"POD_PRICE",message)63 #self.SetActivity(uid,14)64 #self.SendMessage(uid,langs.sell_stage_4)65 self.BackScript(uid)66 self.SendMessage(uid,langs.sell_finish)67 return 168 else:69 self.SendMessage(uid,langs.sell_stage_3_error)70 return 171 #if self.GetActivity(uid) == 14:72 # if type(message) == dict:73 # self.SetLocal(uid,"POD_IMAGE",message)74 # self.BackScript(uid)75 # self.SendMessage(uid,langs.sell_finish)76 # return 177 # else:78 # self.SendMessage(uid,langs.sell_stage_4_error)79 # return 180 return False...

Full Screen

Full Screen

shared.py

Source: shared.py Github

copy

Full Screen

1# from runtime import eprint, say, reply, replypos, replyend, createtextchannel, createvoicechannel, requestauthor, requestnotauthor, requestrole, requestnotrole, requestchannel, requestnotchannel, requestbot, embed, requestchanneltype, clear, replykick, kick, replyban, ban, opendm, requestmessage, requestnotmessage, setstatus, setactivity, sleep2# methods = {3# "print": eprint,4# "say": say,5# "reply": reply,6# "replypos": replypos,7# "replyend": replyend,8# "createtextchannel": createtextchannel,9# "createvoicechannel": createvoicechannel,10# "requestauthor": requestauthor,11# "requestnotauthor": requestnotauthor,12# "requestrole": requestrole,13# "requestnotrole": requestnotrole,14# "requestchannel": requestchannel,15# "requestnotchannel": requestnotchannel,16# "requestbot": requestbot,17# "embed": embed,18# "requestchanneltype": requestchanneltype,19# "clear": clear,20# "replykick": replykick,21# "kick": kick,22# "replyban": replyban,23# "ban": ban,24# "opendm": opendm,25# "igrequestauthor": requestauthor,26# "igrequestnotauthor": requestnotauthor,27# "igrequestrole": requestrole,28# "igrequestnotrole": requestnotrole,29# "igrequestchannel": requestchannel,30# "igrequestnotchannel": requestnotchannel,31# "igrequestbot": requestbot,32# "igrequestchanneltype": requestchanneltype,33# "requestmessage": requestmessage,34# "requestnotmessage": requestnotmessage,35# "igrequestmessage": requestmessage,36# "igrequestnotmessage": requestnotmessage,37# "setstatus": setstatus,38# "setactivity": setactivity,39# "sleep": sleep40# }41# commands = methods.keys()42# commands = []43commands = [44 "setprefix",45 "print",46 "say",47 "reply",48 "replypos",49 "replyend",50 "createtextchannel",51 "createvoicechannel",52 "requestauthor",53 "requestnotauthor",54 "requestrole",55 "requestnotrole",56 "requestchannel",57 "requestnotchannel",58 "requestbot",59 "embed",60 "requestchanneltype",61 "clear",62 "replykick",63 "kick",64 "replyban",65 "ban",66 "opendm",67 "igrequestauthor",68 "igrequestnotauthor",69 "igrequestrole",70 "igrequestnotrole",71 "igrequestchannel",72 "igrequestnotchannel",73 "igrequestbot",74 "igrequestchanneltype",75 "requestmessage",76 "requestnotmessage",77 "igrequestmessage",78 "igrequestnotmessage",79 "setstatus",80 "setactivity",81 "sleep",82 "reaction",83 "reactionadd",84 "reactions",85 "reactionremove",86 "addreaction",87 "parsereactionpayload",88 "readjson",89 "writejson",...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Aug’ 20 Updates: Live Interaction In Automation, macOS Big Sur Preview & More

Hey Testers! We know it’s been tough out there at this time when the pandemic is far from gone and remote working has become the new normal. Regardless of all the hurdles, we are continually working to bring more features on-board for a seamless cross-browser testing experience.

What is Selenium Grid & Advantages of Selenium Grid

Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.

7 Skills of a Top Automation Tester in 2021

With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

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 tox 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