470,613 Members | 1,735 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

Perforce p4c.run("print" error - AttributeError: OutputBinary

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 p4c.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
http://public.perforce.com/guest/rob...hon/index.html
p4c = p4.P4()
p4c.port = "perforce.ic.ncs.com:1424"
p4c.user = "perrk9"
p4c.parse_forms()
p4c.connect()
path = "//practice/perrk9/..."
localTemp = "c:\perforce_temp_dir\\"
first = p4c.run( "counter", "galloway_deploy" )[0]
# here 'last_change_record' is a dictionary
last_change_record = p4c.run( "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 = p4c.run( "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 = p4c.run("print","-q", eachFile)

Mar 28 '06 #1
2 2686
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 p4.py and add a method similar to:

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

e.g. around line 214 add

def OutputBinary(self, text):
"Adds lines to the output data."
self.output.append(text)
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).

Mar 28 '06 #2
This seemed to fix my problem.

Keith

www.301labs.com

Mar 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by kiqyou_vf | last post: by
3 posts views Thread by Anthony Liu | last post: by
3 posts views Thread by Gavin Kreuiter | last post: by
8 posts views Thread by Eric Lilja | last post: by
13 posts views Thread by Vincent Delporte | last post: by
4 posts views Thread by Gilles Ganault | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.