Python 2.4.3

Writing a function that takes the string from "ssh <server> ls -l
/var/log/yum.log" and tries to see if the file is more than a couple months
old. The goal is to only run python on the local server and it will ssh
into the remote server.

Is there a better way to do this?

Thanks!

Leam

####

Standard type of string that would come in date_string:

New file:
  -rw-------  1 sam users    105 Jun 19 13:57 guido2

Old file:
  -rw-------  1 sam users    105 May 19 2011 guido



####

def linux_too_old(date_string):
        '''(string) -> boolean

        Returns True if the date string is more than a couple months old.

        '''

        months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec']
        this_month = datetime.date.today().month

        file_date = date_string.split()

        if ':' not in file_date[7]:
                return True

        file_month = file_date[5]

        if 0 < (this_month - months.index(file_month)) < 3:
                return False




-- 
Mind on a Mission <http://leamhall.blogspot.com/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to