prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add ability to pass in dut_serial via command line config
  Add ability to pass in dut_serial via command line.  This would be a useful feature when doing loop test
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `openhtf/exe/triggers.py`
  Content:
  ```
  1 # Copyright 2014 Google Inc. All Rights Reserved.
  2 
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Module for handling the triggering of test start/stop.
  16 
  17 In order for the TestExecutor (see exe/__init__.py) to know when to start a
  18 test, it needs a way to know when a DUT has been connected.  Also, the test
  19 can't restart until the DUT is removed and re-appears.  The serial for the
  20 TestRun can be read from the DUT, or from the frontend.
  21 
  22 This module provides some built-in triggers. Custom implementations of test
  23 start and stop triggers must follow the following interface:
  24 
  25 TestStart:
  26   Args:
  27     None
  28   Returns:
  29     DUT identifier, or None if it is not known at test start time.
  30 
  31 TestStop:
  32   Args:
  33     dut_id: DUT identifier of the test that is stopping.
  34   Returns:
  35     Blocks until the test can re-start, then returns None.
  36 """
  37 
  38 import logging
  39 import time
  40 
  41 from openhtf.io import user_input
  42 
  43 _LOG = logging.getLogger(__name__)
  44 
  45 
  46 def AutoStart():  # pylint: disable=invalid-name
  47   """Start the test immediately with a dummy DUT ID."""
  48   return 'UNKNOWN_DUT_ID'
  49 
  50 
  51 def AutoStop(dummy_dut_id):  # pylint: disable=invalid-name
  52   """Stop the test immediately regardless of DUT ID given."""
  53   pass
  54 
  55 
  56 # pylint: disable=invalid-name
  57 def PromptForTestStart(message='Provide a DUT ID in order to start the test.',
  58                        text_input=True):
  59   """Make a test start trigger based on prompting the user for input."""
  60   def trigger():  # pylint: disable=missing-docstring
  61     prompt_manager = user_input.get_prompt_manager()
  62     return prompt_manager.DisplayPrompt(message, text_input=text_input)
  63   return trigger
  64 
  65 
  66 def PromptForTestStop(message='Hit ENTER to complete the test.',
  67                       text_input=False):
  68   """Make a test stop trigger based on prompting the user for a response."""
  69   def trigger(dummy_dut_id):  # pylint: disable=missing-docstring
  70     prompt_manager = user_input.get_prompt_manager()
  71     return prompt_manager.DisplayPrompt(message, text_input=text_input)
  72   return trigger
  73
  ```
  --- 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/openhtf/exe/triggers.py b/openhtf/exe/triggers.py
  --- a/openhtf/exe/triggers.py
  +++ b/openhtf/exe/triggers.py
  @@ -38,14 +38,20 @@
   import logging
   import time
   
  +import gflags
  +
   from openhtf.io import user_input
   
  -_LOG = logging.getLogger(__name__)
  +gflags.DEFINE_string('dut_serial', 'UNKNOWN_DUT_ID',
  +                     'DUT serial to start the test with. '
  +                     'Only use if using the AutoStart trigger.')
   
  +FLAGS = gflags.FLAGS
  +_LOG = logging.getLogger(__name__)
   
   def AutoStart():  # pylint: disable=invalid-name
     """Start the test immediately with a dummy DUT ID."""
  -  return 'UNKNOWN_DUT_ID'
  +  return FLAGS.dut_serial
   
   
   def AutoStop(dummy_dut_id):  # pylint: disable=invalid-name
  
verification_info: {"golden_diff": "diff --git a/openhtf/exe/triggers.py b/openhtf/exe/triggers.py\n--- a/openhtf/exe/triggers.py\n+++ b/openhtf/exe/triggers.py\n@@ -38,14 +38,20 @@\n import logging\n import time\n \n+import gflags\n+\n from openhtf.io import user_input\n \n-_LOG = logging.getLogger(__name__)\n+gflags.DEFINE_string('dut_serial', 'UNKNOWN_DUT_ID',\n+                     'DUT serial to start the test with. '\n+                     'Only use if using the AutoStart trigger.')\n \n+FLAGS = gflags.FLAGS\n+_LOG = logging.getLogger(__name__)\n \n def AutoStart():  # pylint: disable=invalid-name\n   \"\"\"Start the test immediately with a dummy DUT ID.\"\"\"\n-  return 'UNKNOWN_DUT_ID'\n+  return FLAGS.dut_serial\n \n \n def AutoStop(dummy_dut_id):  # pylint: disable=invalid-name\n", "issue": "Add ability to pass in dut_serial via command line config\nAdd ability to pass in dut_serial via command line.  This would be a useful feature when doing loop test\n\n", "before_files": [{"content": "# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Module for handling the triggering of test start/stop.\n\nIn order for the TestExecutor (see exe/__init__.py) to know when to start a\ntest, it needs a way to know when a DUT has been connected.  Also, the test\ncan't restart until the DUT is removed and re-appears.  The serial for the\nTestRun can be read from the DUT, or from the frontend.\n\nThis module provides some built-in triggers. Custom implementations of test\nstart and stop triggers must follow the following interface:\n\nTestStart:\n  Args:\n    None\n  Returns:\n    DUT identifier, or None if it is not known at test start time.\n\nTestStop:\n  Args:\n    dut_id: DUT identifier of the test that is stopping.\n  Returns:\n    Blocks until the test can re-start, then returns None.\n\"\"\"\n\nimport logging\nimport time\n\nfrom openhtf.io import user_input\n\n_LOG = logging.getLogger(__name__)\n\n\ndef AutoStart():  # pylint: disable=invalid-name\n  \"\"\"Start the test immediately with a dummy DUT ID.\"\"\"\n  return 'UNKNOWN_DUT_ID'\n\n\ndef AutoStop(dummy_dut_id):  # pylint: disable=invalid-name\n  \"\"\"Stop the test immediately regardless of DUT ID given.\"\"\"\n  pass\n\n\n# pylint: disable=invalid-name\ndef PromptForTestStart(message='Provide a DUT ID in order to start the test.',\n                       text_input=True):\n  \"\"\"Make a test start trigger based on prompting the user for input.\"\"\"\n  def trigger():  # pylint: disable=missing-docstring\n    prompt_manager = user_input.get_prompt_manager()\n    return prompt_manager.DisplayPrompt(message, text_input=text_input)\n  return trigger\n\n\ndef PromptForTestStop(message='Hit ENTER to complete the test.',\n                      text_input=False):\n  \"\"\"Make a test stop trigger based on prompting the user for a response.\"\"\"\n  def trigger(dummy_dut_id):  # pylint: disable=missing-docstring\n    prompt_manager = user_input.get_prompt_manager()\n    return prompt_manager.DisplayPrompt(message, text_input=text_input)\n  return trigger\n", "path": "openhtf/exe/triggers.py"}], "after_files": [{"content": "# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n#     http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Module for handling the triggering of test start/stop.\n\nIn order for the TestExecutor (see exe/__init__.py) to know when to start a\ntest, it needs a way to know when a DUT has been connected.  Also, the test\ncan't restart until the DUT is removed and re-appears.  The serial for the\nTestRun can be read from the DUT, or from the frontend.\n\nThis module provides some built-in triggers. Custom implementations of test\nstart and stop triggers must follow the following interface:\n\nTestStart:\n  Args:\n    None\n  Returns:\n    DUT identifier, or None if it is not known at test start time.\n\nTestStop:\n  Args:\n    dut_id: DUT identifier of the test that is stopping.\n  Returns:\n    Blocks until the test can re-start, then returns None.\n\"\"\"\n\nimport logging\nimport time\n\nimport gflags\n\nfrom openhtf.io import user_input\n\ngflags.DEFINE_string('dut_serial', 'UNKNOWN_DUT_ID',\n                     'DUT serial to start the test with. '\n                     'Only use if using the AutoStart trigger.')\n\nFLAGS = gflags.FLAGS\n_LOG = logging.getLogger(__name__)\n\ndef AutoStart():  # pylint: disable=invalid-name\n  \"\"\"Start the test immediately with a dummy DUT ID.\"\"\"\n  return FLAGS.dut_serial\n\n\ndef AutoStop(dummy_dut_id):  # pylint: disable=invalid-name\n  \"\"\"Stop the test immediately regardless of DUT ID given.\"\"\"\n  pass\n\n\n# pylint: disable=invalid-name\ndef PromptForTestStart(message='Provide a DUT ID in order to start the test.',\n                       text_input=True):\n  \"\"\"Make a test start trigger based on prompting the user for input.\"\"\"\n  def trigger():  # pylint: disable=missing-docstring\n    prompt_manager = user_input.get_prompt_manager()\n    return prompt_manager.DisplayPrompt(message, text_input=text_input)\n  return trigger\n\n\ndef PromptForTestStop(message='Hit ENTER to complete the test.',\n                      text_input=False):\n  \"\"\"Make a test stop trigger based on prompting the user for a response.\"\"\"\n  def trigger(dummy_dut_id):  # pylint: disable=missing-docstring\n    prompt_manager = user_input.get_prompt_manager()\n    return prompt_manager.DisplayPrompt(message, text_input=text_input)\n  return trigger\n", "path": "openhtf/exe/triggers.py"}]}