refactoring

This commit is contained in:
frankknoll
2022-05-12 19:44:06 +02:00
parent 9926901f78
commit 326ead47ca

View File

@@ -138,41 +138,34 @@
"source": [
"import os\n",
"\n",
"def startEmulator():\n",
" os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n",
"class Emulator:\n",
" \n",
"def stopEmulator():\n",
" ! adb emu kill"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fb3755a6",
"metadata": {},
"outputs": [],
"source": [
"startEmulator()"
" @staticmethod\n",
" def runWithinEmulator(runnable):\n",
" Emulator._startEmulator()\n",
" result = runnable()\n",
" Emulator._stopEmulator()\n",
" return result\n",
" \n",
" @staticmethod\n",
" def _startEmulator():\n",
" os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n",
"\n",
" @staticmethod\n",
" def _stopEmulator():\n",
" ! adb emu kill\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c113e49d",
"metadata": {},
"outputs": [],
"source": [
"textInImage = detectTextInImage(captchaImageFile)"
]
"metadata": {
"scrolled": false
},
{
"cell_type": "code",
"execution_count": null,
"id": "cdf3fbe1",
"metadata": {},
"outputs": [],
"source": [
"stopEmulator()"
"textInImage = Emulator.runWithinEmulator(lambda: detectTextInImage(captchaImageFile))"
]
},
{