5 Replies Latest reply on Jun 20, 2012 11:21 AM by HerbSmith

    Separating the API from Python software

      Hi,

       

      I already have my own version of python and simply want to move the relevant files into site-packages. Have found the moving mcafee.py and urlquote.py are sufficient for the session to bind to the ePO and provide a result for >>>dir(mysession), but the next step of >>>dir(mysession.scheduler) returns the error of:

       

      >>> dir(mysession.scheduler)

      Traceback (most recent call last):

        File "<stdin>", line 1, in <module>

        File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ mcafee.py", line 451, in __call__

          raise AttributeError(msg)

      AttributeError: 'scheduler' has no attribute '__dir__' (make sure the command exists and that mcafee.client(...) was called prior to invoking the command)

       

      So, I am assuming that I need to copy over something else. Has anyone else played around with this ?

       

      And, can we get a package install instead?

       

      Thanks,
      Craig

        • 1. Re: Separating the API from Python software

          Hi Craig,

           

          You are correct; those are the only McAfee specific files needed for an existing Python installation.

           

          I tried your scenario: installing Python2.7 and putting mcafee.py and urlquote.py in Python27/Lib/site-packages but I wasn't able to produce the AttributeError you are seeing.

           

          The client object actually intercepts calls to dir() when it is passed as the argument, so that may be the culprit here but it doesn't necessarily indicate a faulty install. The dir() functionality isn't crucial for a working installation but was added make the interface as pythonic as possible to ease the learning curve.  All of what dir() returns can be retrieved from a call to 'mysession.help()'.   I would say the mark of a successful installation has more to do with the ability to call a remote command, such as mysession.help(), mysession.core.listUsers(), or  mysession.core.addUser() and see the requested data and/or validate the success of a requested operation.

           

          Your call to dir(mysession)...what did it look like?  Were you able to see the attributes listed in bold below?

           

          >>> dir(mysession)

          ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__',

          '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce_

          _', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subc

          lasshook__', '__weakref__', '_invoker', '_run', 'console', 'core', 'help', 'run'

          , 'scheduler', 'tasklog']

          >>>

           

          Try this following script so we can narrow down whether this is simply a dir() problem (that is my suspicion) or an actual failed installation/configuration problem:

           

          >>>import mcafee

          >>>c=mcafee.client('myservername',myport,'myusername','mypassword')

          >>>c.core.help('core.listUsers')

          <the detailed help description for core.listUsers command>

          >>>

           

          Are you able to achieve the desired results with the above script or something similar to the above script?  If you get the right results from the above script, then we know that you created a successful connection, connected to the server, sent and received data from the server, and we'd also know the problem is more than likely related to the dir() functionality, rather than a faulty install and we can file a bug for it.  If that's all it is, it shouldn't prevent you from running/executing any scripts you may author.  Let me know what you find.

           

           

          And, can we get a package install instead?

          I take that to mean using a standard third-party Python library installation process for the mcafee module rather than having to manual copy files as is currently the case.   Something like using distutils to distribute the module/package: http://docs.python.org/install/index.html:

           

          $ gunzip -c mcafee-1.0.tar.gz | tar xf -

          $ cd mcafee-1.0

          $ python setup.py install

           

          I assume that's what you mean and I will file a request to have this functionality added; if that's not the case let me know.

           

          Jeremy

           

          Message was edited by: jbrooks2 on 11/21/11 6:12:12 PM CST
          • 2. Re: Separating the API from Python software

            Sorry for the slow response.

             

            For point one,  I was able to connect a list users, policies, etc, so that's all fine.

             

            From the correction of the issue, my test was based upon the ePolicy Orchestrator 4.6.0 Scripting Guide, Page 14, the command dir(mysession) provided the same result as your showed, but dir(mysession.scheduler) failed instead of ot working per step 2 of page 14.

             

            For the installation question, yes you are correct with the URL. My preference is to simply have the API install the needed files into the site-packages directory as a third-party python module.

             

            Thanks,
            Craig

            • 3. Re: Separating the API from Python software

              Any fix for this in sight.   I am starting to build things out to you Python scripting.  Would much prefer to use the current 2.7.3 as it the current version of the 2.x series.

              I don't like the idea of starting off using an out of date version from the start.

              • 4. Re: Separating the API from Python software

                Hi Herb,

                 

                Official compatibility with Python 2.6 is what is available right now.  We do have plans to upgrade to Python 2.7 (or even 3.0); it's just a matter of scheduling which is beyond my control, unfortunately.   I can say this.  We have internal folks doing testing using Python 2.7 with the McAfee client and they haven't seen any problems.  We can't officially support Python 2.7 so it's your call; you're free to give it a shot and see how it works.

                 

                As an added note, as you may know, Python 3.0 is backward incompatible with 2.x scripts and as a result the McAfee client (compatible with 2.6) would not be compatible with a 3.0 installation.

                 

                I hope that helps,

                Jeremy

                • 5. Re: Separating the API from Python software

                  The Scripting Guide for ePolicy Orchestrator 4.6.0 says that the Python client requires Python version 2.5., 2.6, or 2.7.   That implies that McAfee intends for users to be able to work with any of those versions of Python.

                   

                  But then that guide is full of many misleading or incomplete statements.  So I am not surprised.

                   

                  Thanks

                   

                  Herb