Yes, that is what I want to do. 

Kind Regard
Bjørn-Roar

Den 1. aug. 2011 kl. 20:24 skrev spa...@gmail.com:

> Hi,
> 
> Let me understand the problem
> - Do you want to count the number of times the application was restarted 
> between today and 7 days back?
> => If yes, then you will need to do some string manipulation to get the 
> required dates. Then you will need to apply both the conditions to the line 
> i.e. if the date is the required date and if the string contains what you 
> want.
> i.e. if "2009-03-6" in line and <similar condition for the start text>:
> ... count += 1
> You can apply this logic to each date and create a complex statement using OR 
> to get the count.
> OR you can use the datetime object with proper formatting and check the 
> existence of the condition.
> 
> Do I understand your problem correctly? 
> 
> Regards
> Sumod
> 
> 
> 2011/8/1 Bjørn-Roar Eriksen <media...@gmail.com>
> Hi
> 
> I'm new to Python and I'm trying to write a script that's count restart of an 
> application. The log file contains:
> 2009-03-06 18:20:26,423  User operation - start nanny
> 2009-03-06 18:20:26,423  User operation - start all services
> And 2009-03-06 18:20:26,423  User operation - start all services tells me 
> that the application has been restarted.
> 
> My script do count it, but I cant figure out how to code so it's only get 
> from to day and 7 day's back.
> #Counts restart of an application
> count = 0
> with open("c:/test/bre.log")as f:
>     for line in f:
>         if "User operation - start all services" in line:
>             count += 1
>             #print line.strip()
>     print 'Server restart: %s' % count
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> 
> 
> -- 
> http://spawgi.wordpress.com
> We can do it and do it better.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to