]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
- test-move catches exception from mark4moving
authorMariusz Mazur <mmazur@pld-linux.org>
Wed, 11 May 2005 12:29:44 +0000 (12:29 +0000)
committerMariusz Mazur <mmazur@pld-linux.org>
Wed, 11 May 2005 12:29:44 +0000 (12:29 +0000)
- when moving/trying to move a package that hasn't been built for all available
  archs -- warn (don't bail out)
- unified and made errors/warnings more legible

Changed files:
    bin/pfa-testmvpkg -> 1.5
    modules/ftptree.py -> 1.15

bin/pfa-testmvpkg
modules/ftptree.py

index 9914c9dd23fa7f59934dd654098abcad1ebc7393..acd1667a2d826c235d59d337c9b818e361f7336a 100755 (executable)
@@ -3,7 +3,7 @@
 
 import sys, os
 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-from ftptree import FtpTree
+import ftptree
 from common import checkdir
 import ftpio
 
@@ -26,11 +26,17 @@ if not ftpio.lock(sys.argv[2], True):
     print "%s tree already locked" % sys.argv[2]
     sys.exit(1)
 
-# We don't 'try' as in move.py cause these functions don't force exit
-srctree=FtpTree(sys.argv[1], loadall=True)
-dsttree=FtpTree(sys.argv[2])
-srctree.mark4moving(sys.argv[3:])
+try:
+    srctree=ftptree.FtpTree(sys.argv[1], loadall=True)
+    dsttree=ftptree.FtpTree(sys.argv[2])
+    srctree.mark4moving(sys.argv[3:])
+except ftptree.SomeError:
+    # In case of problems we need to unlock the trees before exiting
+    ftpio.unlock(sys.argv[1])
+    ftpio.unlock(sys.argv[2])
+    sys.exit(1)
 
+# We don't 'try' as in move.py cause this function doesn't force exit
 srctree.testmove(dsttree)
 
 ftpio.unlock(sys.argv[1])
index 8b95da8eed06555b2a2c20ab792fbb78df83c102..27ccb53c06ff380599aca4619d7a7914e77c4912 100644 (file)
@@ -18,10 +18,10 @@ def pinfo(msg):
 def perror(msg):
     global errnum
     errnum=errnum+1
-    print msg
+    print 'ERR: ' + msg
 
 def pwarning(msg):
-    print msg
+    print 'WARN: ' + msg
 
 def rm(file):
     os.remove(file)
@@ -183,7 +183,7 @@ class FtpTree(BaseFtpTree):
                     self.loadedpkgs[pkgname]=Pkg(pkgname, self)
                 markfunction(self.loadedpkgs[pkgname])
             else:
-                perror(pkgname+" was not found in source tree")
+                perror('%s not found in source tree' % pkgname)
         bailoutonerror()
 
     def __checkbuild(self):
@@ -202,12 +202,12 @@ class FtpTree(BaseFtpTree):
         for pkg in self.marked4moving:
             for bid in pkg.build.keys():
                 if requests.has_key(bid) and not requests[bid].find('?') == -1:
-                    perror("Building of package %s (buildid %s) not finished" % (pkg,bid))
+                    perror("%s (buildid %s) building not finished" % (pkg,bid))
 
     def __checkarchs(self, dsttree):
         for pkg in self.marked4moving:
             if len(pkg.files.keys()) <= 1:
-                perror('Package %s has only src.rpm built' % pkg)
+                perror('%s has only src.rpm built' % pkg)
                 continue
             otherpkgnames=self.__find_other_pkgs(pkg, dsttree)
             if otherpkgnames: # check if we're not removing some archs
@@ -219,10 +219,19 @@ class FtpTree(BaseFtpTree):
                     if arch not in pkg.files.keys():
                         missingarchs.append(arch)
                 if missingarchs:
-                    perror('Moving %s would remove archs: %s' %
+                    perror('%s moving would remove archs: %s' %
                                                             (pkg, missingarchs))
             else: # warn if a package isn't built for all archs
-                pass
+                if (config.separate_noarch and 'noarch' in pkg.files.keys() and
+                                    len(pkg.files.keys())==2):
+                    continue
+                elif len(pkg.files.keys()) != len(config.ftp_archs):
+                    missingarchs=[]
+                    for arch in config.ftp_archs:
+                        if arch not in pkg.files.keys():
+                            missingarchs.append(arch)
+                    pwarning('%s not built for archs: %s' %
+                                                            (pkg, missingarchs))
 
     def __rmolderfromsrc(self):
         for pkg in self.marked4moving:
This page took 0.039084 seconds and 4 git commands to generate.