Best Python code snippet using tox_python
Demonstration_Code.py
Source: Demonstration_Code.py
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")
...
classvk.py
Source: classvk.py
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...
shared.py
Source: shared.py
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",...
Check out the latest blogs from LambdaTest on this topic:
Were you able to work upon your resolutions for 2019? I may sound comical here but my 2019 resolution being a web developer was to take a leap into web testing in my free time. Why? So I could understand the release cycles from a tester’s perspective. I wanted to wear their shoes and see the SDLC from their eyes. I also thought that it would help me groom myself better as an all-round IT professional.
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
The web development industry is growing, and many Best Automated UI Testing Tools are available to test your web-based project to ensure it is bug-free and easily accessible for every user. These tools help you test your web project and make it fully compatible with user-end requirements and needs.
Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.
Building a website is all about keeping the user experience in mind. Ultimately, it’s about providing visitors with a mind-blowing experience so they’ll keep coming back. One way to ensure visitors have a great time on your site is to add some eye-catching text or image animations.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!