cancel
Showing results for 
Search instead for 
Did you mean: 

Update on McAfee ePO Python Module Code?

I am trying to learn how to use Python to write scripts for McAfee ePO. The problem is the code I found uses the mcafee package is out of date and I can only find the mcafee-epo 1.0.1 (mcafee_epo) package. When using the new package, a lot of the modules are incompatible and trigger errors on execution. Are there any resources that I can be referred to that uses the newer mcafee_epo package or has the McAfee resources been updated for it yet?

PS. I'm currently running Python 3.6

5 Replies
Highlighted

Re: Update on McAfee ePO Python Module Code?

I too am learning python to do stuff in ePO.  In the script below, I'm able to pull some basic information including the Agent Version and Last Communication time from ePO.  Its python 2.7 but the changes should be minor.

sys.path[:0] = ('/mcafee/') # Use if the mcafee api folder is a subfolder of where you're running this.

import mcafee

import requests.packages.urllib3

user = raw_input("Enter Your Username: ")

passwd = getpass.getpass("Enter Your Password: ")

ips = raw_input('Enter an IP address to search: ')

requests.packages.urllib3.disable_warnings()

payload = {"searchText": ips}

r = requests.get('https://INSERT YOUR URL HERE:8443/remote/system.find?', params=payload, verify=False, auth=(user,passwd))

try:

  epoAgentVer = re.findall('Agent Version \(deprecated\): (\d.*$)', r.text, re.MULTILINE)[0]

  print ('ePO Agent Version: %s') % epoAgentVer

except IndexError:

  print ('Unable to find agent version.')

try:

  epoLastComm = re.findall('Last Communication: (.*) EDT', r.text, re.MULTILINE)[0]

  print ('Last Communication: %s EDT') % epoLastComm

except IndexError:

  print ('Unable to determine last communication time. \nDevice may not be managed or agent is not installed.')

Re: Update on McAfee ePO Python Module Code?

I thought the changes would be minor but it looks like with the new ePO package for Python has some significant changes. The more I'm adapting the code for the new package, the more errors I get, and using the new package on the code that you provided gives a lot of errors immediately. But it's not just the syntax difference, it's mainly the package itself. You're using import mcafee

but that package for Python 3.6 is obsolete and I cannot find it anywhere. The new package is import mcafee_epo and it differs significantly from the earlier package. So that's why I want to see if there's any documentation on the new package.                    

Re: Update on McAfee ePO Python Module Code?

The older McAfee ePO python package is available at:

The best bet for documentation on mcafee_epo would be here:

davidism / mcafee-epo — Bitbucket

According to that page the system.find call that you have would look like:

>>> from mcafee_epo import Client

>>> client = Client('https://localhost:8443', 'user', 'password')

>>> systems = client('system.find', '')

Reliable Contributor Hayton
Reliable Contributor
Report Inappropriate Content
Message 5 of 6

Re: Update on McAfee ePO Python Module Code?

Thread moved from Community Support to Business --> ePO for attention

Re: Update on McAfee ePO Python Module Code?

When you are running the code, is it directly on the McAfee ePO server or are you running it remotely from a workstation, managed by the ePO server? 

I have been fighting this for several days now and I cannot get past the import mcafee line.  I always hit the "no module named mcafee".  It is very frustrating.  

Does this only work when run from the ePO management server?

More McAfee Tools to Help You

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community