def download_file(self, download_url, path): if not self.Drive_Service: raise NeedLoginException(None) resp, content = service._http.request(download_url) if resp.status == 200: print 'Download Succeed' if path == 'metadata.xml': metadata = XMLNode.parseXML(content, True) f = open(path, 'w+') f.write(content) f.close() else: print 'Download Failed'
def download(self, download_url, path): if not self.Drive_Service: raise NeedLoginException(None) resp, content = self.Drive_Service._http.request(download_url) if resp.status == 200: #print 'Download Succeed' if path == '.metadata.xml': self.metadata = XMLNode.parseXML(content, True) return self.metadata #test existence of the dir, if not, create one dir = os.path.dirname(path) if not os.path.exists(dir): os.makedirs(dir) f = open(path, 'w+') f.write(content) f.close() else: print 'Download Failed'