diff mxtool/mx.py @ 14539:47b775458982

Merged
author Christian Wirth <christian.wirth@oracle.com>
date Fri, 14 Mar 2014 09:58:31 +0100
parents 5454f6bf50bf 7c36ec150036
children 6fb61ad67962
line wrap: on
line diff
--- a/mxtool/mx.py	Wed Mar 12 11:23:56 2014 +0100
+++ b/mxtool/mx.py	Fri Mar 14 09:58:31 2014 +0100
@@ -349,29 +349,34 @@
 
     def _sha1Cached():
         with open(sha1path, 'r') as f:
-            return f.readline()[0:40]
-
-    def _writesha1Cached():
+            return f.read()[0:40]
+
+    def _writeSha1Cached():
         with open(sha1path, 'w') as f:
             f.write(_sha1OfFile())
 
     def _sha1OfFile():
         with open(path, 'rb') as f:
-            return hashlib.sha1(f.read()).hexdigest()
-
+            d = hashlib.sha1()
+            while True:
+                buf = f.read(4096)
+                if not buf:
+                    break
+                d.update(buf)
+            return d.hexdigest()
 
     if resolve and mustExist and not exists(path):
         assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path
         _download_lib()
 
     if sha1 and not exists(sha1path):
-        _writesha1Cached()
+        _writeSha1Cached()
 
     if sha1 and sha1 != _sha1Cached():
         _download_lib()
         if sha1 != _sha1OfFile():
             abort("SHA1 does not match for " + name + ". Broken download? SHA1 not updated in projects file?")
-        _writesha1Cached()
+        _writeSha1Cached()
 
     return path
 
@@ -427,7 +432,7 @@
             path = join(self.suite.dir, path)
         sha1path = path + '.sha1'
 
-        return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True)
+        return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True)
 
     def append_to_classpath(self, cp, resolve):
         path = self.get_path(resolve)
@@ -1093,7 +1098,7 @@
 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, addDefaultArgs=True):
     return run(java().format_cmd(args, addDefaultArgs), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
 
-def _kill_process_group(pid, sig=None):
+def _kill_process_group(pid, sig):
     if not sig:
         sig = signal.SIGKILL
     pgid = os.getpgid(pid)
@@ -1273,6 +1278,8 @@
         self.restrictTo = restrictTo
         self.seen = set()
         self.out = out
+        self.currentFilteredLineCount = 0
+        self.currentFilteredTime = None
 
     def isSuppressionCandidate(self, line):
         if self.restrictTo:
@@ -1286,9 +1293,18 @@
     def write(self, line):
         if self.isSuppressionCandidate(line):
             if line in self.seen:
+                self.currentFilteredLineCount += 1
+                if self.currentFilteredTime:
+                    if time.time() - self.currentFilteredTime > 1 * 60:
+                        self.out.write("  Filtered " + str(self.currentFilteredLineCount) + " repeated lines...\n")
+                        self.currentFilteredTime = time.time()
+                else:
+                    self.currentFilteredTime = time.time()
                 return
             self.seen.add(line)
+        self.currentFilteredLineCount = 0
         self.out.write(line)
+        self.currentFilteredTime = None
 
 """
 A JavaCompliance simplifies comparing Java compliance values extracted from a JDK version string.
@@ -1471,7 +1487,7 @@
 
     def _isJava():
         if args:
-            name = args[0].split("/")[-1]
+            name = args[0].split(os.sep)[-1]
             return name == "java"
         return False
 
@@ -1500,7 +1516,7 @@
         if get_os() == 'windows':
             p.kill()
         else:
-            _kill_process_group(p.pid)
+            _kill_process_group(p.pid, signal.SIGKILL)
 
     raise SystemExit(codeOrMessage)