Hi Expert, I'm a newbie to python and still on the process of learning on the go ...
I have a webserver which has list of images to load on a Device Under Test (DUT) ... *Requirement is:* if the image is already present on the server, proceed with loading the image onto the DUT. if the image is not present on the server , then proceed with the download of the image and then upgrade the DUT. I have written the following code but I'm quite not happy with the way I have written this, because I have a feeling that it could have been done better using some other method/s Please suggest the areas where i could have done better and the techniques to do so.. Appreciate your time in reading this email and for your valuable suggestions. <Code> import urllib2 url = 'http://localhost/test' filename = 'Image60.txt' # image to Verify def Image_Upgrade(): print 'proceeding with Image upgrade !!!' def Image_Download(): print 'Proceeding with Image Download !!!' resp = urllib2.urlopen(url) flag = False list_of_files = [] for contents in resp.readlines(): if 'Image' in contents: c=(((contents.split('href='))[-1]).split('>')[0]).strip('"') # The content output would have html tags. so removing the tags to pick only image name if c != filename: list_of_files.append(c) else: Image_Upgrade() flag = True if flag==False: Image_Download() </code> Thanks, Vijay Swaminathan
-- http://mail.python.org/mailman/listinfo/python-list