Updated Again: Python script to download virus definitions

Simple, but annoying bug in my python script that downloads virus definitions. It was downloading incomplete files with the .iwnew extension, which caused following downloads to fail. Finally, it bugged me enough that I investigated. It appears that Symantec appends the .iwnew file extension to their most current file in what I am assuming is while they are uploading it to their site. So I added a simple check for the file extension and have it fail if found. While watching the site, it could take Symantec over half an hour to complete their upload and because I have the script to run as an hourly cron, I will just have it check again in an hour.

Changed from

1
2
3
4
5
6
7
8
9
def newFile(fn):
    # Check for newer file
    oldFile = glob.glob('/home/cpowell/Desktop/' + '*.jdb')
    if not oldFile:
        return True
    if (oldFile[0].split('/').pop() != fn):
        return True
    else:
        return False

to

1
2
3
4
5
6
7
8
9
10
11
def newFile(fn):
    # Check for newer file and fail on .iwnew
    oldFile = glob.glob('/home/cpowell/Desktop/' + '*.jdb')
    print fn.split('.').pop()
    if not oldFile:
        return True
    # Added 'iwnew' file extension check.
    if (oldFile[0].split('/').pop() == fn) or (fn.split('.').pop() == 'iwnew'):
        return False
    else:
        return True

Leave a Reply

Your email address will not be published. Required fields are marked *