cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Former Member
Not applicable
Report Inappropriate Content
Message 1 of 6

Python 2.7.3 and Web Scripting Guide.

I am not sure why the Web Scripting guide can not be a complete guide.   The paragraph "Python client software requirement" is badly misleading.   It makes not mention of the more complete setup instructions in the download page.  It would be nice if it refered one there or even better if it repeated the information.  It would avoid having to look multiple places for things.  Most guides are complete

This section makes no mention of the other files that need to be copied over to an Python 2.7.3 installation.

There is also an known issue with task 2 on page 14.  I found a discussion on the forums about this from quite number of months ago.  

It does not take a lot of time or expense to update on line documentation.   Keeping the doc's current would save us customers a lot of time.

Thanks

Herb Smith

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

Re: Python 2.7.3 and Web Scripting Guide.

This must belong in ePO 4.6 API, don't know how it ended up in the Community Interface Help section. So I've moved it.

Former Member
Not applicable
Report Inappropriate Content
Message 3 of 6

Re: Python 2.7.3 and Web Scripting Guide.

Here are the steps I use to set up a system running python for use with ePO Web API

1.  Download and install Python 2.7.x  http://www.python.org

2.  Add C:\python27 to the PATH system environment variable

3.  From the downloaded python pacakge via the ePO software manager. extract and copy mcafee.py and urlquote.py to the C:\python27\lib directory

4.  Install the modules from comand prompt using "python mcafee.py install" command and "python urlquote.py install" command.

5. Verify web API funciton using the following script. *requires getpass module

#------------------------------------------------------------------------------

#Torry Campbell

#McAfee Inc. 2012

#

#Test web API connection to server

#------------------------------------------------------------------------------

#------------------------------------------------------------------------------

#Import required modules

#------------------------------------------------------------------------------

import mcafee

import string

import getpass

from mcafee import CommandInvokerError

print "\n"

ePOServer=''

while ePOServer=='':

    ePOServer=raw_input('Please input your ePO Server name or IP: ')

ePOPort=''

while ePOPort=='':

    ePOPort=raw_input('Please input your ePO Server name or IP: ')

ePOUsername=''

while ePOUsername=='':

    ePOUsername=raw_input('Please input your ePO User Name: ')

ePOUserPwd=''

while ePOUserPwd=='':

    ePOUserPwd=getpass.getpass('Please input your ePO User Password: ')

print '------------------------------------------------------------------------------'

print 'Testing server connectivity.....\n'

try:

    mc = mcafee.client(ePOServer, ePOPort, ePOUsername, ePOUserPwd)

    print "Success! " + ePOServer + " connected."

    mc.close

except CommandInvokerError, ex:

    err = None

    if string.find(ex.msg, 'Errno 11004') != -1:

        err = ePOServer + ' cannot find host'

    elif string.find(ex.msg, 'Errno 10060') != -1:

        err = ePOServer + ' connection attempt timed out'

    elif string.find(ex.msg, 'Errno 10061') != -1:

        err = regsrv + ' connection refused' # likely an incorrect port

    elif string.find(ex.msg, 'Error 401') != -1:

        err = ePOServer + ' user unauthorized'

    else:

        err = '(CommandInvokerError) ' + ex.msg

    print 'Error! %s' % (err)

print '\nTesting server connectivity complete.'

print '------------------------------------------------------------------------------'

rdasso
Level 9
Report Inappropriate Content
Message 4 of 6

Re: Python 2.7.3 and Web Scripting Guide.

Torry... thank you for your steps to get started.

FWIW, the second input in the connection test script is asking for a port, not the name/IP again.

Also, Python 2.7 has getpass built-in... no need to install any additional modules.

Former Member
Not applicable
Report Inappropriate Content
Message 5 of 6

Re: Python 2.7.3 and Web Scripting Guide.

Hello Torry...

import mcafee

mc = mcafee.client('epo-windows','8443','admin','Infyepo@123')

print("hello")

I am using python 3.3.2, and using above code to connect to epo server.

My epo server is on one romote machine.

I am trying to connect to that epo server from local machine. But getting following excetion. Can you please suggest me,where I am wrong?

Traceback (most recent call last):

  File "C:\Python33\lib\urllib\request.py", line 1248, in do_open

    h.request(req.get_method(), req.selector, req.data, headers)

  File "C:\Python33\lib\http\client.py", line 1061, in request

    self._send_request(method, url, body, headers)

  File "C:\Python33\lib\http\client.py", line 1099, in _send_request

    self.endheaders(body)

  File "C:\Python33\lib\http\client.py", line 1057, in endheaders

    self._send_output(message_body)

  File "C:\Python33\lib\http\client.py", line 902, in _send_output

    self.send(msg)

  File "C:\Python33\lib\http\client.py", line 840, in send

    self.connect()

  File "C:\Python33\lib\http\client.py", line 1194, in connect

    self.timeout, self.source_address)

  File "C:\Python33\lib\socket.py", line 417, in create_connection

    for res in getaddrinfo(host, port, 0, SOCK_STREAM):

socket.gaierror: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Python33\lib\mcafee.py", line 305, in get_response

    sock = self.create_socket(url, fileargs)

  File "C:\Python33\lib\mcafee.py", line 375, in create_socket

    return self.opener.open(url)

  File "C:\Python33\lib\urllib\request.py", line 469, in open

    response = self._open(req, data)

  File "C:\Python33\lib\urllib\request.py", line 487, in _open

    '_open', req)

  File "C:\Python33\lib\urllib\request.py", line 447, in _call_chain

    result = func(*args)

  File "C:\Python33\lib\urllib\request.py", line 1283, in https_open

    context=self._context, check_hostname=self._check_hostname)

  File "C:\Python33\lib\urllib\request.py", line 1251, in do_open

    raise URLError(err)

urllib.error.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "D:\PythonWorkspace\de.vogella.python.first\src\webapiscriptexample-1.py", line 4, in <module>

    mc = mcafee.client('epo-windows','8443','admin','Infyepo@123')

  File "C:\Python33\lib\mcafee.py", line 537, in __init__

    self._invoker.save_token()

  File "C:\Python33\lib\mcafee.py", line 243, in save_token

    response = self.get_response(url)

  File "C:\Python33\lib\mcafee.py", line 313, in get_response

    log_and_raise_error(logging.ERROR, 'Failed to reach the server %s:%s. Error/reason: %s' % (self.host,self.port,str(e)))

  File "C:\Python33\lib\mcafee.py", line 92, in log_and_raise_error

    raise CommandInvokerError(code, msg)

mcafee.CommandInvokerError: Failed to reach the server epo-windows:8443. Error/reason: <urlopen error [Errno 11004] getaddrinfo failed>

Former Member
Not applicable
Report Inappropriate Content
Message 6 of 6

Re: Python 2.7.3 and Web Scripting Guide.

It says "Failed to reach the server epo-windows:8443"

Please try with ip-address of ePO

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

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 our Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

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