splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

SearchCommand

Open rhaarm opened this issue 11 years ago • 5 comments

I tried to see if there was an issue already for this, but couldn't find one. I'm seeing a lot of errors in the test runs with errors coming from search_command.py & SearchCommand. After using PyCharm inspection it looks like there is type(self).name being referenced but never declared. I would edit this myself, but not sure what the self.name is referencing, maybe SearchCommand.name?

    def __str__(self):
        values = [type(self).name, str(self.options)] + self.fieldnames
        text = ' '.join([value for value in values if len(value) > 0])
        return text

Also it maybe safe to move these from init into the class declaration, since the displayed stacktrace shows that the self.option cannot find self._option_view.

class SearchCommand(object): 
       def __init__(self):
              self._configuration = None
              self._fieldnames = None
              self._option_view = None
              self._output_file = None
              self._search_results_info = None
              self._service = None
class SearchCommand(object): 
       _configuration = None
        _fieldnames = None
        _option_view = None
        _output_file = None
        _search_results_info = None
        _service = None

       def __init__(self):
Logged from file search_command.py, line 60
.Traceback (most recent call last):
  File "D:\Python27\Lib\logging\__init__.py", line 859, in emit
    msg = self.format(record)
  File "D:\Python27\Lib\logging\__init__.py", line 732, in format
    return fmt.format(record)
  File "D:\Python27\Lib\logging\__init__.py", line 471, in format
    record.message = record.getMessage()
  File "D:\Python27\Lib\logging\__init__.py", line 335, in getMessage
    msg = msg % self.args
  File "d:\code\splunk-sdk-python\splunklib\searchcommands\search_command.py", line 78, in __str__
    values = [type(self).name, str(self.options)] + self.fieldnames
  File "d:\code\splunk-sdk-python\splunklib\searchcommands\search_command.py", line 164, in options
    if self._option_view is None:
AttributeError: 'StubbedGeneratingCommand' object has no attribute '_option_view'

rhaarm avatar Jun 24 '15 20:06 rhaarm

Hi @rhaarm we are aware of these test failures - see my comment in #102. We are actively working on updating the searchcommands sub-package to address some of these test failures among other things.

shakeelmohamed avatar Jun 24 '15 22:06 shakeelmohamed

@shakeelmohamed I wanted to let you know that I am also working on a compatible port for Python 2.7 & 3+, but as trying to accomplish a fully successful test from origin/master with Python 2.7, it's been troublesome. I would like to send y'all a full dump of the python setup.py test to verify if there are some other issues, I also noticed that in the test it seems to drop connection AssertionError: Operation timed out. with the server.

Python 3 Compat

So far I was able to add in future and six to assist with compatibility, but continue to struggle with some of the bits in searchcommands. Luckily this site has be a life saver for some of the conversion. I would like to know if it is a preference to do full questions about the API to go through [email protected]? I have a few questions in regards to the work to be done on searchcommands. From the comments already made about searchcommands, it looks like I just need to totally ignore it for the time being until the fix is provided.

rhaarm avatar Jun 29 '15 22:06 rhaarm

@rhaarm I would agree on the searchcommand - just pretend it and its tests don't exist for the time being - we are working on a significant revamping of it, no need to have your work and time wasted on it.

itay avatar Jun 29 '15 22:06 itay

We've overhauled the searchcommands test suite in preparation for the next release which includes a number of new features/bug fixes. These changes should address your test run issue. See CHANGELOG.md on the develop branch for additional information on our forthcoming Python SDK release.

David-Noble-at-work avatar Sep 24 '15 17:09 David-Noble-at-work

Hi @rhaarm, we've just released v1.5.0. To handle the other tests, you can now install our sdk-app-collection app which is available here.

shakeelmohamed avatar Oct 02 '15 00:10 shakeelmohamed