Repository: RedHatInsights/insights-core

Issue:
DatasourceProvider reads file-content in "bytes" format and causing parsing to fail
Original Exception raised by the parser
```
  File "/work/insights/insights-core/insights/core/__init__.py", line 95, in _handle_content
    self.parse_content(context.content)
  File "/work/insights/insights-core/insights/parsers/ld_library_path.py", line 56, in parse_content
    user, _, raw = [s.strip() for s in line.partition(' ')]
AttributeError: 'int' object has no attribute 'partition'
```

Collected `meta_data`:
```json
# cat /tmp/insights-vm37-39.gsslab.pek2.redhat.com-20210308120914/meta_data/insights.specs.Specs.ld_library_path_of_user.json | python3 -m json.tool
{
    "exec_time": 0.0009329319000244141,
    "ser_time": 0.0006611347198486328,
    "errors": [],
    "name": "insights.specs.Specs.ld_library_path_of_user",
    "results": {
        "object": {
            "relative_path": "insights_commands/echo_user_LD_LIBRARY_PATH"
        },
        "type": "insights.core.spec_factory.DatasourceProvider"
    }
}
```

The content:
```
# insights-inspect insights.specs.Specs.ld_library_path_of_user /tmp/insights-vm37-39.gsslab.pek2.redhat.com-20210308120914

In [1]: type(ld_library_path_of_user)
Out[1]: insights.core.spec_factory.SerializedRawOutputProvider

In [2]: type(ld_library_path_of_user.content)
Out[2]: bytes

In [3]: ld_library_path_of_user.content
Out[3]: b'rh1adm /usr/sap/RH1/SYS/exe/run:/usr/sap/RH1/SYS/exe/uc/linuxx86_64:/sapdb/clients/RH1/lib\nsr1adm /usr/sap/SR1/HDB02/exe/krb5/lib/krb5/plugins/preauth:/usr/sap/SR1/HDB02/exe/krb5/lib:/usr/sap/SR1/HDB02/exe:/usr/sap/SR1/HDB02/exe/Python/lib:/usr/sap/SR1/HDB02/exe/filter:/usr/sap/SR1/HDB02/exe/dat_bin_dir:/usr/sap/SR1/HDB02/exe/plugins/afl:/usr/sap/SR1/HDB02/exe/plugins/lcapps:/usr/sap/SR1/HDB02/exe/plugins/repository:/usr/sap/SR1/HDB02/exe/plugins/epmmds:/usr/sap/SR1/SYS/global/hdb/federation:/usr/sap/SR1/SYS/global/hdb/plugins/3rd_party_libs\nrh2adm /usr/sap/RH2/SYS/exe/run:/usr/sap/RH2/SYS/exe/uc/linuxx86_64:/sapdb/clients/RH2/lib'
```

I'm unsure if it's OK to modify the [load](https://github.com/RedHatInsights/insights-core/blob/6dcb0a35b9bf8089a860fbb8b7364029076b9b72/insights/core/spec_factory.py#L202-L205) method to read the file to a list directly:

```python
self.loaded = True
with open(self.path, 'r') as f:
        return f.readlines()
```

@csams , @bfahr - would you please have a look?


Discussion:
Hey @xiangce we can change the `SerializedRawOutputProvider` in the [deserializer](https://github.com/RedHatInsights/insights-core/blame/6dcb0a35b9bf8089a860fbb8b7364029076b9b72/insights/core/spec_factory.py#L1079) to a `SerializedOutputProvider`.

The raw providers exist  in case we ever need to collect binary data instead of text. I defaulted datasource providers to raw binary since it was most general, but we really need `datasource` functions to be able to return different objects for text and raw bytes.

Resolving patch:
diff --git a/insights/core/spec_factory.py b/insights/core/spec_factory.py
--- a/insights/core/spec_factory.py
+++ b/insights/core/spec_factory.py
@@ -1076,4 +1076,4 @@ def serialize_datasource_provider(obj, root):
 
 @deserializer(DatasourceProvider)
 def deserialize_datasource_provider(_type, data, root):
-    return SerializedRawOutputProvider(data["relative_path"], root)
+    return SerializedOutputProvider(data["relative_path"], root)


Test patch: