[PATCH] add remove-from-journal script

Martin Dengler martinatmartindengler.com
Sun Oct 26 16:18:24 EDT 2008


---
 remove-from-journal |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100755 remove-from-journal

diff --git a/remove-from-journal b/remove-from-journal
new file mode 100755
index 0000000..42064b3
--- /dev/null
+++ b/remove-from-journal
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+#####
+#
+# Copyright (c) 2008 Martin Dengler
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+#####
+import optparse
+import os
+import sys
+
+from sugar.datastore import datastore
+
+# Set up things so that this script can run in a terminal.
+if 'DBUS_SESSION_BUS_ADDRESS' not in os.environ:
+    os.environ['DBUS_SESSION_BUS_ADDRESS'] = 'unix:path=/tmp/olpc-session-bus'
+if 'DISPLAY' not in os.environ:
+    os.environ['DISPLAY'] = ':0.0'
+
+parser = optparse.OptionParser(usage="%prog [--delete]\n\n"
+                               " expects a list of uids on standard input,"
+                               " one per line")
+parser.add_option("--delete", action="store_true", default=False,
+                  help="DELETE the matches - WARNING WILL LOSE DATA")
+options, args = parser.parse_args()
+
+for uid in sys.stdin:
+    uid = uid.strip()
+    if options.delete:
+        datastore.delete(uid)
+            
-- 
1.5.5.1




More information about the Sugar-devel mailing list