<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=343501615-12082008><FONT face=Arial size=2>I am trying to run
p4python API on top of python 2.5.2 and am extracting a dictionary from
perforce. The following code returns the output that follows
it:</FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><SPAN class=343501615-12082008><FONT face=Courier size=2>from P4 import
P4, P4Exception<BR>p4 = P4()<BR>p4.port = "erased"
#deleted<BR>p4.user = "erased" #deleted</FONT></SPAN></DIV>
<DIV><FONT face=Courier></FONT> </DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Courier
size=2>try:<BR> p4.connect()<BR> info =
p4.run("info")<BR> print info<BR>
p4.disconnect()<BR>except P4Exception:<BR> for e in
p4.errors:<BR> print e</FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Arial
size=2></FONT></SPAN> </DIV></BLOCKQUOTE>
<DIV dir=ltr><SPAN class=343501615-12082008><FONT face=Arial
size=2>Output:</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><SPAN class=343501615-12082008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Arial size=2>[{'userName':
'mfielding', 'clientRoot': 'c:\\perforce', 'monitor': 'enabled',
</FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Arial size=2>'serverRoot':
'H:\\p4root\\', 'serverVersion': 'P4D/NTX64/2007.3/143793 (2008/01/<BR>21)',
'serverDate': '2008/08/12 11:18:56 -0400 Eastern Daylight Time',
'clientAd<BR>dress': '10.24.20.97:1918', 'serverLicense': 'Mad Doc Software,
Inc. 140 users (<BR>support expired 2008/05/31) ', 'serverAddress':
'rsgnwep4s1.rockstar.t2.corp:166<BR>6', 'clientHost': 'nwew-mfielding',
'security': 'enabled', 'password': 'enabled'<BR>, 'clientName':
'mfielding'}]</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV><SPAN class=343501615-12082008><FONT face=Arial size=2>I did this to test
that I was receiving a dictionary back from the server, which I clearly am. I
then followed by adding the following lines to the code:</FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><SPAN class=343501615-12082008><FONT face=Courier size=2>print
info</FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Courier size=2><STRONG>s =
info[serverVersion]</STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Courier size=2><STRONG>print
s</STRONG></FONT></SPAN></DIV>
<DIV><SPAN class=343501615-12082008><FONT face=Courier
size=2>p4.disconnect()</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>I would
expect this to print out P4D/NTX64/2007.3/143793 (2008/01/23), but instead it
spits out the following error:</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008></SPAN></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>Traceback
(most recent call last):<BR> File "test.py", line 10, in
<module><BR> s = info[serverVersion]<BR>NameError:
name 'serverVersion' is not defined</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008></SPAN></FONT> </DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>Changing "s
= info[serverVersion]" to "s = info['serverVersion']" only gives me another
error, which is:</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008></SPAN></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>Traceback
(most recent call last):<BR> File "test.py", line 10, in
<module><BR> s = info['serverVersion']<BR>TypeError:
list indices must be integers</SPAN></FONT></DIV></BLOCKQUOTE>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008></SPAN></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>If anyone
has any idea what is going on here, I would appreciate the help. I've spent a
few hours over the past two days trying to figure this little quirk out, but to
no avail.</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008></SPAN></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008>Matt
Fielding</SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN class=343501615-12082008><EM>IT
Technician</EM></SPAN></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2><SPAN
class=343501615-12082008><STRONG>Rockstar New
England</STRONG></SPAN></FONT></DIV></BODY></HTML>