<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download_file(self, url, filename):
 """ Download file from url to filename. """

        self.print_message("Downloading to file '%s' from URL '%s'" % (filename, url))
        try:
            db_file = urllib2.urlopen(url)
            with open(filename, 'wb') as output:
                output.write(db_file.read())
            db_file.close()
        except Exception as e:
            self.error(str(e))
        self.print_message("File downloaded")