def build_response_from_file(self, request, stream): path = uri_to_path(request.url) stat_info = os.stat(path) response = self.build_response(request, FileResponse(path, "rb")) response.headers["content-length"] = str(stat_info.st_size) return response
def add_repo(self, repo, index_fn=None): """ Add a repo to the chain, i.e. read the index file of the url, parse it and update the index. """ if self.verbose: print "Adding repository:" print " URL:", repo repo = dist_naming.cleanup_reponame(repo) self.repos.append(repo) if index_fn: # for running the tests locally repo_path = uri_to_path(repo) index_data = open(join(repo_path, index_fn)).read() new_index = metadata.parse_depend_index(index_data) else: new_index = dict(self.connect(repo).query(type='egg')) for spec in new_index.itervalues(): add_Reqs_to_spec(spec) for distname, spec in new_index.iteritems(): dist = repo + distname self.index[dist] = spec self.groups[spec['cname']].append(dist)
def add_repo(self, repo, index_fn=None): """ Add a repo to the chain, i.e. read the index file of the url, parse it and update the index. """ if self.verbose: print("Adding repository:") print(" URL:", repo) repo = dist_naming.cleanup_reponame(repo) self.repos.append(repo) if index_fn: # for running the tests locally repo_path = uri_to_path(repo) with open(join(repo_path, index_fn), "rt") as fp: index_data = fp.read() new_index = metadata.parse_depend_index(index_data) else: new_index = dict(self.connect(repo).query(type='egg')) for spec in new_index.values(): add_Reqs_to_spec(spec) for distname, spec in new_index.items(): dist = repo + distname self.index[dist] = spec self.groups[spec['cname']].append(dist)
def test_uri_to_path_simple_local(self): if sys.platform == "win32": r_path = "vagrant\\yo" uri = "file://vagrant/yo" else: r_path = "vagrant/yo" uri = "file://vagrant/yo" path = uri_to_path(uri) self.assertEqual(r_path, path)
def test_uri_to_path_simple(self): if sys.platform == "win32": r_path = "C:\\Users\\vagrant\\yo" uri = "file:///C:/Users/vagrant/yo" else: r_path = "/home/vagrant/yo" uri = "file:///home/vagrant/yo" path = uri_to_path(uri) self.assertEqual(r_path, path)
def connect(self, repo): config = Configuration.from_file(HOME_ENSTALLER4RC) if repo in self.repo_objs: return self.repo_objs[repo] if repo.startswith('file://'): repo_path = uri_to_path(repo) r = LocalIndexedStore(repo_path) r.connect() elif repo.startswith(('http://', 'https://')): r = RemoteHTTPIndexedStore(repo, config.local) if repo.startswith('https://'): r.connect(userpass=('EPDUser', 'Epd789')) else: r.connect() self.repo_objs[repo] = r return r