Commits

Armin Rigo committed c3561f3

Various minor updates.

  • Participants
  • Parent commits b27f96d

Comments (0)

Files changed (6)

hack/bin/alsacapture

 # Capture the audio player by any program on Linux.  This creates a dump
 # of all the sounds sent to the audio card in raw format.
 #
-# Usage: alsacapture programname args...
+# Usage: alsacapture [programname args...]
 #
 # This will install sound capture, run the given program, and stop
 # capturing when the program finishes.  Note that all sounds sent to
 # the sound card are captured, not just the ones produced by the given
-# program.
+# program (but ALSA must receive an open-device command while this is
+# running).
 
 DUMPFILE=/dev/shm/out.raw
 
 EOF
 echo "ALSA sound capture enabled"
 
-"$@"
+if [ "$1" == "" ]; then
+    echo "Press Enter to quit..."
+    read
+else
+    "$@"
+fi
 
 rm ~/.asoundrc
 echo "ALSA sound capture disabled"

hack/bin/atomic_rm.py

 
 def remove_trailing_slash(fn):
     if len(fn) > 1 and fn.endswith('/') and not fn.endswith('//'):
-        fn = fn[:-1]
+        if os.path.isdir(fn):   # or a symlink to a dir
+            fn = fn[:-1]
     return fn
 
 
             if not ('0' <= c <= '9' or 'a' <= c <= 'f'):
                 return r
         print >> sys.stderr, '%s ->' % (r,),
-        g = os.popen("hg log --template '{node}\n' | grep -e ^%s"
+        g = os.popen("hg log --template '{node} ({date|shortdate})\n' | grep -e ^%s"
                      % (r,), "r")
         data = g.readline().strip()
         g.close()
         print >> sys.stderr, data
         assert data
-        return data
+        return data.split()[0]
 
     r2, _, r1 = argv[-3:]
     r2 = expand_rev(r2)
          'cobra':  'cobra.cs.uni-duesseldorf.de',
          'tannit': '83.140.78.199',
          's-tannit': '83.140.78.199',
+         's-speed': 'speed.python.org',
          }
 DELAYS = {'tuatara': 25,
           'bigdog-vm1': 25,
           'bigdog6': 25,
           'minime': 25,
           's-tannit': 25,
+          's-speed': 25,
           'mvt': 25,
           }
 FORWARDS = {'bigdog2': 19150,

hack/pypeers/bittorrent/checktorrent.py

             name = os.path.join(dir, name)
             self.files[file_index] = name, total
 
-    def search_dir(self, basedir, filestart=0, filestop=None):
-        import stat
+    def search_dir(self, basedir, filestart=0, filestop=None,
+                   best_effort=False):
         if filestop is None:
             filestop = len(self.files)
         assert 0 <= filestart < filestop <= len(self.files)
-        for file_index in range(filestart, filestop):
-            name, _ = self.files[file_index]
+        results = []
+        self._search_dirs(basedir, results)
+        for basedir, files_found in results:
+            files_found[:] = [i for i in files_found
+                                if filestart <= i < filestop]
+        results.sort(key=lambda (basedir, files_found): len(files_found))
+        resultdir, files_found = results[-1]
+        if best_effort:
+            minimum = 1
+        else:
+            minimum = filestop - filestart
+        if len(files_found) < minimum:
+            return False
+        else:
+            self.change_dir(resultdir)
+            return True
+
+    def _search_dirs(self, basedir, results):
+        import stat
+        files_found = []
+        for i, (name, _) in enumerate(self.files):
             name = os.path.join(basedir, name)
-            if not os.path.exists(name) and not os.path.exists(name + '.part'):
-                break
-        else:
-            self.change_dir(basedir)
-            return True
+            if os.path.exists(name) or os.path.exists(name + '.part'):
+                files_found.append(i)
+        results.append((basedir, files_found))
         for subdir in os.listdir(basedir):
             subdir = os.path.join(basedir, subdir)
             if stat.S_ISDIR(os.lstat(subdir).st_mode):
-                found = self.search_dir(subdir, filestart, filestop)
-                if found:
-                    return True
-        return False
+                self._search_dirs(subdir, results)
 
     def get_digest(self, n):
         return self.pieces_sha[n*20:(n+1)*20]

hack/pypy-hack/irclog.py

     dump_file(g, width=width)
     g.close()
 
-def dump_file(g, width=None):
+def dump_file(g, width=None, timestamps=True):
     if width is None:
         width = terminal_width() - 2
     for line in g:
         try:
-            word1, word2, rest = line.split(' ', 2)
+            if timestamps:
+                word1, word2, rest = line.split(' ', 2)
+            else:
+                word1 = ''
+                word2, rest = line.split(' ', 1)
         except ValueError:
             print line.rstrip()
             continue
             rest = rest.replace('\n', '\x1b[0m\n\x1b[%sm' % (color,))
         word2 = '\x1b[%sm%s' % (color, word2)
         word2 = '\x1b[1m%s\x1b[0m' % word2
-        print '%s %s %s' % (word1, word2, rest)
+        if timestamps:
+            print '%s %s %s' % (word1, word2, rest)
+        else:
+            print '%s> %s' % (word2, rest)
 
 def parse_date(args):
     year, month, day = time.localtime()[:3]
 
 if __name__ == '__main__':
     args = sys.argv[1:]
+    if args and args[0] == '--file':
+        dump_file(open(args[1]), timestamps=False)
+        raise SystemExit
     if args and not args[0].isdigit():
         channel = args.pop(0)
     else: