Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 10
Report Inappropriate Content
Message 1 of 7

python script no longer functions

As you may remember, a couple months ago I was working on using iPython to take a flat file of systems and tag them.  I did get it working.  It was around the middle of February.  So I was asked to revisit this and write a guide for future users so they too could create and use flat files.  When I came back to this task I found that the script i wrote that was working, no longer functions.  There have been no changes from my end, and the person who tested this script is a power user/administrator in the environment so he should have no problems running this.  Here is what I have done so far:

  1. Reassociate the script to python from .txt.  Somewhere along the way the association was changed from python to notepad.  I did not change the association. 
  2. Reviewed the script several times to ensure that nothing had changed.  I did need to update my password, as that did change after 90 days. 
  3. used full path to the flat file containing the target systems
  4. Validated that the and were located in the same folder as the script I was attempting to run
  5. Tried a secondary version of the and in case the originals were corrupted
  6. Reviewed my documentation
  7. Reviewed McAfee Documentation

My script is in the following format.

import mcafee

mc = mcafee.client ('mnap3663','9597','username','password')

file = open('Tagme.txt', 'r')

for line in file:
 mc.system.applyTag(line.rstrip('\n'), 'M.Kirby_test_tag')


I am at a loss for how or why it would stop working, when nothing has changed.  Any ideas are welcome and appreciated. 

Thank you.

Labels (3)
6 Replies
Level 10
Report Inappropriate Content
Message 2 of 7

Re: python script no longer functions

MMore information or fuel to add to the fire. 

I am still working on getting my script functioning again.  Here is what I have found when I use the Spyder Debugging tool.

When I run the script it stops at this line :  file = open('Documents\Tag_me_test.txt', 'r') If does not matter if it is the full location or just what I have displayed.  I get a message on the Console window (to the right) that reads :  runfile('C:/Users/michael.kirby/Documents/', wdir='C:/Users/michael.kirby/Documents')
  File "C:\Users\michael.kirby\Documents\", line 283
    except KeyError, e:
SyntaxError: invalid syntax

So I go back to the and try removing the comma, replacing the comma with a semi colon and even adding a backslash after the e: but nothing. 

This is the that comes with the iPython tool so it is not a manually created script. 

Thanks again

Level 10
Report Inappropriate Content
Message 3 of 7

Re: python script no longer functions

Update #2.

After further investigating, I have found that the version of Anaconda / iPython installed on my system is 4.3.1, which was installed Feb 8th 2018.  If i am correct the version of the and that I was given on Feb 5th by the department controlling the software rollout was 2.7.3.  If that is the case, do i have a compatability issue between the two and that is why when i run the Jupiter Notebook and or the Sypder debugging tool that it cannot find the or has a problem with that on line 283?

Thanks for looking.  Any response may lead to a full resolution.

Level 10
Report Inappropriate Content
Message 4 of 7

Re: python script no longer functions

Update #3

I am still working my way through this.  Here is where we stand at the moment. 

If i use (which was a script I found not sure where at the moment) I can get past the autnentication and it will run right up to thelast line where it needs to actually tag the systems listed in the flat file.  It then gives the message of " AttributeError: 'Client' object has no attribute 'System' ".

So I tried to use the script that I updated using, which is a part of the Python v,3 product that basically updates older script to woirk with the new version of Python.  The was successfully updated, and when i use that as the import mcafee, and then direct it to the epo server it spits out that it cannot authenticate.  a 401 authentication message.  I have trie both the server name as well as the IP address, plus as the same line authenticates with the, it should authenticate with this.

Please help this has gone on far too long. 

Level 7
Report Inappropriate Content
Message 5 of 7

Re: python script no longer functions

I am also experiencing this same issue. What is your server version?
our previous server uses windows server 2012 and my python script to apply tags works fine however upon migrating to windows 2016, the script does not work anymore.

McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 6 of 7

Re: python script no longer functions

Try the latest 2.7.1 or higher version of python.  See if KB90056 applies.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

Level 7
Report Inappropriate Content
Message 7 of 7

Re: python script no longer functions

Hi I have installed Python version 2.7.15 and upon testing the apply tag script i received this error:

Traceback (most recent call last):

  File "C:\Users\Username\Desktop\Python\", line 4, in <module>

    file = open('C:\Users\Username\Desktop\Python\test.txt', 'r')

IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Users\Username\\Desktop\\Python\test.txt'


Still our script whenever we use it in our 2012 server works just fine.

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 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