예제 #1
0
파일: tests.py 프로젝트: palfrey/nih
 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()
예제 #2
0
파일: tests.py 프로젝트: Ferada/nih
 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()
예제 #3
0
파일: tests.py 프로젝트: palfrey/nih
 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()
예제 #4
0
파일: tests.py 프로젝트: Ferada/nih
 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()
예제 #5
0
파일: configfuncs.py 프로젝트: Ferada/nih
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)
예제 #6
0
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)
예제 #7
0
파일: configfuncs.py 프로젝트: Ferada/nih
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"
예제 #8
0
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"