Need eyes to look at code... time not having an attribute called asctime()

H

Harlin Seritt

from utilities import *
from extractor import *
import time
import os

print 'Running AgentPing at '+time.asctime()

confFile = '../conf/AgentPing/AgentPing.conf'
ex = extractor(confFile)

names = ex.array('name')
comments = ex.array('comment')
ips = ex.array('ip')
counts = ex.array('count')
thresholds = ex.array('threshold')
alarms = ex.array('alarm')
levels = ex.array('level')
records = ex.array('record')

plogger = Logger('../logs/AgentPing.log')

for name,comment,count,ip,threshold,alarm,level,record in
zip(names,comments,counts,ips,thresholds,alarms,levels,records):
msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime()
print msg
plogger.loggit(msg)
line = 'ping -n '+count+' '+ip
try:
data = os.popen(line).readlines()
time = data[-1].split()[-1][:-2]
except:
msg = 'AGENT FAILURE: Unable to run ping on '+ip+' for unknown
reason.'
print msg
msg += 'Error created at '+time.asctime()
time = float(threshold)*2
plogger.loggit(msg)
createAlarm(name, comment, ip, threshold, level, msg)

Whenever I run this I get:
Traceback (most recent call last):
File "agentPing.py", line 23, in ?
msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime()
AttributeError: 'str' object has no attribute 'asctime'
Press any key to exit

I'm sure this is something simple but for this I am having trouble
figuring it out.

Thanks,

Harlin Seritt
 
S

Scott David Daniels

Harlin said:
from utilities import *
from extractor import *
import time ....
data = os.popen(line).readlines()
time = data[-1].split()[-1][:-2]
This seems an unfortunate choice of names.
except:
...

--Scott David Daniels
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,270
Members
46,873
Latest member
HeidiWeing

Latest Threads

Top