prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  hostname parser doesn't handle sos_commands/general/hostname
  sos_commands/general/hostname contains the hostname with a newline at the end, which results in a file with two lines. The hostname parser specifically checks for one line but doesn't gracefully handle the problem.
  
  We can update the parser to handle this case and/or investigate whether proc/sys/kernel/hostname is a valid substitute to put in sos_archive.py instead.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `insights/parsers/hostname.py`
  Content:
  ```
  1 """
  2 hostname - command ``/bin/hostname``
  3 ====================================
  4 
  5 This parser simply reads the output of ``/bin/hostname``, which is the
  6 configured fully qualified domain name of the client system.  It then
  7 splits it into ``hostname`` and ``domain`` and stores these as attributes,
  8 along with the unmodified name in the ``fqdn`` attribute.
  9 
  10 Examples:
  11 
  12     >>> hostname = shared[Hostname]
  13     >>> hostname.fqdn
  14     'www.example.com'
  15     >>> hostname.hostname
  16     'www'
  17     >>> hostname.domain
  18     'example.com'
  19 
  20 """
  21 
  22 from .. import Parser, parser
  23 from insights.specs import Specs
  24 
  25 
  26 @parser(Specs.hostname)
  27 class Hostname(Parser):
  28     """Class for parsing ``hostname`` command output.
  29 
  30     Attributes:
  31         fqdn: The fully qualified domain name of the host. The same to
  32             ``hostname`` when domain part is not set.
  33         hostname: The hostname.
  34         domain: The domain get from the fqdn.
  35     """
  36     def parse_content(self, content):
  37         raw = None
  38         if len(content) == 1:
  39             raw = content[0].strip()
  40         self.fqdn = raw
  41         self.hostname = raw.split(".")[0] if raw else None
  42         self.domain = ".".join(raw.split(".")[1:]) if raw else None
  43 
  44     def __str__(self):
  45         return "<hostname: {h}, domain: {d}>".format(h=self.hostname, d=self.domain)
  46
  ```
  --- 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/insights/parsers/hostname.py b/insights/parsers/hostname.py
  --- a/insights/parsers/hostname.py
  +++ b/insights/parsers/hostname.py
  @@ -34,6 +34,7 @@
           domain: The domain get from the fqdn.
       """
       def parse_content(self, content):
  +        content = filter(None, content)
           raw = None
           if len(content) == 1:
               raw = content[0].strip()
  
verification_info: {"golden_diff": "diff --git a/insights/parsers/hostname.py b/insights/parsers/hostname.py\n--- a/insights/parsers/hostname.py\n+++ b/insights/parsers/hostname.py\n@@ -34,6 +34,7 @@\n         domain: The domain get from the fqdn.\n     \"\"\"\n     def parse_content(self, content):\n+        content = filter(None, content)\n         raw = None\n         if len(content) == 1:\n             raw = content[0].strip()\n", "issue": "hostname parser doesn't handle sos_commands/general/hostname\nsos_commands/general/hostname contains the hostname with a newline at the end, which results in a file with two lines. The hostname parser specifically checks for one line but doesn't gracefully handle the problem.\r\n\r\nWe can update the parser to handle this case and/or investigate whether proc/sys/kernel/hostname is a valid substitute to put in sos_archive.py instead.\n", "before_files": [{"content": "\"\"\"\nhostname - command ``/bin/hostname``\n====================================\n\nThis parser simply reads the output of ``/bin/hostname``, which is the\nconfigured fully qualified domain name of the client system.  It then\nsplits it into ``hostname`` and ``domain`` and stores these as attributes,\nalong with the unmodified name in the ``fqdn`` attribute.\n\nExamples:\n\n    >>> hostname = shared[Hostname]\n    >>> hostname.fqdn\n    'www.example.com'\n    >>> hostname.hostname\n    'www'\n    >>> hostname.domain\n    'example.com'\n\n\"\"\"\n\nfrom .. import Parser, parser\nfrom insights.specs import Specs\n\n\n@parser(Specs.hostname)\nclass Hostname(Parser):\n    \"\"\"Class for parsing ``hostname`` command output.\n\n    Attributes:\n        fqdn: The fully qualified domain name of the host. The same to\n            ``hostname`` when domain part is not set.\n        hostname: The hostname.\n        domain: The domain get from the fqdn.\n    \"\"\"\n    def parse_content(self, content):\n        raw = None\n        if len(content) == 1:\n            raw = content[0].strip()\n        self.fqdn = raw\n        self.hostname = raw.split(\".\")[0] if raw else None\n        self.domain = \".\".join(raw.split(\".\")[1:]) if raw else None\n\n    def __str__(self):\n        return \"<hostname: {h}, domain: {d}>\".format(h=self.hostname, d=self.domain)\n", "path": "insights/parsers/hostname.py"}], "after_files": [{"content": "\"\"\"\nhostname - command ``/bin/hostname``\n====================================\n\nThis parser simply reads the output of ``/bin/hostname``, which is the\nconfigured fully qualified domain name of the client system.  It then\nsplits it into ``hostname`` and ``domain`` and stores these as attributes,\nalong with the unmodified name in the ``fqdn`` attribute.\n\nExamples:\n\n    >>> hostname = shared[Hostname]\n    >>> hostname.fqdn\n    'www.example.com'\n    >>> hostname.hostname\n    'www'\n    >>> hostname.domain\n    'example.com'\n\n\"\"\"\n\nfrom .. import Parser, parser\nfrom insights.specs import Specs\n\n\n@parser(Specs.hostname)\nclass Hostname(Parser):\n    \"\"\"Class for parsing ``hostname`` command output.\n\n    Attributes:\n        fqdn: The fully qualified domain name of the host. The same to\n            ``hostname`` when domain part is not set.\n        hostname: The hostname.\n        domain: The domain get from the fqdn.\n    \"\"\"\n    def parse_content(self, content):\n        content = filter(None, content)\n        raw = None\n        if len(content) == 1:\n            raw = content[0].strip()\n        self.fqdn = raw\n        self.hostname = raw.split(\".\")[0] if raw else None\n        self.domain = \".\".join(raw.split(\".\")[1:]) if raw else None\n\n    def __str__(self):\n        return \"<hostname: {h}, domain: {d}>\".format(h=self.hostname, d=self.domain)\n", "path": "insights/parsers/hostname.py"}]}