# HG changeset patch # User cat@eee # Date 1266783922 18000 # Node ID 32b9137577b8778266d7ed7dd94ee6eb789230e4 # Parent 6cc12ad6e61683393a1a0409e19ee6eb7b259921 avoiding 'str doesn't support the buffer api' exception diff -r 6cc12ad6e616 -r 32b9137577b8 cmd2.py --- a/cmd2.py Sat Feb 20 09:26:33 2010 -0500 +++ b/cmd2.py Sun Feb 21 15:25:22 2010 -0500 @@ -1438,7 +1438,10 @@ self.trap.seek(0) result = self.trap.read() self.trap.truncate(0) - return result.strip('\x00') + try: + return result.strip('\x00') #TODO: understand this + except TypeError: + return result def tearDown(self): sys.stdout = self.old_stdout diff -r 6cc12ad6e616 -r 32b9137577b8 docs/pycon2010/pirate6.py --- a/docs/pycon2010/pirate6.py Sat Feb 20 09:26:33 2010 -0500 +++ b/docs/pycon2010/pirate6.py Sun Feb 21 15:25:22 2010 -0500 @@ -1,4 +1,4 @@ -from cmd import Cmd +from cmd2 import Cmd # prompts and defaults class Pirate(Cmd): diff -r 6cc12ad6e616 -r 32b9137577b8 docs/pycon2010/pycon2010.rst --- a/docs/pycon2010/pycon2010.rst Sat Feb 20 09:26:33 2010 -0500 +++ b/docs/pycon2010/pycon2010.rst Sun Feb 21 15:25:22 2010 -0500 @@ -327,6 +327,35 @@ Now ``cmd2``-based; postgreSQL; MySQL +File reporter +============= + +.. class:: huge + + Gather info: Python + + Store: postgresql + + Report: html + +fileutil.py +=========== + +:: + + import glob + import os.path + + for fullfilename in glob.glob('/home/cat/proj/cmd2/*.py'): + (dirpath, fname) = os.path.split(fullfilename) + stats = os.stat(fullfilename) + binds['path'] = dirpath + binds['name'] = fname + binds['bytes'] = stats.st_size + cmd("""INSERT INTO cat.files (path, name, bytes) + VALUES (%(path)s, %(name)s, %(bytes)s)""") + quit() + sqlpython features ================== @@ -338,16 +367,6 @@ * UNIX: ls, cat, grep * Special output -File reporter -============= - -.. class:: huge - - Gather info: Python - - Store: postgresql - - Report: html Thank you =========