def SetFilesList(self, serverInfo): self.setEnabled(True) domains = serverInfo.keys() or orngServerFiles.listdomains() localInfo = dict([(dom, orngServerFiles.allinfo(dom)) for dom in domains]) items = [] self.allTags = set() allTitles = set() self.updateItems = [] for i, domain in enumerate(set(domains) - set(["test", "demo"])): local = localInfo.get(domain, {}) server = serverInfo.get(domain, {}) files = sorted(set(server.keys() + local.keys())) for j, file in enumerate(files): infoServer = server.get(file, None) infoLocal = local.get(file, None) items.append((self.filesView, domain, file, infoLocal, infoServer)) displayInfo = infoServer if infoServer else infoLocal self.allTags.update(displayInfo["tags"]) allTitles.update(displayInfo["title"].split()) for i, item in enumerate(items): self.updateItems.append(UpdateTreeWidgetItem(self, *item)) self.pb.advance() self.filesView.resizeColumnToContents(0) self.filesView.resizeColumnToContents(1) self.filesView.resizeColumnToContents(2) self.lineEditFilter.setItems([hint for hint in sorted(self.allTags) if not hint.startswith("#")]) self.SearchUpdate() self.UpdateInfoLabel() self.pb.finish()
def UpdateFilesList(self): self.retryButton.hide() # self.progressBarInit() pb = OWGUI.ProgressBar(self, 3) self.filesView.clear() # self.tagsWidget.clear() self.allTags = set() allTitles = set() self.updateItems = [] if self.accessCode: self.serverFiles = orngServerFiles.ServerFiles( access_code=self.accessCode) self.error(0) try: domains = self.serverFiles.listdomains( ) if self.domains is None else self.domains pb.advance() serverInfo = dict([(dom, self.serverFiles.allinfo(dom)) for dom in domains]) pb.advance() except IOError, ex: self.error( 0, "Could not connect to server! Press the Retry button to try again." ) self.retryButton.show() domains = orngServerFiles.listdomains( ) if self.domains is None else self.domains pb.advance() serverInfo = {} pb.advance()
def files_report(): import orngServerFiles as sf sf = sf.ServerFiles() html = [] for domain in sf.listdomains(): if domain not in ["demo", "demo2", "test", "gad"]: allinfo = sf.allinfo(domain) html += ["<h2>%s</h2>" % domain, "<table><tr><th>Title</th><th>Date</th><th>Filename</th></tr>"] + \ ["<tr><td>%s</td><td>%s</td><td>%s</td></tr>" % (info["title"], info["datetime"], file) \ for file, info in allinfo.items()] + \ ["</table>"] return "\n".join(html)
def SetFilesList(self, serverInfo): self.setEnabled(True) domains = list(serverInfo.keys()) or orngServerFiles.listdomains() localInfo = dict([(dom, orngServerFiles.allinfo(dom)) for dom in domains]) items = [] self.allTags = set() allTitles = set() self.updateItems = [] for i, domain in enumerate(set(domains) - set(["test", "demo"])): local = localInfo.get(domain, {}) server = serverInfo.get(domain, {}) files = sorted(set(server.keys)) + list(local.keys()))) for j, file in enumerate(files):
import orngServerFiles reload(orngServerFiles) domain = "demo" # remove the domain from the local repository if domain in orngServerFiles.listdomains(): orngServerFiles.remove_domain(domain, force=True) # download all the files for this domain from the server server = orngServerFiles.ServerFiles() for filename in server.listfiles(domain): orngServerFiles.download(domain, filename, verbose=False) # make sure that both file lists are the same files_on_server = server.listfiles(domain) print "Domain: %s" % domain intersection = set(files_on_server).intersection(set(orngServerFiles.listfiles(domain))) if len(intersection) == len(files_on_server): print "Same number of files on server and local repository." else: print "Directories on server and local repository are different."