<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def downloadFile(self, filename, ispickle=False, athome=False):
 """ Downloads a single file from Redunda. :param str filename: The name of the file you want to download :param bool ispickle: Optional variable which tells if the file to be downloaded is a pickle; default is False. :returns: returns nothing """

        print("Downloading file {} from Redunda.".format(filename))

        _, tail = os.path.split(filename)
        url = "https://redunda.sobotics.org/bots/data/{}?key={}".format(tail, self.key)

        requestToMake = request.Request(url)

        #Make the request.
        response = request.urlopen(requestToMake)

        if response.code != 200:
            print("Error occured while downloading file '{}' with error code {}.".format(filename,response.code))

        if athome:
            filename = str(os.path.expanduser("~")) + filename


        filedata = response.read().decode("utf-8")

        try:
            if filename.endswith (".pickle") or ispickle:
                data = json.loads(filedata)
                try:
                    with open(filename, "wb") as fileToWrite:
                        pickle.dump (data, fileToWrite)
                except pickle.PickleError as perr:
                    print("Pickling error occurred: {}".format(perr))
                    return
            else:
                with open (filename, "w") as fileToWrite:
                    fileToWrite.write(filedata)
        except IOError as ioerr:
            print("IOError occurred: {}".format(ioerr))
            return