Python-rrdtool try except rrdtool.error module object has no attribute error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python-rrdtool try except rrdtool.error module object has no attribute error
# 1  
Old 10-20-2015
Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help
Code:
import rrdtool

try:      
      ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2));    
except rrdtool.error, e:
      print e

When i run the above i get the below error
Code:
except rrdtool.error, e:
AttributeError: 'module' object has no attribute 'error'

The code is intended to skip this error while updating the rrd file
Code:
illegal attempt to update using time 1363358441 when last update time is 1363358441 (minimum one second step)

Appreciate if you can help me get a solution for this

Thanks

Last edited by kaf3773; 10-20-2015 at 06:22 PM..
# 2  
Old 10-21-2015
abc.xyz in python means you're looking for an attribute (object, function, variable...) xyz inside the object abc. In your case, do you know if attribute rrdtool.error exists? Even if it does it should be a valid exception class (meaning, it should be derived from Exception class)

If you don't know or don't care what exception to catch exactly, you can always use the generic except block

Code:
import sys
import rrdtool

try:
  blah_blah
except:
    print "Exception occurred:", sys.exec_info()[0]
    raise # or do something else

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python rrdtool try catch statement

I have a Python script that updates an rrd file with data it pulls from a database. Here is a snippet of the Python code for i in range(numrowed): row = curred.fetchone() time_stamp = row rx_max = row ret =... (1 Reply)
Discussion started by: kaf3773
1 Replies

2. Red Hat

Why do we use RRDtool in MRTG?

Hi Guys, Why do we use RRDtool in MRTG? I have implemented MRTG for some routers, I have read some notes about RRDTOOL also but don't know what is use of these tool. Any one one please explain me the use of RRDTOOL in their own words? (1 Reply)
Discussion started by: manalisharmabe
1 Replies

3. UNIX for Dummies Questions & Answers

rrdtool question

Hi, DEF:clients=cccam.rrd:kliensek:AVERAGE DEF:activeclients=cccam_actclient.rrd:activeclients:AVERAGE "LINE1:clients#0000FF:Connected clients" COMMENT:" \n" "LINE2:activeclients#99FF00:Active clients" COMMENT:" \n" GPRINT:clients:LAST:'Current'\%5.0lf%s COMMENT:" \n"... (2 Replies)
Discussion started by: adriankoooo
2 Replies

4. Shell Programming and Scripting

Debian, digitemp, rrdtool

Mit perlscript: #!/usr/bin/perl # # copyright Per Hansen 2009 # # # temp.pl use lib qw(/opt/rrdtool-1.4.1/lib/perl); use RRDs; # sti til rrdtool databases my $rrd = '/var/lib/rrd'; # sti til færdige grafer (1 Reply)
Discussion started by: perhansen
1 Replies

5. HP-UX

compiling the RRDtool

I tried to compile the RRDtool on HP-UX (IA56). I have gcc-3.4.3 and perl 5.8.0 I got this: Writing Makefile for RRDs cd perl-shared && make /opt/perl/bin/perl /opt/perl/lib/5.8.0/ExtUtils/xsubpp -typemap /opt/perl/lib/5.8.0/ExtUtils/typemap RRDs.xs > RRDs.xsc && mv... (2 Replies)
Discussion started by: Kalin
2 Replies
Login or Register to Ask a Question