コード例 #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"