[csw-devel] SF.net SVN: gar:[8196] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Jan 27 11:28:00 CET 2010


Revision: 8196
          http://gar.svn.sourceforge.net/gar/?rev=8196&view=rev
Author:   wahwah
Date:     2010-01-27 10:27:59 +0000 (Wed, 27 Jan 2010)

Log Message:
-----------
mGAR v2: a little bit of cleanup based on pychecker's output

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/checkpkg.py
    csw/mgar/gar/v2/lib/python/gartest.py
    csw/mgar/gar/v2/lib/python/opencsw.py

Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py	2010-01-27 09:44:52 UTC (rev 8195)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-01-27 10:27:59 UTC (rev 8196)
@@ -12,7 +12,6 @@
 import socket
 import sqlite3
 import subprocess
-import StringIO
 from Cheetah import Template
 import opencsw
 
@@ -191,7 +190,7 @@
       logging.debug("Connecting to the %s database.", self.db_path)
       self.conn = sqlite3.connect(self.db_path)
       if not self.IsDatabaseUpToDate():
-      	logging.warning("Rebuilding the package cache, can take a few minutes.")
+        logging.warning("Rebuilding the package cache, can take a few minutes.")
         self.PurgeDatabase()
         self.PopulateDatabase()
     else:
@@ -471,14 +470,13 @@
   for runpath in runpath_list:
     for symlink, expansion_list in SYSTEM_SYMLINKS:
       for target in expansion_list:
-      	expanded = ExpandSymlink(symlink, target, runpath)
+        expanded = ExpandSymlink(symlink, target, runpath)
         if expanded not in symlinked_list:
-        	symlinked_list.append(expanded)
+          symlinked_list.append(expanded)
   return symlinked_list
 
 
 def SanitizeRunpath(runpath):
-  ok = False
   while True:
     if runpath.endswith("/"):
       runpath = runpath[:-1]
@@ -507,7 +505,7 @@
       # RPATH does not contain $ISALIST.
       new_soname_runpath_data = {}
       for p in soname_runpath_data:
-      	expanded_p_list = Emulate64BitSymlinks([p])
+        expanded_p_list = Emulate64BitSymlinks([p])
         for expanded_p in expanded_p_list:
           new_soname_runpath_data[expanded_p] = soname_runpath_data[p]
       soname_runpath_data = new_soname_runpath_data
@@ -599,14 +597,14 @@
     packages = []
     errors = []
     for pkgname in self.pkgname_list:
-    	pkg_path = os.path.join(self.extractdir, pkgname)
-    	packages.append(opencsw.DirectoryFormatPackage(pkg_path))
+        pkg_path = os.path.join(self.extractdir, pkgname)
+        packages.append(opencsw.DirectoryFormatPackage(pkg_path))
     for pkg in packages:
       for function in self.individual_checks:
-      	errors.extend(function(pkg))
+        errors.extend(function(pkg))
     # Set checks
     for function in self.set_checks:
-    	errors.extend(function(packages))
+        errors.extend(function(packages))
     namespace = {
         "name": self.name,
         "errors": errors,

Modified: csw/mgar/gar/v2/lib/python/gartest.py
===================================================================
--- csw/mgar/gar/v2/lib/python/gartest.py	2010-01-27 09:44:52 UTC (rev 8195)
+++ csw/mgar/gar/v2/lib/python/gartest.py	2010-01-27 10:27:59 UTC (rev 8196)
@@ -6,11 +6,9 @@
 import Cheetah.Template
 import shutil
 import tempfile
-import unittest
 import os
 import os.path
 import subprocess
-import sys
 import opencsw
 
 """A module used to do end-to-end testing of GAR."""
@@ -45,10 +43,11 @@
 
 class GarBuild(object):
 
-  def __init__(self):
+  def __init__(self, build_dir):
     self.built = False
     self.packages = None
     self.cleanup = True
+    self.build_dir = build_dir
 
   def GetDebugHelp(self):
     """To be overriden in subclasses."""
@@ -83,7 +82,7 @@
     args = ["gmake", "pkglist"]
     gar_proc = subprocess.Popen(args, cwd=self.build_dir, stdout=subprocess.PIPE)
     stdout, stderr = gar_proc.communicate()
-    ret = gar_proc.wait()
+    unused_ret = gar_proc.wait()
     pkglist = []
     for line in stdout.splitlines():
       # directory, catalogname, pkgname
@@ -107,8 +106,8 @@
   Can create a GAR build and execute it.
   """
   def __init__(self):
-    super(DynamicGarBuild, self).__init__()
-    self.build_dir = tempfile.mkdtemp(prefix=TMPDIR_PREFIX)
+    build_dir = tempfile.mkdtemp(prefix=TMPDIR_PREFIX)
+    super(DynamicGarBuild, self).__init__(build_dir)
     self.filedir = os.path.join(self.build_dir, "files")
     self.makefile_filename = os.path.join(self.build_dir, "Makefile")
     os.mkdir(self.filedir)
@@ -175,11 +174,10 @@
 class StaticGarBuild(GarBuild):
 
   def __init__(self, build_dir):
-    super(StaticGarBuild, self).__init__()
-    self.build_dir = build_dir
+    super(StaticGarBuild, self).__init__(build_dir)
 
   def __del__(self):
     if self.cleanup:
-    	shutil.rmtree(os.path.join(self.build_dir, "work"))
+      shutil.rmtree(os.path.join(self.build_dir, "work"))
 
 # vim:set ts=2 sts=2 sw=2 expandtab:

Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py	2010-01-27 09:44:52 UTC (rev 8195)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-01-27 10:27:59 UTC (rev 8196)
@@ -372,7 +372,7 @@
         shutil.copy(self.pkg_path, self.GetWorkDir())
         self.pkg_path = os.path.join(self.GetWorkDir(), base_name_gz)
         args = ["gunzip", "-f", self.pkg_path]
-        retcode = self.ShellCommand(args)
+        unused_retcode = self.ShellCommand(args)
         self.gunzipped_path = self.pkg_path[:(-len(gzip_suffix))]
       elif self.pkg_path.endswith(pkg_suffix):
         self.gunzipped_path = self.pkg_path
@@ -385,7 +385,7 @@
     if not self.transformed:
       args = ["pkgtrans", "-a", self.GetAdminFilePath(),
               self.GetGunzippedPath(), self.GetWorkDir(), "all"]
-      retcode = self.ShellCommand(args, quiet=True)
+      unused_retcode = self.ShellCommand(args, quiet=True)
       dirs = self.GetDirs()
       if len(dirs) != 1:
         raise Error("Need exactly one package in the package stream: "
@@ -394,7 +394,7 @@
       self.transformed = True
 
   def GetDirFormatPkg(self):
-    self.TransformToDir(self)
+    self.TransformToDir()
     return self.dir_format_pkg
 
   def GetDirs(self):
@@ -578,9 +578,9 @@
         sum_process = subprocess.Popen(args, stdout=subprocess.PIPE)
         stdout, stderr = sum_process.communicate()
         sum_process.wait()
-        sum = ws_re.split(stdout)[0]
+        sum_value = ws_re.split(stdout)[0]
         fields[3] = size
-        fields[4] = sum
+        fields[4] = sum_value
         logging.debug("New pkgmap line: %s", fields)
         line = " ".join(fields)
       new_pkgmap_lines.append(line.strip())


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list