From Matt.Fielding at rockstarnewengland.com Tue Aug 12 07:16:43 2008 From: Matt.Fielding at rockstarnewengland.com (Matt Fielding (R* New England)) Date: Tue, 12 Aug 2008 10:16:43 -0400 Subject: [p4python] Test code erroring out Message-ID: I've recently installed the p4python API on top of python 2.5.2 on my machine to try and test out some perforce scripts, but I am running into an issue that I don't quite understand. Traceback (most recent call last): File "test.py", line 12, in except p4.P4Exception: File "C:\Python25\lib\site-packages\P4.py", line 244, in __getattr__ raise AttributeError, name AttributeError: P4Exception This error is coming up while running the following code: from P4 import P4 p4 = P4() p4.port = "port" #actual port was here, no worries p4.user = "username" #actual user name was here as well try: p4.connect() info1 = p4.run("info") s = info['serverVersion'] print s p4.disconnect() except p4.P4Exception: for e in p4.errors: print e The code comes straight out of the P4Python manual, and is the first, most basic chunk of code I could possibly run. It appears something is incorrect in my P4.py file, but seeing as I just installed the API, I don't see why something would be messed up already. I'm hoping someone else has run into this problem and has a quick solution for me. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://maillist.perforce.com/pipermail/p4python/attachments/20080812/093d1c3a/attachment.html From sknop at perforce.com Tue Aug 12 07:44:38 2008 From: sknop at perforce.com (Sven Erik Knop) Date: Tue, 12 Aug 2008 15:44:38 +0100 Subject: [p4python] Test code erroring out In-Reply-To: References: Message-ID: <48A1A1D6.1060303@perforce.com> Hi Matt, Unfortunately, there is an error in documentation. Here is the correct code: /from P4 import P4, P4Exception p4 = P4() p4.port = "port" #actual port was here, no worries p4.user = "username" #actual user name was here as well/ // / try: p4.connect() info1 = p4.run("info") s = info['serverVersion'] print s p4.disconnect() except P4Exception: for e in p4.errors: print e/ P4Exception is not a member of the instance "p4", but of the module "P4". With these changes you should be able to run the code. Kind regards, Sven Erik Matt Fielding (R* New England) wrote: > I've recently installed the p4python API on top of python 2.5.2 on my > machine to try and test out some perforce scripts, but I am running > into an issue that I don't quite understand. > > / Traceback (most recent call last): > File "test.py", line 12, in > except p4.P4Exception: > File "C:\Python25\lib\site-packages\P4.py", line 244, in __getattr__ > raise AttributeError, name > AttributeError: P4Exception/ > > This error is coming up while running the following code: > > / from P4 import P4 > p4 = P4() > p4.port = "port" #actual port was here, no worries > p4.user = "username" #actual user name was here as well/ > // > / try: > p4.connect() > info1 = p4.run("info") > s = info['serverVersion'] > print s > p4.disconnect() > except p4.P4Exception: > for e in p4.errors: > print e/ > // > The code comes straight out of the P4Python manual, and is the first, > most basic chunk of code I could possibly run. It appears something is > incorrect in my P4.py file, but seeing as I just installed the API, I > don't see why something would be messed up already. I'm hoping someone > else has run into this problem and has a quick solution for me. > ------------------------------------------------------------------------ > > _______________________________________________ > p4python mailing list > p4python at perforce.com > http://maillist.perforce.com/mailman/listinfo/p4python > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://maillist.perforce.com/pipermail/p4python/attachments/20080812/5ce18277/attachment.html