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": [ "source": [
"import os\n", "import os\n",
"\n", "\n",
"def startEmulator():\n", "class Emulator:\n",
" \n",
" @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", " os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n",
"\n", "\n",
"def stopEmulator():\n", " @staticmethod\n",
" ! adb emu kill" " def _stopEmulator():\n",
] " ! adb emu kill\n"
},
{
"cell_type": "code",
"execution_count": null,
"id": "fb3755a6",
"metadata": {},
"outputs": [],
"source": [
"startEmulator()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "c113e49d", "id": "c113e49d",
"metadata": {}, "metadata": {
"outputs": [], "scrolled": false
"source": [
"textInImage = detectTextInImage(captchaImageFile)"
]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "cdf3fbe1",
"metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"stopEmulator()" "textInImage = Emulator.runWithinEmulator(lambda: detectTextInImage(captchaImageFile))"
] ]
}, },
{ {