def get_string_from_url(self, url=""): """ Read a string from a url (file) on the server. Purpose: to read a file on the server that contains the md5sum of a file that we are going to download for file integrity. @param: url - place storing string we are looking for @returns: string returned by the url @author: Roy Nielsen """ server_string = "" set_no_proxy() if not re.match("^\s*$", url): set_no_proxy() try: f = urllib2.urlopen(url) except IOError, err: self.logger.log(LogPriority.INFO, ["InstallingHelper.get_string_from_url", "IOError, " + url + " : " + str(err)]) else: server_string = f.read() f.close()
def download_and_save_file(self, fpath="") : """ Download a file from "url" to "fpath" location, a "chunk" at a time, so we don't get a memory filling problem. @param: fpath - path to save the file to @author: Roy Nielsen """ if not re.match("^$", self.url) or not re.match("^$", fpath) : set_no_proxy() # first try to open the URL try : urlfile = urllib2.urlopen(self.url) except Exception , err: self.logger.log(LogPriority.DEBUG, ["InstallingHelper.download_and_save_file", "Error: " + str(err)]) else : try : # Next try to open the file for writing f = open(fpath, "w") except IOError, err : self.logger.log(LogPriority.INFO, ["InstallingHelper.download_and_save_file", "Error opening file - err: " + str(err)]) except Exception, err : self.logger.log(LogPriority.INFO, ["InstallingHelper.download_and_save_file", "Generic exception opening file - err: " + str(err)])
def get_string_from_url(self, url=""): """ Read a string from a url (file) on the server. Purpose: to read a file on the server that contains the md5sum of a file that we are going to download for file integrity. @param: url - place storing string we are looking for @returns: string returned by the url @author: Roy Nielsen """ server_string = "" set_no_proxy() if not re.match("^\s*$", url): set_no_proxy() try: f = urllib2.urlopen(url) except IOError, err: self.logger.log(LogPriority.INFO, [ "InstallingHelper.get_string_from_url", "IOError, " + url + " : " + str(err) ]) else: server_string = f.read() f.close()
def __init__(self, logger): """ Constructor """ self.logger = logger ########################## # Make it so this will only work on the yellow. set_no_proxy()
def download_and_save_file(self, fpath=""): """ Download a file from "url" to "fpath" location, a "chunk" at a time, so we don't get a memory filling problem. @param: fpath - path to save the file to @author: Roy Nielsen """ if not re.match("^$", self.url) or not re.match("^$", fpath): set_no_proxy() # first try to open the URL try: urlfile = urllib2.urlopen(self.url) except Exception, err: self.logger.log(LogPriority.DEBUG, [ "InstallingHelper.download_and_save_file", "Error: " + str(err) ]) else: try: # Next try to open the file for writing f = open(fpath, "w") except IOError, err: self.logger.log(LogPriority.INFO, [ "InstallingHelper.download_and_save_file", "Error opening file - err: " + str(err) ]) except Exception, err: self.logger.log(LogPriority.INFO, [ "InstallingHelper.download_and_save_file", "Generic exception opening file - err: " + str(err) ])