From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-commits+bounces-362102-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1QgknN-0002Qf-EB
	for garchives@archives.gentoo.org; Tue, 12 Jul 2011 21:47:09 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 25B5321C173;
	Tue, 12 Jul 2011 21:45:27 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id D592C21C173
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Jul 2011 21:45:26 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 26BFE2AC059
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Jul 2011 21:45:26 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 090578003E
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Jul 2011 21:45:25 +0000 (UTC)
From: "Paul Varner" <fuzzyray@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Paul Varner" <fuzzyray@gentoo.org>
Message-ID: <a6964c2141e4cc95760a29b4a471a31d25dacb53.fuzzyray@gentoo>
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
X-VCS-Repository: proj/gentoolkit
X-VCS-Files: pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
X-VCS-Directories: pym/gentoolkit/revdep_rebuild/
X-VCS-Committer: fuzzyray
X-VCS-Committer-Name: Paul Varner
X-VCS-Revision: a6964c2141e4cc95760a29b4a471a31d25dacb53
Date: Tue, 12 Jul 2011 21:45:25 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: b977aadf6045e7c33bd6934856ab8bd0

commit:     a6964c2141e4cc95760a29b4a471a31d25dacb53
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Fri Jan  7 05:46:19 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoolkit.gi=
t;a=3Dcommit;h=3Da6964c21

Fixed error in reading cache. Fixed problem with too many files to check.

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   51 +++++++++++++++--=
------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoo=
lkit/revdep_rebuild/revdep-rebuild.py
index ebc0c3b..ac2a6c8 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -25,7 +25,7 @@ from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
=20
 APP_NAME =3D sys.argv[0]
-VERSION =3D '0.1-r3'
+VERSION =3D '0.1-r4'
=20
=20
 __productname__ =3D "revdep-ng"
@@ -51,6 +51,7 @@ IS_DEV =3D True       #True for dev. version, False for=
 stable
 # can be set True from the cli with the --no-pretend option
 NO_PRETEND =3D False=20
=20
+CMD_MAX_ARGS =3D 1000 # number of maximum allowed files to be parsed at =
once
=20
=20
 # util. functions
@@ -62,6 +63,22 @@ def call_program(args):
     return stdout
=20
=20
+def scan(params, files):
+    ''' Calls scanelf with given params and files to scan.
+        @param params is list of parameters that should be passed into s=
canelf app.
+        @param files list of files to scan.
+
+        When files count is greater CMD_MAX_ARGS, it'll be divided
+        into several parts
+
+        @return scanelf output (joined if was called several times)
+    '''
+    out =3D []
+    for i in range(0, len(files), CMD_MAX_ARGS):
+        out +=3D call_program(['scanelf'] + params + files[i:i+CMD_MAX_A=
RGS]).strip().split('\n')
+    return out
+
+
 def print_v(verbosity, args):
     """Prints to stdout according to the verbosity level=20
     and the global VERBOSITY level
@@ -75,10 +92,6 @@ def print_v(verbosity, args):
=20
=20
 def exithandler(signum, frame):
-    print 'Signal caught!'
-    print 'Bye!'
-    signal.signal(signal.SIGINT, signal.SIG_IGN)
-    signal.signal(signal.SIGTERM, signal.SIG_IGN)
     sys.exit(1)
=20
=20
@@ -350,7 +363,8 @@ def prepare_checks(files_to_check, libraries, bits):
     dependencies =3D [] # list of lists of files (from file_to_check) th=
at uses
                       # library (for dependencies[id] and libs[id] =3D> =
id=3D=3Did)
=20
-    for line in call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n=
',]+files_to_check).strip().split('\n'):
+    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check)=
:
+    #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_t=
o_check).strip().split('\n'):
         r =3D line.strip().split(' ')
         if len(r) < 2: # no dependencies?
             continue
@@ -463,7 +477,7 @@ def assign_packages(broken, output):
                                     if found not in assigned:
                                         assigned.add(found)
                                     print_v(1, '\t' + m + ' -> ' + bold(=
found))
-                except:
+                except Exception as e:
                     output(1, red(' !! Failed to read ' + f))
=20
     return assigned
@@ -544,7 +558,7 @@ def read_cache(temp_path=3DDEFAULT_TMP_DIR):
     return (ret['libraries'], ret['la_libraries'], ret['libraries_links'=
], ret['binaries'])
=20
=20
-def save_cache(to_save, temp_path=3DDEFAULT_TMP_DIR):
+def save_cache(output=3Dprint_v, to_save=3D{}, temp_path=3DDEFAULT_TMP_D=
IR):
     ''' Tries to store caching information.
         @param to_save have to be dict with keys: libraries, la_librarie=
s, libraries_links and binaries
     '''
@@ -552,16 +566,18 @@ def save_cache(to_save, temp_path=3DDEFAULT_TMP_DIR=
):
     if not os.path.exists(temp_path):
         os.makedirs(temp_path)
=20
-    f =3D open(os.path.join(temp_path, 'timestamp'), 'w')
-    f.write(str(int(time.time())))
-    f.close()
-
-    for key,val in to_save.iteritems():
-        f =3D open(os.path.join(temp_path, key), 'w')
-        for line in val:
-            f.write(line + '\n')
+    try:
+        f =3D open(os.path.join(temp_path, 'timestamp'), 'w')
+        f.write(str(int(time.time())))
         f.close()
=20
+        for key,val in to_save.iteritems():
+            f =3D open(os.path.join(temp_path, key), 'w')
+            for line in val:
+                f.write(line + '\n')
+            f.close()
+    except Exception as ex:
+        output(1, red('Could not save cache %s' %str(ex)))
=20
 def analyse(output=3Dprint_v, libraries=3DNone, la_libraries=3DNone, lib=
raries_links=3DNone, binaries=3DNone):
     """Main program body.  It will collect all info and determine the
@@ -616,7 +632,8 @@ def analyse(output=3Dprint_v, libraries=3DNone, la_li=
braries=3DNone, libraries_links=3DN
=20
     for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
         bits =3D int(av_bits[4:])
-        _libraries =3D call_program(['scanelf', '-M', str(bits), '-BF', =
'%F',] + libraries+libraries_links).strip().split('\n')
+        _libraries =3D scan(['-M', str(bits), '-BF', '%F'], libraries+li=
braries_links)
+        #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libra=
ries+libraries_links).strip().split('\n')
=20
         found_libs, dependencies =3D prepare_checks(libs_and_bins, _libr=
aries, bits)
=20