Best Python code snippet using fMBT_python
remote-object.js
Source:remote-object.js
...10 return Protocol.Runtime.evaluate(options);11}12InspectorTest.runAsyncTestSuite([13 async function testNull() {14 InspectorTest.logMessage((await evaluate({15 expression: 'null'16 })).result);17 InspectorTest.logMessage((await evaluate({18 expression: 'null',19 returnByValue: true20 })).result);21 InspectorTest.logMessage((await evaluate({22 expression: 'null',23 generatePreview: true24 })).result);25 },26 async function testBoolean() {27 InspectorTest.logMessage((await evaluate({28 expression: 'true'29 })).result);30 InspectorTest.logMessage((await evaluate({31 expression: 'false'32 })).result);33 InspectorTest.logMessage((await evaluate({34 expression: 'true',35 returnByValue: true,36 })).result);37 InspectorTest.logMessage((await evaluate({38 expression: 'true',39 generatePreview: true,40 })).result);41 },42 async function testNumber() {43 InspectorTest.logMessage((await evaluate({44 expression: '0 / {}'45 })).result);46 InspectorTest.logMessage((await evaluate({47 expression: '-0'48 })).result);49 InspectorTest.logMessage((await evaluate({50 expression: '0'51 })).result);52 InspectorTest.logMessage((await evaluate({53 expression: '1/0'54 })).result);55 InspectorTest.logMessage((await evaluate({56 expression: '-1/0'57 })).result);58 InspectorTest.logMessage((await evaluate({59 expression: '2.3456'60 })).result);61 InspectorTest.logMessage((await evaluate({62 expression: '2.3456',63 returnByValue: true64 })).result);65 InspectorTest.logMessage((await evaluate({66 expression: '1/0',67 returnByValue: true68 })).result);69 InspectorTest.logMessage((await evaluate({70 expression: '({a: 1/0})',71 returnByValue: true72 })).result);73 },74 async function testUndefined() {75 InspectorTest.logMessage((await evaluate({76 expression: 'undefined'77 })).result);78 InspectorTest.logMessage((await evaluate({79 expression: 'undefined',80 returnByValue: true81 })).result);82 InspectorTest.logMessage((await evaluate({83 expression: '({a : undefined})',84 returnByValue: true85 })).result);86 InspectorTest.logMessage((await evaluate({87 expression: '([1, undefined])',88 returnByValue: true89 })).result);90 },91 async function testString() {92 InspectorTest.logMessage((await evaluate({93 expression: '\'Hello!\''94 })).result);95 InspectorTest.logMessage((await evaluate({96 expression: '\'Hello!\'',97 returnByValue: true98 })).result);99 InspectorTest.logMessage((await evaluate({100 expression: '\'Hello!\'',101 generatePreview: true102 })).result);103 },104 async function testSymbol() {105 InspectorTest.logMessage((await evaluate({106 expression: 'Symbol()',107 generatePreview: true108 })).result);109 InspectorTest.logMessage((await evaluate({110 expression: 'Symbol(42)',111 generatePreview: true112 })).result);113 InspectorTest.logMessage((await evaluate({114 expression: `Symbol('abc')`,115 generatePreview: true116 })).result);117 InspectorTest.logMessage((await evaluate({118 expression: `Symbol('abc')`,119 returnByValue: true120 })));121 },122 async function testReturnByValue() {123 InspectorTest.log('Empty object');124 InspectorTest.logMessage((await evaluate({125 expression: '({})', returnByValue: true126 })).result);127 InspectorTest.log('Object with properties');128 InspectorTest.logMessage((await evaluate({129 expression: '({a:1, b:2})', returnByValue: true130 })).result);131 InspectorTest.log('Object with cycle');132 InspectorTest.logMessage((await evaluate({133 expression: 'a = {};a.a = a; a', returnByValue: true134 })).error);135 InspectorTest.log('Function () => 42');136 InspectorTest.logMessage((await evaluate({137 expression: '() => 42', returnByValue: true138 })).result);139 InspectorTest.log('Symbol(42)');140 InspectorTest.logMessage((await evaluate({141 expression: 'Symbol(42)', returnByValue: true142 })).error);143 InspectorTest.log('Error object');144 InspectorTest.logMessage((await evaluate({145 expression: 'new Error()', returnByValue: true146 })).result);147 },148 async function testFunction() {149 InspectorTest.logMessage((await evaluate({150 expression: '(() => 42)'151 })).result);152 InspectorTest.logMessage((await evaluate({153 expression: '(function() { return 42 })'154 })).result);155 InspectorTest.logMessage((await evaluate({156 expression: '(function name() { return 42 })'157 })).result);158 InspectorTest.logMessage((await evaluate({159 expression: '(async function asyncName() { return 42 })'160 })).result);161 InspectorTest.logMessage((await evaluate({162 expression: '(async () => 42)'163 })).result);164 InspectorTest.logMessage((await evaluate({165 expression: '(function (a) { return a; }).bind(null, 42)'166 })).result);167 InspectorTest.logMessage((await evaluate({168 expression: 'a = (function() { return 42 }); a.b = 2; a',169 generatePreview: true170 })).result);171 InspectorTest.logMessage((await evaluate({172 expression: '(function() { return 42 })',173 returnByValue: true174 })).result);175 InspectorTest.logMessage((await evaluate({176 expression: 'a = (function() { return 42 }); a.b = 2; a',177 returnByValue: true178 })).result);179 },180 async function testBigInt() {181 InspectorTest.logMessage((await evaluate({182 expression: '1n'183 })).result);184 InspectorTest.logMessage((await evaluate({185 expression: '-5n'186 })).result);187 InspectorTest.logMessage((await evaluate({188 expression: '1234567890123456789012345678901234567890n'189 })).result);190 InspectorTest.logMessage((await evaluate({191 expression: '-5n',192 returnByValue: true193 })).result);194 InspectorTest.logMessage((await evaluate({195 expression: '-5n',196 generatePreview: true197 })).result);198 },199 async function testRegExp() {200 InspectorTest.logMessage((await evaluate({201 expression: '/\w+/g'202 })).result);203 InspectorTest.logMessage((await evaluate({204 expression: '/\w+/i'205 })).result);206 InspectorTest.logMessage((await evaluate({207 expression: '/\w+/m'208 })).result);209 InspectorTest.logMessage((await evaluate({210 expression: '/\w+/s'211 })).result);212 InspectorTest.logMessage((await evaluate({213 expression: '/\w+/u'214 })).result);215 InspectorTest.logMessage((await evaluate({216 expression: '/\w+/y'217 })).result);218 InspectorTest.logMessage((await evaluate({219 expression: '/\w+/gimsuy'220 })).result);221 InspectorTest.logMessage((await evaluate({222 expression: `new RegExp('\\w+', 'g')`,223 })).result);224 InspectorTest.logMessage((await evaluate({225 expression: `var re = new RegExp('\\w+', 'g');226 re.prop = 32;227 re`,228 generatePreview: true229 })).result);230 InspectorTest.logMessage((await evaluate({231 expression: `var re = new RegExp('\\w+', 'g');232 re.prop = 32;233 re`,234 returnByValue: true235 })).result);236 },237 async function testDate() {238 let result = (await evaluate({239 expression: `new Date('May 18, 1991 03:24:00')`,240 generatePreview: true241 })).result;242 if (result.result.description === new Date('May 18, 1991 03:24:00') + '')243 result.result.description = '<expected description>';244 if (result.result.preview.description === new Date('May 18, 1991 03:24:00') + '')245 result.result.preview.description = '<expected description>';246 InspectorTest.logMessage(result);247 result = (await evaluate({248 expression: `new Date(2018, 9, 31)`,249 generatePreview: true250 })).result;251 if (result.result.description === new Date(2018, 9, 31) + '')252 result.result.description = '<expected description>';253 if (result.result.preview.description === new Date(2018, 9, 31) + '')254 result.result.preview.description = '<expected description>';255 InspectorTest.logMessage(result);256 result = (await evaluate({257 expression: `a = new Date(2018, 9, 31); a.b = 2; a`,258 generatePreview: true259 })).result;260 if (result.result.description === new Date(2018, 9, 31) + '')261 result.result.description = '<expected description>';262 if (result.result.preview.description === new Date(2018, 9, 31) + '')263 result.result.preview.description = '<expected description>';264 InspectorTest.logMessage(result);265 },266 async function testMap() {267 InspectorTest.logMessage((await evaluate({268 expression: 'new Map()',269 generatePreview: true,270 })).result);271 InspectorTest.logMessage((await evaluate({272 expression: 'new Map([[1,2]])',273 generatePreview: true,274 })).result);275 InspectorTest.logMessage((await evaluate({276 expression: 'a = new Map(); a.set(a, a); a',277 generatePreview: true,278 })).result);279 InspectorTest.logMessage((await evaluate({280 expression: `new Map([['a','b']])`281 })).result);282 InspectorTest.logMessage((await evaluate({283 expression: `({ a: new Map([['a','b']]) })`,284 generatePreview: true285 })).result);286 InspectorTest.logMessage((await evaluate({287 expression: `m = new Map([['a', {b: 2}]])288 m.d = 42;289 m`,290 generatePreview: true291 })).result);292 InspectorTest.logMessage((await evaluate({293 expression: `m = new Map([['a', {b: 2}]])294 m.d = 42;295 m`,296 returnByValue: true297 })).result);298 InspectorTest.logMessage((await evaluate({299 expression: `new Map([['a', {b: 2}]]).values()`300 })).result);301 InspectorTest.logMessage((await evaluate({302 expression: `new Map([['a', {b: 2}]]).values()`,303 generatePreview: true304 })).result);305 InspectorTest.logMessage((await evaluate({306 expression: `it = new Map([['a', {b: 2}]]).values(); it.next(); it`,307 generatePreview: true308 })).result);309 InspectorTest.logMessage((await evaluate({310 expression: `new Map([['a', {b: 2}]]).values()`,311 returnByValue: true312 })).result);313 InspectorTest.logMessage((await evaluate({314 expression: `new Map([['a', {b: 2}]]).entries()`315 })).result);316 InspectorTest.logMessage((await evaluate({317 expression: `new Map([['a', {b: 2}]]).entries()`,318 generatePreview: true319 })).result);320 InspectorTest.logMessage((await evaluate({321 expression: `it = new Map([['a', {b: 2}]]).entries(); it.next(); it`,322 generatePreview: true323 })).result);324 InspectorTest.logMessage((await evaluate({325 expression: `new Map([['a', {b: 2}]]).entries()`,326 returnByValue: true327 })).result);328 },329 async function testSet() {330 InspectorTest.logMessage((await evaluate({331 expression: 'new Set([1])',332 generatePreview: true333 })).result);334 InspectorTest.logMessage((await evaluate({335 expression: 'new Set([1])',336 returnByValue: true337 })).result);338 InspectorTest.logMessage((await evaluate({339 expression: 'new Set([1,2,3,4,5,6,7])',340 generatePreview: true341 })).result);342 InspectorTest.logMessage((await evaluate({343 expression: 'new Set([1,2,3]).values()',344 generatePreview: true345 })).result);346 InspectorTest.logMessage((await evaluate({347 expression: 'it = new Set([1,2,3]).values(); it.next(); it',348 generatePreview: true349 })).result);350 },351 async function testWeakMap() {352 InspectorTest.logMessage((await evaluate({353 expression: 'new WeakMap()',354 generatePreview: true355 })).result);356 InspectorTest.logMessage((await evaluate({357 expression: 'new WeakMap([[this, 1]])',358 generatePreview: true359 })).result);360 },361 async function testWeakSet() {362 InspectorTest.logMessage((await evaluate({363 expression: 'new WeakSet()',364 generatePreview: true365 })).result);366 InspectorTest.logMessage((await evaluate({367 expression: 'new WeakSet([this])',368 generatePreview: true369 })).result);370 },371 async function testGenerator() {372 InspectorTest.logMessage((await evaluate({373 expression: 'g = (function*(){ yield 42; })(); g.a = 2; g',374 generatePreview: true375 })).result);376 },377 async function testError() {378 InspectorTest.logMessage((await evaluate({379 expression: 'new Error()'380 })).result);381 InspectorTest.logMessage((await evaluate({382 expression: `new Error('abc')`383 })).result);384 InspectorTest.logMessage((await evaluate({385 expression: `new Error('at\\nat')`386 })).result);387 InspectorTest.logMessage((await evaluate({388 expression: `new Error('preview')`,389 returnByValue: true390 })).result);391 InspectorTest.logMessage((await evaluate({392 expression: `new Error('preview')`,393 generatePreview: true394 })).result);395 InspectorTest.logMessage((await evaluate({396 expression: `({a: new Error('preview')})`,397 generatePreview: true398 })).result);399 InspectorTest.logMessage((await evaluate({400 expression: `a = new Error('preview and a'); a.a = 123; a`,401 generatePreview: true402 })).result);403 InspectorTest.logMessage((await evaluate({404 expression: `a = new Error('preview and a'); a.a = 123; a`,405 returnByValue: true406 })).result);407 },408 async function testCustomError() {409 InspectorTest.logMessage((await evaluate({410 expression: `class CustomError extends Error {}; a = new CustomError(); delete a.stack; a`411 })).result);412 },413 async function testCustomErrorWithMessage() {414 InspectorTest.logMessage((await evaluate( {415 expression: `class CustomMsgError extends Error {}; a = new CustomMsgError(); delete a.stack; a.message = 'foobar'; a`416 })).result);417 },418 async function testProxy() {419 InspectorTest.logMessage((await evaluate({420 expression: 'new Proxy({}, {})'421 })).result);422 InspectorTest.logMessage((await evaluate({423 expression: 'new Proxy(new Error(), {})'424 })).result);425 InspectorTest.logMessage((await evaluate({426 expression: 'new Proxy({c: 3}, {d: 4})',427 returnByValue: true428 })).result);429 InspectorTest.logMessage((await evaluate({430 expression: 'new Proxy({a: 1}, {b: 2})',431 generatePreview: true432 })).result);433 InspectorTest.logMessage((await evaluate({434 expression: '({e: new Proxy({a: 1}, {b: 2})})',435 generatePreview: true436 })).result);437 },438 async function testPromise() {439 InspectorTest.logMessage((await evaluate({440 expression: 'Promise.resolve(42)'441 })).result);442 InspectorTest.logMessage((await evaluate({443 expression: 'Promise.reject(42)'444 })).result);445 InspectorTest.logMessage((await evaluate({446 expression: '(async function(){})()'447 })).result);448 InspectorTest.logMessage((await evaluate({449 expression: `Promise.resolve('a'.repeat(101))`,450 generatePreview: true451 })).result);452 InspectorTest.logMessage((await evaluate({453 expression: 'Promise.reject(42)',454 generatePreview: true455 })).result);456 InspectorTest.logMessage((await evaluate({457 expression: 'new Promise(resolve => this.resolve = resolve)',458 generatePreview: true459 })).result);460 InspectorTest.logMessage((await evaluate({461 expression: 'a = Promise.resolve(42); a.b = 2; a',462 returnByValue: true463 })).result);464 InspectorTest.logMessage((await evaluate({465 expression: '({a: Promise.resolve(42)})',466 generatePreview: true467 })).result);468 },469 async function testTypedArray() {470 InspectorTest.logMessage((await evaluate({471 expression: 'a = new Uint8Array(2); a.b = 2; a',472 generatePreview: true473 })).result);474 InspectorTest.logMessage((await evaluate({475 expression: 'new Int32Array(101)',476 generatePreview: true477 })).result);478 },479 async function testArrayBuffer() {480 InspectorTest.logMessage((await evaluate({481 expression: 'new Uint8Array().buffer',482 generatePreview: true483 })).result);484 InspectorTest.logMessage((await evaluate({485 expression: 'new Int32Array(100).buffer',486 generatePreview: true487 })).result);488 },489 async function testDataView() {490 InspectorTest.logMessage((await evaluate({491 expression: 'new DataView(new ArrayBuffer(16))',492 generatePreview: true493 })).result);494 InspectorTest.logMessage((await evaluate({495 expression: 'new DataView(new ArrayBuffer(16), 12, 4)',496 generatePreview: true497 })).result);498 },499 async function testArray() {500 InspectorTest.logMessage((await evaluate({501 expression: '[]'502 })).result);503 InspectorTest.logMessage((await evaluate({504 expression: '[1,2,3]'505 })).result);506 },507 async function testArrayLike() {508 InspectorTest.logMessage((await evaluate({509 expression: '({length: 5, splice: () => []})'510 })).result);511 InspectorTest.logMessage((await evaluate({512 expression: `new (class Foo{constructor() {513 this.length = 5;514 this.splice = () => [];515 }})`516 })).result);517 InspectorTest.logMessage((await evaluate({518 expression: '({length: -5, splice: () => []})'519 })).result);520 },521 async function testOtherObjects() {522 InspectorTest.logMessage((await evaluate({523 expression: '({a: 1, b:2})'524 })).result);525 InspectorTest.logMessage((await evaluate({526 expression: '({a: 1, b:2})',527 returnByValue: true528 })).result);529 InspectorTest.logMessage((await evaluate({530 expression: '({a: 1, b:2})',531 generatePreview: true532 })).result);533 InspectorTest.logMessage((await evaluate({534 expression: 'new (function Foo() { this.a = 5; })'535 })).result);536 InspectorTest.logMessage((await evaluate({537 expression: 'new (function Foo() { this.a = [1,2,3]; })',538 returnByValue: true539 })).result);540 InspectorTest.logMessage((await evaluate({541 expression: 'new (class Bar {})'542 })).result);543 InspectorTest.logMessage((await evaluate({544 expression: 'inspector.createObjectWithAccessor(\'title\', true)',545 generatePreview: true546 })));547 InspectorTest.logMessage((await evaluate({548 expression: 'inspector.createObjectWithAccessor(\'title\', false)',549 generatePreview: true550 })));551 // TODO(kozyatinskiy): fix this one.552 InspectorTest.logMessage((await evaluate({553 expression: 'inspector.createObjectWithAccessor(\'title\', true)',554 returnByValue: true555 })));556 InspectorTest.logMessage((await evaluate({557 expression: '({get a() { return 42; }})',558 generatePreview: true559 })));560 InspectorTest.logMessage((await evaluate({561 expression: '({set a(v) {}})',562 generatePreview: true563 })));564 InspectorTest.logMessage((await evaluate({565 expression: '({a: () => 42})',566 generatePreview: true567 })));568 InspectorTest.logMessage((await evaluate({569 expression: '({a: null})',570 generatePreview: true571 })));572 InspectorTest.logMessage((await evaluate({573 expression: '({a: true})',574 generatePreview: true575 })));576 InspectorTest.logMessage((await evaluate({577 expression: '({a1: -Infinity, a2: +Infinity, a3: -0, a4: NaN, a5: 1.23})',578 generatePreview: true579 })));580 InspectorTest.logMessage((await evaluate({581 expression: '({a1: 1234567890123456789012345678901234567890n})',582 generatePreview: true583 })));584 InspectorTest.logMessage((await evaluate({585 expression: '({a1: Symbol(42)})',586 generatePreview: true587 })));588 InspectorTest.logMessage((await evaluate({589 expression: '({a1: /abc/i})',590 generatePreview: true591 })));592 InspectorTest.logMessage((await evaluate({593 expression: '({a1: () => 42, a2: async () => 42})',594 generatePreview: true595 })));596 InspectorTest.logMessage((await evaluate({597 expression: '({a1: ({}), a2: new (class Bar{})})',598 generatePreview: true599 })));600 InspectorTest.logMessage((await evaluate({601 expression: `({a1: 'a'.repeat(100), a2: 'a'.repeat(101)})`,602 generatePreview: true603 })));604 InspectorTest.logMessage((await evaluate({605 expression: `({a1: 1, a2: 2, a3: 3, a4:4, a5:5, a6: 6})`,606 generatePreview: true607 })));608 InspectorTest.logMessage((await evaluate({609 expression: `([1,2,3])`,610 generatePreview: true611 })));612 },613 async function testArray2() {614 InspectorTest.logMessage((await evaluate({615 expression: `([1,2,3])`616 })));617 InspectorTest.logMessage((await evaluate({618 expression: `([1,2,3])`,619 returnByValue: true620 })));621 InspectorTest.logMessage((await evaluate({622 expression: `([1,2,3])`,623 generatePreview: true624 })));625 InspectorTest.logMessage((await evaluate({626 expression: `({a: [1,2,3]})`,627 generatePreview: true628 })));629 }...
app.py
Source:app.py
...26@app.route('/index')27@app.route('/menu')28@app.route('/home')29def index():30 logMessage('index')31 return loginModule.index()32@app.route('/employeeMenu')33def employeeMenu():34 logMessage('employeeMenu')35 return loginModule.employeeMenu()36@app.route('/userAddMessage', methods=['POST'])37def addMessage():38 logMessage('userAddMessage')39 return loginModule.addMessage()40@app.route('/administratorMenu')41def administratorMenu():42 logMessage('administratorMenu')43 return loginModule.administratorMenu()44@app.route('/masterMenu')45def masterMenu():46 logMessage('masterMenu')47 return loginModule.masterMenu()48@app.route('/logout')49def logout():50 logMessage('logout')51 return loginModule.logout()52@app.route('/login')53def login():54 logMessage('login')55 return loginModule.login()56@app.route('/loginRoute', methods=['POST'])57def loginRoute():58 logMessage('loginRoute')59 return loginModule.loginRoute()60 61@app.route('/createAccount')62def createAccount():63 logMessage('createAccount')64 return loginModule.createAccount()65@app.route('/createAccountRoute', methods=['POST'])66def createAccountRoute():67 logMessage('createAccountRoute')68 return loginModule.createAccountRoute()69 70@app.route('/authenticateCreateAccount', methods=['POST'])71def authenticateCreateAccount():72 logMessage('authenticateCreateAccount')73 return loginModule.authenticateCreateAccount()74@app.route('/changePassword')75def changePassword():76 logMessage('changePassword')77 return loginModule.changePassword()78@app.route('/changePasswordRoute', methods=['POST'])79def changePasswordRoute():80 logMessage('changePasswordRoute')81 return loginModule.changePasswordRoute()82@app.route('/authenticateChangePassword', methods=['POST'])83def authenticateChangePassword():84 logMessage('authenticateChangePassword')85 return loginModule.authenticateChangePassword()86#########################################################################87### ###88### Inventory ###89### ###90######################################################################### 91@app.route('/inventory')92def inventory():93 logMessage('inventory')94 return inventoryModule.inventory()95@app.route('/addInventoryRoute', methods=['POST'])96def addInventoryRoute():97 logMessage('addInventoryRoute')98 return inventoryModule.addInventoryRoute()99@app.route('/editInventoryRoute', methods=['POST'])100def editInventoryRoute():101 logMessage('editInventoryRoute')102 return inventoryModule.editInventoryRoute()103@app.route('/inventoryDelete', methods=['POST'])104def inventoryDelete():105 logMessage('inventoryDelete')106 return inventoryModule.inventoryDelete()107@app.route('/inventoryMessageClear', methods=['POST'])108def inventoryMessageClear():109 logMessage('inventoryMessageClear')110 return inventoryModule.inventoryMessageClear()111@app.route('/inventoryUpdate', methods=['POST'])112def inventoryUpdate():113 logMessage('inventoryUpdate')114 return inventoryModule.inventoryToggleCheckStatus()115@app.route('/inventoryEdit', methods=['POST'])116def inventoryEdit():117 logMessage('inventoryEdit')118 return inventoryModule.inventoryEdit()119#########################################################################120### ###121### Calendar ###122### ###123######################################################################### 124@app.route('/calendar')125def calendar():126 logMessage('calendar')127 return calendarModule.calendar() 128@app.route('/calendarUpdate', methods=['POST'])129def calendarUpdate():130 logMessage('calendarUpdate')131 return calendarModule.calendarUpdate()132@app.route('/calendarDelete', methods=['POST'])133def calendarDelete():134 logMessage('calendarDelete')135 return calendarModule.calendarDelete()136@app.route('/calendarInsert', methods=['POST'])137def calendarInsert():138 logMessage('calendarInsert')139 return calendarModule.calendarInsert()140#########################################################################141### ###142### Patron ###143### ###144######################################################################### 145@app.route('/patronSignUp')146def patronSignUp():147 logMessage('patronSignUp')148 return patronModule.patronSignUp()149@app.route('/patronSignUpRoute', methods=['POST'])150def patronSignUpRoute():151 logMessage('patronSignUpRoute')152 return patronModule.patronSignUpRoute()153@app.route('/patronCheckIn')154@app.route('/patron')155def patronCheckIn():156 logMessage('patronCheckIn')157 return patronModule.patronCheckIn()158@app.route('/patronCheckInRoute', methods=['POST'])159def patronCheckInRoute():160 logMessage('patronCheckInRoute')161 return patronModule.patronCheckInRoute()162@app.route('/patronCheckInRoute2', methods=['POST'])163def patronCheckInRoute2():164 logMessage('patronCheckInRoute2')165 return patronModule.patronCheckInRoute2()166@app.route('/patronConfirmation')167def patronConfirmation():168 logMessage('patronConfirmation')169 return patronModule.patronConfirmation()170@app.route('/signWaiver')171def signWaiver():172 logMessage('signWaiver')173 return patronModule.signWaiver()174@app.route('/patronSuspension')175def patronSuspension():176 logMessage('patronSuspension')177 return patronModule.patronSuspension()178@app.route('/signWaiverRoute', methods=['POST'])179def signWaiverRoute():180 logMessage('signWaiverRoute')181 return patronModule.signWaiverRoute()182@app.route('/createPatronAccountRoute', methods=['POST'])183def createPatronAccountRoute():184 logMessage('createPatronAccountRoute')185 return patronModule.createPatronAccountRoute()186@app.route('/storeImage', methods=['POST'])187def storeImage():188 logMessage('storeImage')189 return patronModule.storeImage()190#########################################################################191### ###192### Reporting ###193### ###194######################################################################### 195@app.route('/reporting')196def reporting():197 logMessage('reporting')198 return reportingModule.reporting()199@app.route('/reportingEmployee')200def reportingEmployee():201 logMessage('reportingEmployee')202 return reportingModule.reportingEmployee()203@app.route('/reportingAdmin')204def reportingAdmin():205 logMessage('reportingAdmin')206 return reportingModule.reportingAdmin()207@app.route('/reportingMaster')208def reportingMaster():209 logMessage('reportingMaster')210 return reportingModule.reportingMaster()211@app.route('/addIncidentRoute', methods=['POST'])212def addIncidentRoute():213 logMessage('addIncidentRoute')214 return reportingModule.addIncidentRoute()215@app.route('/toggleReportReviewStatus', methods=['POST'])216def toggleReportReviewStatus():217 logMessage('toggleReportReviewStatus')218 return reportingModule.toggleReportReviewStatus()219@app.route('/editPatronSuspensionRoute', methods=['POST'])220def editPatronSuspensionRoute():221 logMessage('editPatronSuspensionRoute')222 return reportingModule.editPatronSuspensionRoute()223#########################################################################224### ###225### Patron View ###226### ###227######################################################################### 228@app.route('/patrons')229def patron():230 logMessage('patrons')231 return patronViewModule.patrons()232@app.route('/patronViewEmployee')233def patronViewEmployee():234 logMessage('patronViewEmployee')235 return patronViewModule.patronViewEmployee()236@app.route('/patronViewAdmin')237def patronViewAdmin():238 logMessage('patronViewAdmin')239 return patronViewModule.patronViewAdmin()240@app.route('/patronViewMaster')241def patronViewMaster():242 logMessage('patronViewMaster')243 return patronViewModule.patronViewMaster()244@app.route('/editPatronRoute', methods=['POST'])245def editPatronRoute():246 logMessage('editPatronRoute')247 return patronViewModule.editPatronRoute()248@app.route('/editPatronCertificationRoute', methods=['POST'])249def editPatronCertificationRoute():250 logMessage('editPatronCertificationRoute')251 return patronViewModule.editPatronCertificationRoute()252@app.route('/patronDelete', methods=['POST'])253def patronDelete():254 logMessage('patronDelete')255 return patronViewModule.patronDelete()256@app.route('/patronDeleteAll', methods=['POST'])257def patronDeleteAll():258 logMessage('patronDeleteAll')259 return patronViewModule.patronDeleteAll()260#########################################################################261### ###262### User View ###263### ###264######################################################################### 265@app.route('/users')266def users():267 logMessage('users')268 return userViewModule.users()269@app.route('/userViewAdmin')270def userViewAdmin():271 logMessage('userViewAdmin')272 return userViewModule.userViewAdmin()273@app.route('/userViewMaster')274def userViewMaster():275 logMessage('userViewMaster')276 return userViewModule.userViewMaster()277@app.route('/editUserRoute', methods=['POST'])278def editUserRoute():279 logMessage('editUserRoute')280 return userViewModule.editUserRoute()281@app.route('/userDelete', methods=['POST'])282def userDelete():283 logMessage('userDelete')284 return userViewModule.userDelete()285#########################################################################286### ###287### Others ###288### ###289#########################################################################290def logMessage(log):291 currentTime = datetime.now(pytz.timezone('US/Central'))292 with open("debugLog.txt", "a") as logFile: 293 logFile.write(str(request.environ.get('HTTP_X_REAL_IP', request.remote_addr)) + ' - {:%Y-%m-%d %H:%M:%S}'.format(datetime.now(pytz.timezone('US/Central'))) + ': ' + str(log) + '\n')294if __name__ == '__main__':295 HOST = environ.get('SERVER_HOST', 'localhost')296 try:297 PORT = int(environ.get('SERVER_PORT', '5555'))298 except ValueError:299 PORT = 5555300 app.run(HOST, PORT, debug=True)301 302if __name__ == "__main__":...
ExceptionParser.js
Source:ExceptionParser.js
1import unserialize from './unserialize';2import style from "./Components/TraceLine.css";3import {formatArgument} from "./Components/TraceLine";4window.unserialize = unserialize;5export class ExceptionParser {6 isException (logMessage) {7 return this.isNewStyleException(logMessage) || this.isOldStyleException(logMessage) || this.isBackgroundJobException(logMessage);8 }9 isNewStyleException (logMessage) {10 return logMessage.Exception;11 }12 isOldStyleException (logMessage) {13 return logMessage.substr && logMessage.substr(0, 12) === 'Exception: {';14 }15 isBackgroundJobException (logMessage) {16 return logMessage.substr && logMessage.substr(0, 34) === 'Error while running background job' && logMessage.indexOf('{"Exception":') !== -1;17 }18 parse (logMessage) {19 if (this.isNewStyleException(logMessage)) {20 return logMessage;21 }22 let data;23 if (this.isOldStyleException(logMessage)) {24 try {25 data = this.tryParseJSON(logMessage.substr(10));26 } catch (e) {27 console.log('Error while parsing exception:');28 console.log(logMessage.substr(10));29 console.error(e);30 }31 } else {32 data = this.tryParseJSON(logMessage.substr(logMessage.indexOf('{"Exception":')));33 const messageHead = logMessage.substr(0, logMessage.indexOf('{"Exception":'));34 const jobDataString = messageHead.split('(', 2)[1];35 const jobDataParts = jobDataString.split(',', 2).map(part => part.trim());36 data.jobClass = jobDataParts[0].split(':', 2)[1].trim();37 data.jobArguments = jobDataParts[1].substr(10).trim();38 window.s = jobDataParts[1].substr(10).trim();39 if (data.jobClass === 'OC\\Command\\CommandJob') {40 try {41 [data.jobClass, data.jobArguments] = this.parseCommandJob(data.jobArguments);42 } catch (e) {43 }44 }45 }46 let traceLines = data.Trace.split('\n');47 data.Trace = traceLines.map(this.parseTraceLine);48 return data;49 }50 tryParseJSON (json) {51 try {52 return JSON.parse(json);53 } catch (e) {54 // fix unescaped newlines55 json = json.replace(/\n/g, '\\n');56 // fix unescaped namespace delimiters57 json = json.replace(/([^\\])\\([A-Z{])/g, '$1\\\\$2');58 try {59 return JSON.parse(json);60 } catch (e) {61 console.log('Error while parsing exception:');62 console.log(json);63 console.error(e);64 }65 }66 }67 parseCommandJob (data) {68 const parsed = unserialize(data);69 return [parsed['class'], parsed.properties];70 }71 parseTraceLine (line) {72 let parts = line.split(' ');73 let number = parts.shift();74 let traceData = parts.join(' ');75 parts = traceData.split(':');76 if (parts.length > 1) {77 let file, lineNumber;78 let fileAndLine = parts.shift();79 let call = parts.join(' ');80 if (fileAndLine[0] === '[') {81 lineNumber = false;82 file = fileAndLine;83 } else {84 let filePaths = fileAndLine.split('(', 2);85 file = filePaths[0];86 lineNumber = filePaths[1].substr(0, filePaths[1].length - 1);87 }88 return {89 'function': call,90 number: number,91 file: file,92 line: lineNumber93 };94 } else {95 return {96 'function': traceData,97 number: number,98 file: false,99 line: false100 };101 }102 }103 format (logMessage) {104 if (!this.isException(logMessage)) {105 return logMessage;106 }107 const parsed = this.parse(logMessage);108 const fileAndLine = (item) => {109 if (item.file && item.line) {110 return `${item.file} line ${item.line}`111 } else {112 return '<<closure>>';113 }114 };115 if (parsed.Exception) {116 const widestIndex = ('' + (parsed.Trace.length - 1)).length;117 let message = `${parsed.Exception}: ${parsed.Message} at ${fileAndLine(parsed)}\n\n`;118 message += parsed.Trace.map(119 (trace, i) => {120 const args = trace.args.map(arg => {121 const baseFormatted = formatArgument(arg, 0).replace(/\n/g, '');;122 const showInline = baseFormatted.length < 42;123 return showInline ? baseFormatted : `${baseFormatted.substr(0, 16)} ... ${baseFormatted.substr(baseFormatted.length - 2, 2)}`;124 });125 return `${' '.repeat(widestIndex - ('' + i).length)}${i}. ${fileAndLine(trace)}\n` +126 `${' '.repeat(widestIndex + 2)}${trace.class || ''}${trace.type || ''}${trace.function}(${args.join(', ')})`;127 }128 ).join('\n');129 return message;130 } else {131 return parsed;132 }133 }...
Log.js
Source:Log.js
1Log = {23 v: function v(logMessage)4 {5 if ($.type(logMessage) == "string" && arguments.callee.caller && arguments.callee.caller.name)6 {7 logMessage = arguments.callee.caller.name + ": " + logMessage;8 }910 Log.prettyConsoleLog("v", logMessage);11 },1213 d: function d(logMessage)14 {15 if ($.type(logMessage) == "string" && arguments.callee.caller && arguments.callee.caller.name)16 {17 logMessage = arguments.callee.caller.name + ": " + logMessage;18 }1920 Log.prettyConsoleLog("d", logMessage);21 },2223 i: function i(logMessage)24 {25 if ($.type(logMessage) == "string" && arguments.callee.caller && arguments.callee.caller.name)26 {27 logMessage = arguments.callee.caller.name + ": " + logMessage;28 }2930 Log.prettyConsoleLog("i", logMessage);31 },3233 w: function w(logMessage)34 {35 if ($.type(logMessage) == "string" && arguments.callee.caller && arguments.callee.caller.name)36 {37 logMessage = arguments.callee.caller.name + ": " + logMessage;38 }3940 Log.prettyConsoleLog("w", logMessage);41 },4243 e: function e(logMessage)44 {45 if ($.type(logMessage) == "string" && arguments.callee.caller && arguments.callee.caller.name)46 {47 logMessage = arguments.callee.caller.name + ": " + logMessage;48 }4950 Log.prettyConsoleLog("e", logMessage);51 },5253 exception: function exception(e)54 {55 var errorString = e.stack.toString();56 Log.prettyConsoleLog("e", errorString);57 },5859 getInlineFunctionTrace: function getInlineFunctionTrace(inputArguments, inputCallee)60 {61 var inlineTraceString = '';6263 if (inputArguments.callee)64 {65 inlineTraceString += inputArguments.callee.name;66 }6768 try69 {70 if (inputCallee.caller && inputCallee.caller.name.length)71 {72 inlineTraceString += " called by " + inputCallee.caller.name;73 }74 }75 catch (e)76 {77 }7879 if (inputArguments.length)80 {81 inlineTraceString += " with arguments: " + [].slice.apply(inputArguments).toString();82 }8384 return inlineTraceString;85 },8687 prettyConsoleLog: function prettyConsoleLog(logLevel, logMessage)88 {89 var objectToLog = false;90 if ($.type(logMessage) != "string")91 {92 objectToLog = logMessage;93 logMessage = "Object dump below:";94 }9596 if (logLevel == "v")97 {98 console.log("%c" + logMessage, "color: #999999");99 }100 else if (logLevel == "d")101 {102 console.log(logMessage);103 }104 else if (logLevel == "i")105 {106 console.log("%c" + logMessage, "color: #008800");107 }108 else if (logLevel == "w")109 {110 console.warn(logMessage);111 }112 else if (logLevel == "e")113 {114 console.error(logMessage);115 }116 else117 {118 console.log(logMessage);119 }120121 if (objectToLog !== false)122 {123 console.log(objectToLog);124 }125 }126
...
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!!