CVS: tmda-cgi CgiVersion.py,NONE,1.1 Info.py,1.3,1.4 Install.py,1.8,1.9 configure,1.2,1.3 tmda-cgi.py,1.29,1.30 Version.py,1.18,NONE

Gre7g Luterman <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda-cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv3384

Modified Files:
	Info.py Install.py configure tmda-cgi.py 
Added Files:
	CgiVersion.py 
Removed Files:
	Version.py 
Log Message:
Renamed Version.py to CgiVersion.py to keep importer from grabbing the wrong
one.

Install now uses Util.RunTask instead of os.system to launch tar.  This keeps
it from reverting to RUID/RGID.

Simplified uninstall form processing a tad.  Put threshold codes in form so 
code doesn't have to generate them.

Fixed a bug where uninstall would hang if it had to delete messages. 
Mistakenly assumed that the Pending modules listPendingIds would return only
the pending IDs referred to by threshold.  It does not.  It returns them all.


--- NEW FILE ---
# -*- python -*-
#
# Copyright (C) 2001,2002 Jason R. Mastaler <[email protected]>
#
# This file is part of TMDA.
#
# TMDA is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  A copy of this license should
# be included in the file COPYING.
#
# TMDA is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with TMDA; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

"""Various versioning information."""

import sys
from TMDA import Version

# tmda-cgi version
tmda_cgi = "0.08+"

# tmda-cgi version codename
Codename = "Oxygen"

# TMDA version required
TMDAReqVer = "0.75"

# Python version
Python = sys.version.split()[0]

# Platform identifier
try:
    from distutils.util import get_platform
    Platform = get_platform()
except ImportError:
    Platform = sys.platform

# Summary of all the version identifiers
# e.g, tmda-cgi/0.02 (Python 2.2.2 on linux-i686)
All = "tmda-cgi/%s (Python %s on %s)" % (tmda_cgi, Python, Platform)

def Test():
  "Validate TMDAReqVer."
  if Version.TMDA < TMDAReqVer:
    raise ImportError, \
      "tmda-cgi/%s requires TMDA/%s or later.  TMDA/%s found." % \
      (tmda_cgi, TMDAReqVer, Version.TMDA)

Index: Info.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Info.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Info.py	7 May 2003 16:31:52 -0000	1.3
+++ Info.py	9 May 2003 05:04:59 -0000	1.4
@@ -24,7 +24,7 @@
 import os
 import re
 import Template
-from Version import All
+from CgiVersion import All
 from TMDA import Version
 
 # Search stuff

Index: Install.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Install.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Install.py	4 May 2003 04:56:28 -0000	1.8
+++ Install.py	9 May 2003 05:04:59 -0000	1.9
@@ -32,6 +32,7 @@
 import Template
 
 from TMDA import Errors
+from TMDA import Util
 
 PermSearch = re.compile("^([^#\s]\S*)\s+(\d+)")
 
@@ -101,12 +102,13 @@
         Files.append(NewFilename)
       else:
         Files.append(Filename)
-  TarCmd = "%s -C %s -czf %s %s" % (PVars[("NoOverride", "WhichTar")],
-    os.environ["HOME"], Archive, " ".join(Files))
-  RetVal = os.system(re.sub("([\(\)])", r"\\\1", TarCmd))
-  if RetVal:
-    CgiUtil.TermError("CreateTgz failed.", "Errcode: %D" % RetVal,
-      "create backup", re.sub("([\(\)])", r"\\\1", TarCmd),
+  TarCmd = [PVars[("NoOverride", "WhichTar")], "-C", os.environ["HOME"],
+    "-czf", Archive] + Files
+  try:
+    Util.RunTask(TarCmd)
+  except OSError:
+    CgiUtil.TermError("CreateTgz failed.", "Errcode: %d" % RetVal,
+      "create backup", " ".join(TarCmd),
       "Check file permissions in home directory.")
   for (DstFn, SrcFn) in Parents:
     os.rename(SrcFn, DstFn)
@@ -117,8 +119,9 @@
 
 def ReadTgz(Archive):
   "Return the files listed in an archive."
-  Files = os.popen("%s -C %s -tzf %s" % (PVars[("NoOverride", "WhichTar")],
-    os.environ["HOME"], Archive)).readlines()
+  TarCmd = [PVars[("NoOverride", "WhichTar")], "-C", os.environ["HOME"],
+    "-tzf", Archive]
+  Files = Util.RunTask(TarCmd)
   for i in range(len(Files)):
     Files[i] = Files[i].strip()
   return Files
@@ -128,8 +131,11 @@
 
 Return file list on success, None on error."""
 
-  if os.system("%s -C %s -xzf %s" % (PVars[("NoOverride", "WhichTar")],
-    os.environ["HOME"], Archive)):
+  TarCmd = [PVars[("NoOverride", "WhichTar")], "-C", os.environ["HOME"],
+    "-xzf", Archive]
+  try:
+    Util.RunTask(TarCmd)
+  except OSError:
     return None
   Files = ReadTgz(Archive)
   for i in range(len(Files)):
@@ -315,7 +321,8 @@
 
   # What files do we need to uninstall?
   InstallDir = os.path.join(os.getcwd(), "skel", "install")
-  RemoveFiles = FindFiles("", InstallDir)
+  Files = FindFiles("", InstallDir)
+  RemoveFiles = FindExisting(Files, os.environ["HOME"])
   for i in range(len(RemoveFiles)):
     RemoveFiles[i] = RemoveFiles[i] % Dict
 
@@ -410,32 +417,25 @@
   print T
   sys.exit()
 
-def ReleaseAndDelete(Days):
-  """Release all messages younger than given days old.  Delete rest.
-
-Don't release anything if Days=0, release them all if Days=-1."""
+def ReleaseAndDelete(Threshold):
+  "Release all messages younger than given amount.  Delete rest."
 
   from TMDA import Defaults
   from TMDA import Pending
 
   # Release
-  if Days:
-    if Days == -1:
-      Threshold = None
-      Younger   = None
-    else:
-      Threshold = "%dd" % Days
-      Younger   = 1
-    Pending.Queue(dispose = "release", threshold = Threshold, younger =
-      Younger, verbose = 0).initQueue().mainLoop()
+  Pending.Queue(dispose = "release", threshold = Threshold, younger = 1,
+    verbose = 0).initQueue().mainLoop()
 
   # Wait for messages to release...
   while 1:
     time.sleep(1)
-    Queue = Pending.Queue(threshold = Threshold, younger = Younger)
+    Queue = Pending.Queue(threshold = Threshold, younger = 1)
     Queue.initQueue()
-    if len(Queue.listPendingIds()) == 0:
-      break
+    Msgs = 0
+    for MsgID in Queue.listPendingIds():
+      Msgs += Queue.checkTreshold(MsgID)
+    if not Msgs: break
 
   # Delete
   Pending.Queue(dispose = "delete", verbose = 0).initQueue().mainLoop()
@@ -558,7 +558,7 @@
         "", "Contact system administrator.")
     if Form.has_key("subcmd"):
       try:
-        ReleaseAndDelete(int(Form["release"].value))
+        ReleaseAndDelete(Form["release"].value)
       except Errors.QueueError:
         pass
       Uninstall()  # Does not return.
@@ -568,8 +568,9 @@
     TemplateFN = "welcome.html"
   else:
     # Have they installed before?
-    if os.access(os.path.join(os.environ["HOME"],
-      PVars[("NoOverride", "UninstallBackupTGZ")]), os.R_OK):
+    if Util.CanRead(os.path.join(os.environ["HOME"],
+      PVars[("NoOverride", "UninstallBackupTGZ")]),
+      os.geteuid(), os.getegid()):
       TemplateFN = "re-enroll.html"
     else:
       TemplateFN = "welcome.html"

Index: configure
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/configure,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- configure	4 May 2003 23:56:58 -0000	1.2
+++ configure	9 May 2003 05:04:59 -0000	1.3
@@ -381,8 +381,8 @@
 # Check for a compatible version of TMDA
 sys.path.insert(0, OptD["Base"])
 try:
-  import Version
-  Version.Test()
+  import CgiVersion
+  CgiVersion.Test()
 except ImportError, ErrStr:
   print ErrStr
   sys.exit()

Index: tmda-cgi.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/tmda-cgi.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- tmda-cgi.py	6 May 2003 23:19:37 -0000	1.29
+++ tmda-cgi.py	9 May 2003 05:04:59 -0000	1.30
@@ -68,8 +68,8 @@
 
 # Check version information
 try:
-  import Version
-  Version.Test()
+  import CgiVersion
+  CgiVersion.Test()
 except ImportError, ErrStr:
   CgiUtil.TermError("Failed to import TMDA module.", ErrStr, "import TMDA", "",
     "Upgrade to the most recent release of TMDA.")

--- Version.py DELETED ---

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.