Mercurial > p > roundup > code
comparison roundup/admin.py @ 562:62febbd7ffec
You can now use the roundup-admin tool to pack the database
| author | Roche Compaan <rochecompaan@users.sourceforge.net> |
|---|---|
| date | Mon, 21 Jan 2002 16:33:20 +0000 |
| parents | 1401596be460 |
| children | 2fc4f8942a59 |
comparison
equal
deleted
inserted
replaced
| 561:13df980755fa | 562:62febbd7ffec |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 # | 18 # |
| 19 # $Id: admin.py,v 1.4 2002-01-14 06:51:09 richard Exp $ | 19 # $Id: admin.py,v 1.5 2002-01-21 16:33:19 rochecompaan Exp $ |
| 20 | 20 |
| 21 import sys, os, getpass, getopt, re, UserDict, shlex | 21 import sys, os, getpass, getopt, re, UserDict, shlex |
| 22 try: | 22 try: |
| 23 import csv | 23 import csv |
| 24 except ImportError: | 24 except ImportError: |
| 855 | 855 |
| 856 # and create the new node | 856 # and create the new node |
| 857 apply(cl.create, (), d) | 857 apply(cl.create, (), d) |
| 858 return 0 | 858 return 0 |
| 859 | 859 |
| 860 def do_pack(self, args): | |
| 861 '''Usage: pack period | date | |
| 862 | |
| 863 Remove journal entries older than a period of time specified or | |
| 864 before a certain date. | |
| 865 | |
| 866 A period is specified using the suffixes "y", "m", and "d". The | |
| 867 suffix "w" (for "week") means 7 days. | |
| 868 | |
| 869 "3y" means three years | |
| 870 "2y 1m" means two years and one month | |
| 871 "1m 25d" means one month and 25 days | |
| 872 "2w 3d" means two weeks and three days | |
| 873 | |
| 874 Date format is "YYYY-MM-DD" eg: | |
| 875 2001-01-01 | |
| 876 | |
| 877 ''' | |
| 878 if len(args) <> 1: | |
| 879 raise UsageError, _('Not enough arguments supplied') | |
| 880 | |
| 881 # are we dealing with a period or a date | |
| 882 value = args[0] | |
| 883 date_re = re.compile(r''' | |
| 884 (?P<date>\d\d\d\d-\d\d?-\d\d?)? # yyyy-mm-dd | |
| 885 (?P<period>(\d+y\s*)?(\d+m\s*)?(\d+d\s*)?)? | |
| 886 ''', re.VERBOSE) | |
| 887 m = date_re.match(value) | |
| 888 if not m: | |
| 889 raise ValueError, _('Invalid format') | |
| 890 m = m.groupdict() | |
| 891 if m['period']: | |
| 892 # TODO: need to fix date module. one should be able to say | |
| 893 # pack_before = date.Date(". - %s"%value) | |
| 894 pack_before = date.Date(".") + date.Interval("- %s"%value) | |
| 895 elif m['date']: | |
| 896 pack_before = date.Date(value) | |
| 897 self.db.pack(pack_before) | |
| 898 return 0 | |
| 899 | |
| 860 def run_command(self, args): | 900 def run_command(self, args): |
| 861 '''Run a single command | 901 '''Run a single command |
| 862 ''' | 902 ''' |
| 863 command = args[0] | 903 command = args[0] |
| 864 | 904 |
| 993 tool = AdminTool() | 1033 tool = AdminTool() |
| 994 sys.exit(tool.main()) | 1034 sys.exit(tool.main()) |
| 995 | 1035 |
| 996 # | 1036 # |
| 997 # $Log: not supported by cvs2svn $ | 1037 # $Log: not supported by cvs2svn $ |
| 1038 # Revision 1.4 2002/01/14 06:51:09 richard | |
| 1039 # . #503164 ] create and passwords | |
| 1040 # | |
| 998 # Revision 1.3 2002/01/08 05:26:32 rochecompaan | 1041 # Revision 1.3 2002/01/08 05:26:32 rochecompaan |
| 999 # Missing "self" in props_from_args | 1042 # Missing "self" in props_from_args |
| 1000 # | 1043 # |
| 1001 # Revision 1.2 2002/01/07 10:41:44 richard | 1044 # Revision 1.2 2002/01/07 10:41:44 richard |
| 1002 # #500140 ] AdminTool.get_class() returns nothing | 1045 # #500140 ] AdminTool.get_class() returns nothing |
