{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "500d13a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import logging\n",
    "logger = logging.getLogger(\"\")\n",
    "logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "135bf316",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "DEBUG:starting\n"
     ]
    }
   ],
   "source": [
    "logger.debug(\"starting\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "7aeecef2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "from PIL import Image, ImageDraw, ImageFont\n",
    "\n",
    "def create_image_with_random_string():\n",
    "    # Define the image size\n",
    "    width, height = 64, 64\n",
    "\n",
    "    # Create a blank image with a white background\n",
    "    image = Image.new(\"RGB\", (width, height), \"lightgray\")\n",
    "    draw = ImageDraw.Draw(image)\n",
    "\n",
    "    # Choose a random alphabetic string with no vowels\n",
    "    random_string = ''.join(random.choice('bcdfghjklmnpqrstvwxz') for _ in range(3))\n",
    "\n",
    "    # Define the font properties\n",
    "    font_size = 48\n",
    "    font = ImageFont.truetype(\"DejaVuSans.ttf\", font_size)\n",
    "\n",
    "    # Calculate the text position\n",
    "    text_width, text_height = draw.textsize(random_string, font=font)\n",
    "    x = (width - text_width) // 2\n",
    "    y = (height - text_height) // 2\n",
    "\n",
    "    # Draw the text on the image\n",
    "    draw.text((x, y), random_string, font=font, fill=\"darkred\")\n",
    "\n",
    "    return image\n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "527dc50c",
   "metadata": {},
   "outputs": [],
   "source": [
    " # Save the image as a PNG file\n",
    "image = create_image_with_random_string()\n",
    "image.save(\"random_string.png\", \"PNG\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "14f16727",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'dls_bxflow_run'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32mc:\\22\\dls-bxflow\\tests\\jupyter\\jupyter2.ipynb Cell 5\u001b[0m in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      <a href='vscode-notebook-cell:/c%3A/22/dls-bxflow/tests/jupyter/jupyter2.ipynb#W2sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39m# Import the class which takes care of storing execution summary information.\u001b[39;00m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/22/dls-bxflow/tests/jupyter/jupyter2.ipynb#W2sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mdls_bxflow_run\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbx_tasks\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mexecution_summary\u001b[39;00m \u001b[39mimport\u001b[39;00m ExecutionSummary\n\u001b[0;32m      <a href='vscode-notebook-cell:/c%3A/22/dls-bxflow/tests/jupyter/jupyter2.ipynb#W2sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39m# Write some execution summary raw text.\u001b[39;00m\n\u001b[0;32m      <a href='vscode-notebook-cell:/c%3A/22/dls-bxflow/tests/jupyter/jupyter2.ipynb#W2sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m ExecutionSummary\u001b[39m.\u001b[39mappend_raw(\u001b[39m\"\u001b[39m\u001b[39mrandom_string.png\u001b[39m\u001b[39m\"\u001b[39m)\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'dls_bxflow_run'"
     ]
    }
   ],
   "source": [
    "# Import the class which takes care of storing execution summary information.\n",
    "from dls_bxflow_run.bx_tasks.execution_summary import ExecutionSummary\n",
    "\n",
    "# Write some execution summary raw text.\n",
    "ExecutionSummary().append_raw(\"random_string.png\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7bee2268",
   "metadata": {},
   "outputs": [],
   "source": [
    "logger.debug(\"finished\")"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b0da30b48cde19f294958e6b6ece8d1adf792283a6fcdd72a9ecfffe90973a93"
  },
  "kernelspec": {
   "display_name": "Python 3.10.4 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
