changeset 503:1c46c48ca67e

moin maint cleanpage imported from: moin--main--1.5--patch-507
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 26 Mar 2006 12:49:07 +0000
parents 55691a4d867a
children 67d5daa9e872
files ChangeLog MoinMoin/script/maint/cleanpage.py MoinMoin/script/old/pagescleaner.py docs/CHANGES setup.py
diffstat 5 files changed, 87 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 26 12:38:33 2006 +0000
+++ b/ChangeLog	Sun Mar 26 12:49:07 2006 +0000
@@ -2,6 +2,27 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-26 13:49:07 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-507
+
+    Summary:
+      moin maint cleanpage
+    Revision:
+      moin--main--1.5--patch-507
+
+    moin maint cleanpage
+    
+
+    modified files:
+     ChangeLog MoinMoin/script/maint/cleanpage.py docs/CHANGES
+     setup.py
+
+    renamed files:
+     MoinMoin/script/old/.arch-ids/pagescleaner.py.id
+       ==> MoinMoin/script/maint/.arch-ids/cleanpage.py.id
+     MoinMoin/script/old/pagescleaner.py
+       ==> MoinMoin/script/maint/cleanpage.py
+
+
 2006-03-26 13:38:33 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-506
 
     Summary:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/maint/cleanpage.py	Sun Mar 26 12:49:07 2006 +0000
@@ -0,0 +1,64 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - display unused or trash page directories in data/pages
+    
+    Then please review the output before running it!
+
+    @copyright: 2005-2006 by MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import os
+
+from MoinMoin.script._util import MoinScript
+
+class PluginScript(MoinScript):
+    def __init__(self, argv, def_values):
+        MoinScript.__init__(self, argv, def_values)
+    
+    def qualify(self, p):
+        """ look at page directory p and return its state """
+        dir = os.listdir(p)
+        if not dir:
+            return 'empty'
+
+        # check if we have something of potential value
+        revs = []
+        if 'revisions' in dir:
+            revs = os.listdir(os.path.join(p, 'revisions'))
+        atts = []
+        if 'attachments' in dir:
+            atts = os.listdir(os.path.join(p, 'attachments'))
+
+        if not revs and not atts:
+            return 'trash'
+        
+        if 'current-locked' in dir:
+            return 'current-locked'
+        elif 'current' in dir:
+            try:
+                current = open(os.path.join(p, 'current')).read().strip()
+                curr = int(current)
+            except:
+                return 'current damaged'
+            if current not in revs:
+                return 'deleted'
+        else:
+            return 'no current'
+
+        return 'ok'
+
+    def mainloop(self):
+        self.init_request()
+        base = self.request.cfg.data_dir
+        pagesdir = os.path.join(base, 'pages')
+        for p in os.listdir(pagesdir):
+            pagedir = os.path.join(pagesdir, p)
+            status = self.qualify(pagedir)
+            if status in ['trash', 'empty', ]:
+                print "mv '%s' trash # %s" % (pagedir,status)
+            elif status in ['deleted', ]:
+                print "mv '%s' deleted # %s" % (pagedir,status)
+            else:
+                print "# %s: '%s'" % (status, pagedir)
+
--- a/MoinMoin/script/old/pagescleaner.py	Sun Mar 26 12:38:33 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - display unused or trash page directories in data/pages
-    
-    Usage:
-    First change the base path to match your needs.
-    Then do ./pagescleaner.py >cleanthem.sh
-    Then please review cleanthem.sh and run it, if it is OK.
-
-    @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
-    @license: GNU GPL, see COPYING for details.
-"""
-
-import os
-
-base = "."
-pagebasedir = base + "/data/pages"
-
-def qualify(p):
-    dir = os.listdir(p)
-    if not dir:
-        return 'empty'
-
-    # check if we have something of potential value
-    revs = []
-    if 'revisions' in dir:
-        revs = os.listdir(os.path.join(p, 'revisions'))
-    atts = []
-    if 'attachments' in dir:
-        atts = os.listdir(os.path.join(p, 'attachments'))
-
-    if not revs and not atts:
-        return 'trash'
-    
-    if 'current-locked' in dir:
-        return 'current-locked'
-    elif 'current' in dir:
-        try:
-            current = open(os.path.join(p, 'current')).read().strip()
-            curr = int(current)
-        except:
-            return 'current damaged'
-        if current not in revs:
-            return 'deleted'
-    else:
-        return 'no current'
-
-    return 'ok'
-
-def run():
-    for p in os.listdir(pagebasedir):
-        pagedir = os.path.join(pagebasedir, p)
-        status = qualify(pagedir)
-        if status in ['trash', 'empty', ]:
-            print "mv '%s' trash # %s" % (pagedir,status)
-        elif status in ['deleted', ]:
-            print "mv '%s' deleted # %s" % (pagedir,status)
-        else:
-            print "# %s: '%s'" % (status, pagedir)
-
-if __name__ == "__main__":
-    run()
-
--- a/docs/CHANGES	Sun Mar 26 12:38:33 2006 +0000
+++ b/docs/CHANGES	Sun Mar 26 12:49:07 2006 +0000
@@ -112,6 +112,7 @@
       * moin ... account disable --name=JoeDoe
       * moin ... acount check     <-- this is what usercheck script was before
       * moin ... maint cleancache <-- this is what cachecleaner script was
+      * moin ... maint cleanpage  <-- this is what pagescleaner script was
 
   Bugfixes:
     * cookie_lifetime didn't work comfortable for low values. The cookie was
--- a/setup.py	Sun Mar 26 12:38:33 2006 +0000
+++ b/setup.py	Sun Mar 26 12:49:07 2006 +0000
@@ -208,6 +208,7 @@
         'MoinMoin.script',
         'MoinMoin.script.account',
         'MoinMoin.script.cli',
+        'MoinMoin.script.maint',
         'MoinMoin.script.migration',
         'MoinMoin.script.import',
         'MoinMoin.script.old',