[p4python] Exceptions & Diffs

Wright, Richard richardw at cobaltgroup.com
Wed Jul 6 14:42:22 PDT 2005


So to get things started on the list, I have a couple things:
 
1. For exceptions, it would be great if some there were some exceptions like
"PerforceError" defined, instead of the current 'raise "Errors during
command execution"'.  This way, you could do:
try:
    p4.run_edit("file.txt")
except PerforceError:
   for e in p4.errors:
   print e
 
This would make it easier to differentiate between errors coming from
Perforce and general problems with the Python around it.
 
2.  There seem to be some issues with 'p4 diff' and 'p4 diff2' (My testing
has been on Windows 2000sp4 connected to both a 2004.2 & 2005.1 server using
both Python 2.3 & Python 2.4 with P4Python-0.5.win32-py2.3.exe#3 and
P4Python-0.5.win32-py2.4.exe#1 respectively) :
   With "diff2" it seems to work OK unless you have the tagged output turned
on.  When I connect with p4.tagged() or p4.parse_forms(), then I see the
following error:
 
Traceback (most recent call last):
  File "C:\Python23\p4pytest.py", line 6, in -toplevel-
    test = p4.run_diff2("//Playpen/richardw/Training/file1.txt",
"//Playpen/richardw/Training/file2.txt")
  File "C:\Python23\Lib\site-packages\p4.py", line 135, in run
    self.p4c.Run(cmd)
  File "C:\Python23\Lib\site-packages\p4.py", line 196, in InsertItem
    indices = map(int, string.split(index, ','))
  File "C:\Python23\lib\string.py", line 121, in split
    return s.split(sep, maxsplit)
  File "C:\Python23\Lib\site-packages\p4.py", line 196, in InsertItem
    indices = map(int, string.split(index, ','))
  File "C:\Python23\lib\string.py", line 121, in split
    return s.split(sep, maxsplit)
  File "C:\Python23\Lib\site-packages\p4.py", line 197, in InsertItem
    self._array_insert(arr, indices, val)
  File "C:\Python23\Lib\site-packages\p4.py", line 181, in _array_insert
    arr.append(val)
AttributeError: 'str' object has no attribute 'append'
 
 
With "diff", I can get output with "-se" or similar options, but when I try:
p4.run("diff")
I get the following:
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in -toplevel-
    p4.run("diff")
  File "C:\Python24\Lib\site-packages\p4.py", line 264, in run
    return self.p4client.run(args)
  File "C:\Python24\Lib\site-packages\p4.py", line 135, in run
    self.p4c.Run(cmd)
AttributeError: Diff
 

Rick Wright
CM/Build Engineer
The Cobalt Group, Inc.
2200 First Avenue South
Seattle, WA 98134
richardw at cobaltgroup.com <mailto:richardw at cobaltgroup.com> 
www.cobaltgroup.com 

p. 206.219.8382

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4python/attachments/20050706/abb3c06c/attachment-0001.html>


More information about the p4python mailing list