prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  external_script modifies numeric output
  The external_script module converts numeric values to a numeric type. This removes the original formatting of the input and is undesired.
  
  To reproduce create an external script and simply echo "0.123000", the output in the bar will be "0.123".
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `py3status/modules/external_script.py`
  Content:
  ```
  1 """
  2 Display output of a given script.
  3 
  4 Display output of any executable script set by `script_path`. Only the first
  5 two lines of output will be used. The first line is used as the displayed
  6 text. If the output has two or more lines, the second line is set as the text
  7 color (and should hence be a valid hex color code such as #FF0000 for red).
  8 The script should not have any parameters, but it could work.
  9 
  10 Configuration parameters:
  11     button_show_notification: button to show notification with full output
  12         (default None)
  13     cache_timeout: how often we refresh this module in seconds
  14         (default 15)
  15     format: see placeholders below (default '{output}')
  16     localize: should script output be localized (if available)
  17         (default True)
  18     script_path: script you want to show output of (compulsory)
  19         (default None)
  20     strip_output: shall we strip leading and trailing spaces from output
  21         (default False)
  22 
  23 Format placeholders:
  24     {lines} number of lines in the output
  25     {output} output of script given by "script_path"
  26 
  27 Examples:
  28 ```
  29 external_script {
  30     format = "my name is {output}"
  31     script_path = "/usr/bin/whoami"
  32 }
  33 ```
  34 
  35 @author frimdo ztracenastopa@centrum.cz
  36 
  37 SAMPLE OUTPUT
  38 {'full_text': 'script output'}
  39 
  40 example
  41 {'full_text': 'It is now: Wed Feb 22 22:24:13'}
  42 """
  43 
  44 import re
  45 
  46 STRING_ERROR = "missing script_path"
  47 
  48 
  49 class Py3status:
  50     """
  51     """
  52 
  53     # available configuration parameters
  54     button_show_notification = None
  55     cache_timeout = 15
  56     format = "{output}"
  57     localize = True
  58     script_path = None
  59     strip_output = False
  60 
  61     def post_config_hook(self):
  62         if not self.script_path:
  63             raise Exception(STRING_ERROR)
  64 
  65     def external_script(self):
  66         output_lines = None
  67         response = {}
  68         response["cached_until"] = self.py3.time_in(self.cache_timeout)
  69         try:
  70             self.output = self.py3.command_output(
  71                 self.script_path, shell=True, localized=self.localize
  72             )
  73             output_lines = self.output.splitlines()
  74             if len(output_lines) > 1:
  75                 output_color = output_lines[1]
  76                 if re.search(r"^#[0-9a-fA-F]{6}$", output_color):
  77                     response["color"] = output_color
  78         except self.py3.CommandError as e:
  79             # something went wrong show error to user
  80             output = e.output or e.error
  81             self.py3.error(output)
  82 
  83         if output_lines:
  84             output = output_lines[0]
  85             if self.strip_output:
  86                 output = output.strip()
  87             # If we get something that looks numeric then we convert it
  88             # to a numeric type because this can be helpful. for example:
  89             #
  90             # external_script {
  91             #     format = "file is [\?if=output>10 big|small]"
  92             #     script_path = "cat /tmp/my_file | wc -l"
  93             # }
  94             try:
  95                 output = int(output)
  96             except ValueError:
  97                 try:
  98                     output = float(output)
  99                 except ValueError:
  100                     pass
  101         else:
  102             output = ""
  103 
  104         response["full_text"] = self.py3.safe_format(
  105             self.format, {"output": output, "lines": len(output_lines)}
  106         )
  107         return response
  108 
  109     def on_click(self, event):
  110         button = event["button"]
  111         if button == self.button_show_notification:
  112             self.py3.notify_user(self.output)
  113             self.py3.prevent_refresh()
  114 
  115 
  116 if __name__ == "__main__":
  117     """
  118     Run module in test mode.
  119     """
  120     from py3status.module_test import module_test
  121 
  122     module_test(Py3status)
  123
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/py3status/modules/external_script.py b/py3status/modules/external_script.py
  --- a/py3status/modules/external_script.py
  +++ b/py3status/modules/external_script.py
  @@ -12,6 +12,8 @@
           (default None)
       cache_timeout: how often we refresh this module in seconds
           (default 15)
  +    convert_numbers: convert decimal numbers to a numeric type
  +        (default True)
       format: see placeholders below (default '{output}')
       localize: should script output be localized (if available)
           (default True)
  @@ -53,6 +55,7 @@
       # available configuration parameters
       button_show_notification = None
       cache_timeout = 15
  +    convert_numbers = True
       format = "{output}"
       localize = True
       script_path = None
  @@ -91,13 +94,14 @@
               #     format = "file is [\?if=output>10 big|small]"
               #     script_path = "cat /tmp/my_file | wc -l"
               # }
  -            try:
  -                output = int(output)
  -            except ValueError:
  +            if self.convert_numbers is True:
                   try:
  -                    output = float(output)
  +                    output = int(output)
                   except ValueError:
  -                    pass
  +                    try:
  +                        output = float(output)
  +                    except ValueError:
  +                        pass
           else:
               output = ""
  
verification_info: {"golden_diff": "diff --git a/py3status/modules/external_script.py b/py3status/modules/external_script.py\n--- a/py3status/modules/external_script.py\n+++ b/py3status/modules/external_script.py\n@@ -12,6 +12,8 @@\n         (default None)\n     cache_timeout: how often we refresh this module in seconds\n         (default 15)\n+    convert_numbers: convert decimal numbers to a numeric type\n+        (default True)\n     format: see placeholders below (default '{output}')\n     localize: should script output be localized (if available)\n         (default True)\n@@ -53,6 +55,7 @@\n     # available configuration parameters\n     button_show_notification = None\n     cache_timeout = 15\n+    convert_numbers = True\n     format = \"{output}\"\n     localize = True\n     script_path = None\n@@ -91,13 +94,14 @@\n             #     format = \"file is [\\?if=output>10 big|small]\"\n             #     script_path = \"cat /tmp/my_file | wc -l\"\n             # }\n-            try:\n-                output = int(output)\n-            except ValueError:\n+            if self.convert_numbers is True:\n                 try:\n-                    output = float(output)\n+                    output = int(output)\n                 except ValueError:\n-                    pass\n+                    try:\n+                        output = float(output)\n+                    except ValueError:\n+                        pass\n         else:\n             output = \"\"\n", "issue": "external_script modifies numeric output\nThe external_script module converts numeric values to a numeric type. This removes the original formatting of the input and is undesired.\r\n\r\nTo reproduce create an external script and simply echo \"0.123000\", the output in the bar will be \"0.123\".\n", "before_files": [{"content": "\"\"\"\nDisplay output of a given script.\n\nDisplay output of any executable script set by `script_path`. Only the first\ntwo lines of output will be used. The first line is used as the displayed\ntext. If the output has two or more lines, the second line is set as the text\ncolor (and should hence be a valid hex color code such as #FF0000 for red).\nThe script should not have any parameters, but it could work.\n\nConfiguration parameters:\n    button_show_notification: button to show notification with full output\n        (default None)\n    cache_timeout: how often we refresh this module in seconds\n        (default 15)\n    format: see placeholders below (default '{output}')\n    localize: should script output be localized (if available)\n        (default True)\n    script_path: script you want to show output of (compulsory)\n        (default None)\n    strip_output: shall we strip leading and trailing spaces from output\n        (default False)\n\nFormat placeholders:\n    {lines} number of lines in the output\n    {output} output of script given by \"script_path\"\n\nExamples:\n```\nexternal_script {\n    format = \"my name is {output}\"\n    script_path = \"/usr/bin/whoami\"\n}\n```\n\n@author frimdo ztracenastopa@centrum.cz\n\nSAMPLE OUTPUT\n{'full_text': 'script output'}\n\nexample\n{'full_text': 'It is now: Wed Feb 22 22:24:13'}\n\"\"\"\n\nimport re\n\nSTRING_ERROR = \"missing script_path\"\n\n\nclass Py3status:\n    \"\"\"\n    \"\"\"\n\n    # available configuration parameters\n    button_show_notification = None\n    cache_timeout = 15\n    format = \"{output}\"\n    localize = True\n    script_path = None\n    strip_output = False\n\n    def post_config_hook(self):\n        if not self.script_path:\n            raise Exception(STRING_ERROR)\n\n    def external_script(self):\n        output_lines = None\n        response = {}\n        response[\"cached_until\"] = self.py3.time_in(self.cache_timeout)\n        try:\n            self.output = self.py3.command_output(\n                self.script_path, shell=True, localized=self.localize\n            )\n            output_lines = self.output.splitlines()\n            if len(output_lines) > 1:\n                output_color = output_lines[1]\n                if re.search(r\"^#[0-9a-fA-F]{6}$\", output_color):\n                    response[\"color\"] = output_color\n        except self.py3.CommandError as e:\n            # something went wrong show error to user\n            output = e.output or e.error\n            self.py3.error(output)\n\n        if output_lines:\n            output = output_lines[0]\n            if self.strip_output:\n                output = output.strip()\n            # If we get something that looks numeric then we convert it\n            # to a numeric type because this can be helpful. for example:\n            #\n            # external_script {\n            #     format = \"file is [\\?if=output>10 big|small]\"\n            #     script_path = \"cat /tmp/my_file | wc -l\"\n            # }\n            try:\n                output = int(output)\n            except ValueError:\n                try:\n                    output = float(output)\n                except ValueError:\n                    pass\n        else:\n            output = \"\"\n\n        response[\"full_text\"] = self.py3.safe_format(\n            self.format, {\"output\": output, \"lines\": len(output_lines)}\n        )\n        return response\n\n    def on_click(self, event):\n        button = event[\"button\"]\n        if button == self.button_show_notification:\n            self.py3.notify_user(self.output)\n            self.py3.prevent_refresh()\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    Run module in test mode.\n    \"\"\"\n    from py3status.module_test import module_test\n\n    module_test(Py3status)\n", "path": "py3status/modules/external_script.py"}], "after_files": [{"content": "\"\"\"\nDisplay output of a given script.\n\nDisplay output of any executable script set by `script_path`. Only the first\ntwo lines of output will be used. The first line is used as the displayed\ntext. If the output has two or more lines, the second line is set as the text\ncolor (and should hence be a valid hex color code such as #FF0000 for red).\nThe script should not have any parameters, but it could work.\n\nConfiguration parameters:\n    button_show_notification: button to show notification with full output\n        (default None)\n    cache_timeout: how often we refresh this module in seconds\n        (default 15)\n    convert_numbers: convert decimal numbers to a numeric type\n        (default True)\n    format: see placeholders below (default '{output}')\n    localize: should script output be localized (if available)\n        (default True)\n    script_path: script you want to show output of (compulsory)\n        (default None)\n    strip_output: shall we strip leading and trailing spaces from output\n        (default False)\n\nFormat placeholders:\n    {lines} number of lines in the output\n    {output} output of script given by \"script_path\"\n\nExamples:\n```\nexternal_script {\n    format = \"my name is {output}\"\n    script_path = \"/usr/bin/whoami\"\n}\n```\n\n@author frimdo ztracenastopa@centrum.cz\n\nSAMPLE OUTPUT\n{'full_text': 'script output'}\n\nexample\n{'full_text': 'It is now: Wed Feb 22 22:24:13'}\n\"\"\"\n\nimport re\n\nSTRING_ERROR = \"missing script_path\"\n\n\nclass Py3status:\n    \"\"\"\n    \"\"\"\n\n    # available configuration parameters\n    button_show_notification = None\n    cache_timeout = 15\n    convert_numbers = True\n    format = \"{output}\"\n    localize = True\n    script_path = None\n    strip_output = False\n\n    def post_config_hook(self):\n        if not self.script_path:\n            raise Exception(STRING_ERROR)\n\n    def external_script(self):\n        output_lines = None\n        response = {}\n        response[\"cached_until\"] = self.py3.time_in(self.cache_timeout)\n        try:\n            self.output = self.py3.command_output(\n                self.script_path, shell=True, localized=self.localize\n            )\n            output_lines = self.output.splitlines()\n            if len(output_lines) > 1:\n                output_color = output_lines[1]\n                if re.search(r\"^#[0-9a-fA-F]{6}$\", output_color):\n                    response[\"color\"] = output_color\n        except self.py3.CommandError as e:\n            # something went wrong show error to user\n            output = e.output or e.error\n            self.py3.error(output)\n\n        if output_lines:\n            output = output_lines[0]\n            if self.strip_output:\n                output = output.strip()\n            # If we get something that looks numeric then we convert it\n            # to a numeric type because this can be helpful. for example:\n            #\n            # external_script {\n            #     format = \"file is [\\?if=output>10 big|small]\"\n            #     script_path = \"cat /tmp/my_file | wc -l\"\n            # }\n            if self.convert_numbers is True:\n                try:\n                    output = int(output)\n                except ValueError:\n                    try:\n                        output = float(output)\n                    except ValueError:\n                        pass\n        else:\n            output = \"\"\n\n        response[\"full_text\"] = self.py3.safe_format(\n            self.format, {\"output\": output, \"lines\": len(output_lines)}\n        )\n        return response\n\n    def on_click(self, event):\n        button = event[\"button\"]\n        if button == self.button_show_notification:\n            self.py3.notify_user(self.output)\n            self.py3.prevent_refresh()\n\n\nif __name__ == \"__main__\":\n    \"\"\"\n    Run module in test mode.\n    \"\"\"\n    from py3status.module_test import module_test\n\n    module_test(Py3status)\n", "path": "py3status/modules/external_script.py"}]}