Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Perforce"print" error - AttributeError: OutputBinary

Thread Tools

Perforce"print" error - AttributeError: OutputBinary

Posts: n/a
Hi all,
I am getting an error message when trying to use the P4 print command
via the python api for perforce.

Anytime that I run"print","-q", eachFile), I keep getting an
error message: "AttributeError: OutputBinary."

Here is my code below: Please Help.

import p4
#import perforce module
#For complete API see
p4c = p4.P4()
p4c.port = ""
p4c.user = "perrk9"
path = "//practice/perrk9/..."
localTemp = "c:\perforce_temp_dir\\"

first = "counter", "galloway_deploy" )[0]
# here 'last_change_record' is a dictionary
last_change_record = "changes", "-m", "1", path )[0]
print "last change record"
print last_change_record
last = last_change_record['change']
print "last \n"
print last

status_dict = { "right only" :"add", "left only" :"delete", "content"
:"edit", "identical" :"no change" }

result = "diff2", "-q", path + "@" + first , path + "@" + last
# result is an Array, each element is a Dictionary

#Find out which files were add/edited/deleted and throw them into lists
deploy = [] # add/edit list
undeploy = [] # delete list
for changed_file in result:
action = status_dict[ changed_file['status'] ]
print action
if ((action =='add') or (action == 'edit')):
print "Changed file = "
print changed_file['depotFile']
deploy.append(changed_file['depotFile']) #appending each file to our
'deploy' list
elif action == delete:
undeploy.append(changed_file['depotFile']) #appending each file to
our 'undeploy' list

#print the deploy list
print "deploy list"
print deploy
for eachFile in deploy :
print eachFile

file ="print","-q", eachFile)

Reply With Quote
Posts: n/a
I received a response from Robert Cowham ( the author of the API):

The problem is that something like print was only expected to be done
for text files not binary.

You could try editing and add a method similar to:

def OutputText(self, text):
"Adds text lines to the output data."
for line in string.split(text, '\n'):

e.g. around line 214 add

def OutputBinary(self, text):
"Adds lines to the output data."

Note: I am sure that Robert will be updating the P4 module for python,
so if you can I would just download the most recent version (I would
give him a couple of days though).

Reply With Quote
Posts: n/a
This seemed to fix my problem.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
NetBeans 5.0 & Perforce Versioning Manager ozgwei Java 3 06-08-2007 03:53 PM
Perforce plugin for Eclipse 3.1 or above ozgwei Java 3 06-05-2007 12:53 AM
Marshaled input / output from Perforce server Kim Bendtsen Python 0 09-12-2006 08:25 PM
ANN: P4Python 0.5 - Interface to Perforce Robert Cowham Python 0 01-21-2005 03:38 PM
popen3 and Perforce Ruchika Python 1 09-09-2004 09:11 AM