How to use quit method in avocado

Best Python code snippet using avocado_python

KeyboardQuitSnackbarHelper.js

Source:KeyboardQuitSnackbarHelper.js Github

copy

Full Screen

1import React from 'react'2import PropTypes from 'prop-types'3import { Snackbar, SnackbarContent, Button } from '@material-ui/core'4import shallowCompare from 'react-addons-shallow-compare'5import { ipcRenderer } from 'electron'6import ElectronAccelerator from './ElectronAccelerator'7import { withStyles } from '@material-ui/core/styles'8import {9 WB_ATTEMPT_FULL_QUIT_KEYBOARD_ACCEL,10 WB_QUIT_APP11} from 'shared/ipcEvents'12const styles = {13 snackbarContentRoot: {14 flexDirection: 'column'15 },16 snackbarContentAction: {17 width: '100%',18 justifyContent: 'center',19 paddingLeft: 0,20 paddingRight: 0,21 marginRight: 0,22 marginLeft: 0,23 marginTop: 1024 },25 snackbarContentMessage: {26 width: '100%',27 textAlign: 'center'28 },29 accelerator: {30 display: 'inline-block',31 margin: '0px 0.5ch'32 },33 kbd: {34 display: 'inline-block',35 border: '2px solid #FFF',36 padding: 4,37 borderRadius: 4,38 margin: '0px 1ch',39 minWidth: 30,40 textAlign: 'center',41 fontFamily: 'inherit'42 }43}44const QUIT_CYCLE_LENGTH = 300045@withStyles(styles)46class KeyboardQuitSnackbarHelper extends React.Component {47 /* **************************************************************************/48 // PropTypes49 /* **************************************************************************/50 static propTypes = {51 onRequestAlwaysQuitImmediately: PropTypes.func52 }53 /* **************************************************************************/54 // Lifecycle55 /* **************************************************************************/56 constructor (props) {57 super(props)58 this.quitCycleCancel = null59 }60 /* **************************************************************************/61 // Component Lifecycle62 /* **************************************************************************/63 componentDidMount () {64 ipcRenderer.on(WB_ATTEMPT_FULL_QUIT_KEYBOARD_ACCEL, this._handleAttemptQuit)65 }66 componentWillUnmount () {67 ipcRenderer.removeListener(WB_ATTEMPT_FULL_QUIT_KEYBOARD_ACCEL, this._handleAttemptQuit)68 clearTimeout(this.quitCycleCancel)69 }70 /* **************************************************************************/71 // Data lifecycle72 /* **************************************************************************/73 state = {74 accelerator: null,75 isInQuitCycle: false76 }77 /* **************************************************************************/78 // UI Events79 /* **************************************************************************/80 /**81 * Handles the attempted full quit82 * @param evt: the event that fired83 * @param accelerator: the keyboard accelerator84 */85 _handleAttemptQuit = (evt, accelerator) => {86 if (ElectronAccelerator.isValid(accelerator)) {87 this.setState((prevState) => {88 clearTimeout(this.quitCycleCancel)89 if (prevState.isInQuitCycle) {90 ipcRenderer.send(WB_QUIT_APP)91 return { isInQuitCycle: false }92 } else {93 this.quitCycleCancel = setTimeout(() => {94 this.setState({ isInQuitCycle: false })95 }, QUIT_CYCLE_LENGTH)96 return {97 accelerator: accelerator,98 isInQuitCycle: true99 }100 }101 })102 } else {103 ipcRenderer.send(WB_QUIT_APP)104 }105 }106 handleDismiss = () => {107 clearTimeout(this.quitCycleCancel)108 this.setState({ isInQuitCycle: false })109 }110 handleQuitImmediately = () => {111 this.setState({ isInQuitCycle: false })112 this.props.onRequestAlwaysQuitImmediately()113 // A little bit bad from a UX perspective, but we need the action to dispatch and write to disk ideally!114 setTimeout(() => {115 ipcRenderer.send(WB_QUIT_APP)116 }, 1000)117 }118 /* **************************************************************************/119 // Rendering120 /* **************************************************************************/121 shouldComponentUpdate (nextProps, nextState) {122 return shallowCompare(this, nextProps, nextState)123 }124 render () {125 const { classes, onRequestAlwaysQuitImmediately } = this.props126 const { accelerator, isInQuitCycle } = this.state127 const isValid = ElectronAccelerator.isValid(accelerator)128 return (129 <Snackbar130 autoHideDuration={QUIT_CYCLE_LENGTH}131 anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}132 open={isInQuitCycle && isValid}133 onClose={this.handleDismiss}>134 <SnackbarContent135 classes={onRequestAlwaysQuitImmediately ? {136 root: classes.snackbarContentRoot,137 action: classes.snackbarContentAction,138 message: classes.snackbarContentMessage139 } : undefined}140 action={(141 <React.Fragment>142 {onRequestAlwaysQuitImmediately ? (143 <Button color='secondary' size='small' onClick={this.handleQuitImmediately}>144 Always Quit Immediately145 </Button>146 ) : undefined}147 <Button color='secondary' size='small' onClick={this.handleDismiss}>148 Cancel149 </Button>150 </React.Fragment>151 )}152 message={(153 <span>154 Press155 <ElectronAccelerator156 className={classes.accelerator}157 keyClassName={classes.kbd}158 accelerator={accelerator} />159 again to quit160 </span>161 )} />162 </Snackbar>163 )164 }165}...

Full Screen

Full Screen

context-menu.js

Source:context-menu.js Github

copy

Full Screen

1(function($) {2 'use strict';3 $.contextMenu({4 selector: '#context-menu-simple',5 callback: function(key, options) {},6 items: {7 "edit": {8 name: "Edit",9 icon: "edit"10 },11 "cut": {12 name: "Cut",13 icon: "cut"14 },15 copy: {16 name: "Copy",17 icon: "copy"18 },19 "paste": {20 name: "Paste",21 icon: "paste"22 },23 "delete": {24 name: "Delete",25 icon: "delete"26 },27 "sep1": "---------",28 "quit": {29 name: "Quit",30 icon: function() {31 return 'context-menu-icon context-menu-icon-quit';32 }33 }34 }35 });36 $.contextMenu({37 selector: '#context-menu-access',38 callback: function(key, options) {39 var m = "clicked: " + key;40 window.console && console.log(m) || alert(m);41 },42 items: {43 "edit": {44 name: "Edit",45 icon: "edit",46 accesskey: "e"47 },48 "cut": {49 name: "Cut",50 icon: "cut",51 accesskey: "c"52 },53 // first unused character is taken (here: o)54 "copy": {55 name: "Copy",56 icon: "copy",57 accesskey: "c o p y"58 },59 // words are truncated to their first letter (here: p)60 "paste": {61 name: "Paste",62 icon: "paste",63 accesskey: "cool paste"64 },65 "delete": {66 name: "Delete",67 icon: "delete"68 },69 "sep1": "---------",70 "quit": {71 name: "Quit",72 icon: function($element, key, item) {73 return 'context-menu-icon context-menu-icon-quit';74 }75 }76 }77 });78 $.contextMenu({79 selector: '#context-menu-open',80 callback: function(key, options) {81 var m = "clicked: " + key;82 window.console && console.log(m) || alert(m);83 },84 items: {85 "edit": {86 name: "Closing on Click",87 icon: "edit",88 callback: function() {89 return true;90 }91 },92 "cut": {93 name: "Open after Click",94 icon: "cut",95 callback: function() {96 return false;97 }98 }99 }100 });101 $.contextMenu({102 selector: '#context-menu-multi',103 callback: function(key, options) {104 var m = "clicked: " + key;105 window.console && console.log(m) || alert(m);106 },107 items: {108 "edit": {109 "name": "Edit",110 "icon": "edit"111 },112 "cut": {113 "name": "Cut",114 "icon": "cut"115 },116 "sep1": "---------",117 "quit": {118 "name": "Quit",119 "icon": "quit"120 },121 "sep2": "---------",122 "fold1": {123 "name": "Sub group",124 "items": {125 "fold1-key1": {126 "name": "Foo bar"127 },128 "fold2": {129 "name": "Sub group 2",130 "items": {131 "fold2-key1": {132 "name": "alpha"133 },134 "fold2-key2": {135 "name": "bravo"136 },137 "fold2-key3": {138 "name": "charlie"139 }140 }141 },142 "fold1-key3": {143 "name": "delta"144 }145 }146 },147 "fold1a": {148 "name": "Other group",149 "items": {150 "fold1a-key1": {151 "name": "echo"152 },153 "fold1a-key2": {154 "name": "foxtrot"155 },156 "fold1a-key3": {157 "name": "golf"158 }159 }160 }161 }162 });163 $.contextMenu({164 selector: '#context-menu-hover',165 trigger: 'hover',166 delay: 500,167 callback: function(key, options) {168 var m = "clicked: " + key;169 window.console && console.log(m) || alert(m);170 },171 items: {172 "edit": {173 name: "Edit",174 icon: "edit"175 },176 "cut": {177 name: "Cut",178 icon: "cut"179 },180 "copy": {181 name: "Copy",182 icon: "copy"183 },184 "paste": {185 name: "Paste",186 icon: "paste"187 },188 "delete": {189 name: "Delete",190 icon: "delete"191 },192 "sep1": "---------",193 "quit": {194 name: "Quit",195 icon: function($element, key, item) {196 return 'context-menu-icon context-menu-icon-quit';197 }198 }199 }200 });201 $.contextMenu({202 selector: '#context-menu-hover-autohide',203 trigger: 'hover',204 delay: 500,205 autoHide: true,206 callback: function(key, options) {207 var m = "clicked: " + key;208 window.console && console.log(m) || alert(m);209 },210 items: {211 "edit": {212 name: "Edit",213 icon: "edit"214 },215 "cut": {216 name: "Cut",217 icon: "cut"218 },219 "copy": {220 name: "Copy",221 icon: "copy"222 },223 "paste": {224 name: "Paste",225 icon: "paste"226 },227 "delete": {228 name: "Delete",229 icon: "delete"230 },231 "sep1": "---------",232 "quit": {233 name: "Quit",234 icon: function($element, key, item) {235 return 'context-menu-icon context-menu-icon-quit';236 }237 }238 }239 });...

Full Screen

Full Screen

trans_working_with_functions.py

Source:trans_working_with_functions.py Github

copy

Full Screen

1Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win322Type "help", "copyright", "credits" or "license()" for more information.3>>> 4 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes.py 5Enter a number: 126The number is not prime7>>> 8 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes.py 9Enter a number: 1310The number is prime11>>> list(range(2, 1))12[]13>>> 14 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes.py 15Enter a number: 116The number is prime17>>> 18 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes.py 19Enter a number: 220The number is prime21>>> list(range(2, 1, -1))22[2]23>>> list(range(2, 0, -1))24[2, 1]25>>> 26 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes2.py 27Enter a number: 1228The number is not prime29>>> 30 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes2.py 31Enter a number: 4732The number is prime33>>> import primes234Enter a number: 1235The number is not prime36>>> primes2.checkprime(100)37False38>>> primes2.checkprime(1)39True40>>> for n in range(10):41 primes2.checkprime(n)4243 44True45True46True47True48False49True50False51True52False53False54>>> 55 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/project_a.py 56Enter a number: 357The number is prime58Enter a start point: 1059Enter a end point: 10060----------------------------------------61PRIMES: 62[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]63>>> 64 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/primes2.py 65Enter a number: 1266The number is not prime67>>> 68 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/project_a.py 69Enter a start point: 1070Enter a end point: 10071----------------------------------------72PRIMES: 73[11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]74>>> 75 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/project_b.py 76(q to quit)--> 1277(q to quit)--> 3478(q to quit)--> 4579(q to quit)--> 5680(q to quit)--> 6781(q to quit)--> dd82(q to quit)--> ff83(q to quit)--> gg84(q to quit)--> hh85(q to quit)--> 5686(q to quit)--> 6787(q to quit)--> 7888(q to quit)--> q89------------------------------------------------------------90[12, 34, 45, 56, 67, 56, 67, 78]91>>> 92 RESTART: C:/Users/Purushotham/Desktop/oracle_july/day_02/examples/project_b.py 93(q to quit)--> 1294(q to quit)--> 2395(q to quit)--> 3496(q to quit)--> 4597(q to quit)--> 5698(q to quit)--> 6799(q to quit)--> 78100(q to quit)--> 89101(q to quit)--> 45102(q to quit)--> 56103(q to quit)--> 67104(q to quit)--> 45105(q to quit)--> 34106(q to quit)--> 23107(q to quit)--> fsda108(q to quit)--> dfg109(q to quit)--> xcbv110(q to quit)--> asdgf111(q to quit)--> asdf112(q to quit)--> wer113(q to quit)--> asdf114(q to quit)--> 23115(q to quit)--> 45116(q to quit)--> q117--------------------------------------------------------------------------------118MAXIMUM : 89119MINIMUM : 12120AVERAGE : 46.375121MEDIAN : 45.0122PRIMES : 6123--------------------------------------------------------------------------------124>>> import primes2 ...

Full Screen

Full Screen

test_convenience.py

Source:test_convenience.py Github

copy

Full Screen

1# Copyright (c) Twisted Matrix Laboratories.2# See LICENSE for details.3"""4Test cases for convenience functionality in L{twisted._threads._convenience}.5"""6from __future__ import absolute_import, division, print_function7from twisted.trial.unittest import SynchronousTestCase8from .._convenience import Quit9from .._ithreads import AlreadyQuit10class QuitTests(SynchronousTestCase):11 """12 Tests for L{Quit}13 """14 def test_isInitiallySet(self):15 """16 L{Quit.isSet} starts as L{False}.17 """18 quit = Quit()19 self.assertEqual(quit.isSet, False)20 def test_setSetsSet(self):21 """22 L{Quit.set} sets L{Quit.isSet} to L{True}.23 """24 quit = Quit()25 quit.set()26 self.assertEqual(quit.isSet, True)27 def test_checkDoesNothing(self):28 """29 L{Quit.check} initially does nothing and returns L{None}.30 """31 quit = Quit()32 self.assertIs(quit.check(), None)33 def test_checkAfterSetRaises(self):34 """35 L{Quit.check} raises L{AlreadyQuit} if L{Quit.set} has been called.36 """37 quit = Quit()38 quit.set()39 self.assertRaises(AlreadyQuit, quit.check)40 def test_setTwiceRaises(self):41 """42 L{Quit.set} raises L{AlreadyQuit} if it has been called previously.43 """44 quit = Quit()45 quit.set()...

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