How to use run_short method in autotest

Best Python code snippet using autotest_python

typing.py

Source:typing.py Github

copy

Full Screen

1#!/usr/bin/env python32# TODD: update to latest pyxhook, if it exists3# TODO: update display4# TODO: allow users to configure5# TODO: include differt sounds6# TODO: make sound dependent on performance7# TODO: register commonly made mistakes (which char sequence is followed by bs)8# TODO: make the python version available for Windows9# DONE: make playing sound less verbose10# DONE: host on github11# DONE: sort out licence, disentangle from keylogger12# DONE: added requirements.txt13# Done: add install notes with required libraries14import os15import datetime16import pyxhook17def now():18 return datetime.datetime.now()19class Sound(object):20 def beep(sec, freq):21 os.system('play -q -n synth %s sin %s' % (sec, freq))22class Typing(object):23 def __init__(self):24 self.last = now()25 self.nr_char = 026 self.run_long = 0 # the goal27 self.run_short = 50 # current28 def key_simple(self, k):29 if k == "BackSpace":30 print("Back space pressed.")31 Sound.beep(self.sec, self.freq)32 def key(self, k):33 if k == "BackSpace":34 time_delta = now() - self.last35 if time_delta > datetime.timedelta(seconds=1):36 self.run_long = self.run_long * 0.75 + self.nr_char * 0.2537 self.run_short = self.run_short * 0.5 + self.nr_char * 0.538 print(f'Characters typed since last backspace: {self.nr_char}')39 print(f'Running average (long/short):', end='')40 print(f' {self.run_long}/{self.run_short}')41 self.nr_char = 042 if self.run_short < 20:43 Sound.beep(0.5, 600)44 if self.run_short < self.run_long:45 Sound.beep(0.5, 400)46 self.last = now()47 else:48 self.nr_char += 149if __name__ == '__main__':50 typing = Typing()51 def OnKeyPress(event):52 typing.key(event.Key)53 if event.Ascii == 96: # the grave key (`)54 new_hook.cancel()55 new_hook = pyxhook.HookManager() # instantiate HookManager class56 new_hook.KeyDown = OnKeyPress # listen to all keystrokes57 new_hook.HookKeyboard() # hook the keyboard...

Full Screen

Full Screen

start_cgi.py

Source:start_cgi.py Github

copy

Full Screen

1#!/bin/env python2from __future__ import print_function3import cgi4import os5RUNNUMBER_PADDING=66form = cgi.FieldStorage()7print("Content-Type: text/html") # HTML is following8print()9print("<TITLE>CGI script output</TITLE>")10if "run" not in form:11 print("<H1>Error</H1>")12 print("Please fill in the run number ")13else:14 #add BU suffix15 bu_suffix = "_"+form["buname"].value if "buname" in form else ""16 #check for duplicate:17 run_short = 'run'+str(form["run"].value).zfill(RUNNUMBER_PADDING)18 run_long = 'run'+str(form["run"].value).zfill(RUNNUMBER_PADDING)+bu_suffix19 #check for both variants (renaming race)20 if os.path.exists(run_long) or os.path.exists(run_short):21 print("<H1>run "+str(form["run"].value)+" alreary exists</H1>")22 print("in dir "+os.getcwd())23 #trip exception 24 raise FileExistsError("Directory for " + run_short + " exists")25 else:26 os.mkdir(run_short+bu_suffix)27 print("<H1>run "+str(form["run"].value)+" created</H1>")...

Full Screen

Full Screen

test_interactive.py

Source:test_interactive.py Github

copy

Full Screen

...7 ppg.new_pipegraph()8 def run_long():9 time.sleep(20)10 raise ValueError()11 def run_short():12 time.sleep(5)13 with open("short.dat", "wb") as op:14 op.write("DONO")15 if os.path.exists("short.dat"):16 os.unlink("short.dat")17 if os.path.exists("long.dat"):18 os.unlink("long.dat")19 job1 = ppg.FileGeneratingJob("long.dat", run_long)20 job2 = ppg.FileGeneratingJob("short.dat", run_short)21 job1.depends_on(job2)...

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