def testCurrentRescans(self): spider.pause() self._configmethod("rescan_root", self.static_path) rescans = self._configmethod("current_rescans") self.assertEqual(len(rescans), 1) self.assertEqual(rescans[0], self.static_path) spider.unpause()
def testRemoveRoot(self): spider.pause() self._configmethod("rescan_root", self.static_path) rootcount = len(self._configmethod("all_roots")) res = self._configmethod("remove_root", self.static_path) self.assertEqual(len(res), rootcount - 1) for wp in spider.queue: print "q", wp, wp.root spider.unpause() self.needs_static()
def testRemoveRoot(self): spider.pause() self._configmethod("rescan_root", self.static_path) rootcount = len(self._configmethod("all_roots")) res = self._configmethod("remove_root", self.static_path) self.assertEqual(len(res), rootcount - 1) for wp in spider.queue: logger.debug("still queued %s %s", wp, wp.root) spider.unpause() self.needs_static()
def remove_root(request, root): for x in WebPath.get_root_nodes(): if x.url == root: spider.pause() start = time() logger.debug("deleting %s %s", root, x) MusicFile.objects.filter(parent__root = x).delete() WebPath.objects.filter(root = x).delete() x.delete() logger.debug("deleted %s", time()-start) spider.unpause() break return all_roots(request)
def remove_root(request, root): for x in WebPath.get_root_nodes(): if x.url == root: spider.pause() start = time() print "deleting", root, x MusicFile.objects.filter(parent__root=x).delete() WebPath.objects.filter(root=x).delete() x.delete() print "deleted", time() - start spider.unpause() break return all_roots(request)
def rescan_root(request, root): result = "success" for x in WebPath.get_root_nodes(): if x.url == root: spider.pause() x.delete() spider.add(WebPath.add_root(root)) spider.unpause() break else: try: urlopen(root) spider.add(WebPath.add_root(url=root)) except Exception, e: logger.debug("don't like %s %s %s", root, e, request.META) result = "failure"
def rescan_root(request, root): result = "success" for x in WebPath.get_root_nodes(): if x.url == root: spider.pause() x.delete() spider.add(WebPath.add_root(root)) spider.unpause() break else: try: urlopen(root) spider.add(WebPath.add_root(url=root)) except Exception, e: print "don't like", root, e print request.META result = "failure"