[p4python] Output of p4 print chunked into array?

Sven Erik Knop sknop at perforce.com
Fri Nov 7 01:45:01 PST 2014


Hi Jan,

As Goeff said, the server sends 4K blocks of content back, so the APIs return them as separate strings. 
If you use P4.run_print() instead of P4.run(“print”), P4Python clumps the chunks together into a single continuous string. 
This should make your customers life much easier.

Cheers

Sven Erik

PS: Time for a blog article?

> On 6 Nov 2014, at 22:12, Geoff Nicol <gnicol at perforce.com> wrote:
> 
> Its not a particularly helpful observation but p4-php behaves the same way; I think its a fundamental part of p4.
> 
> Its useful in its own way as you can use an output handler to deal with large files being printed 4k at a time.
> 
> It is surprising though the first time you figure it out.
> 
> -Geoff
> 
> On Thu, Nov 6, 2014 at 1:46 PM, Jan Van Uytven <juytven at perforce.com <mailto:juytven at perforce.com>> wrote:
> 
> I have a user who's a bit confused as to why the output of 'p4 print'
> (when run as p4.run_print("-q", "some_file")) returns an array with the
> contents of the file 'chunked' into 4096-byte segments.
> 
> He points out that this isn't documented, and as far as I can tell, he's
> right.  Is there a particular reason why P4Python does this?
> 
> (I'd check p4prod, but I can't seem to access it atm)
> 
> - Jan
> 
> --
> Jan Van Uytven
> 
> Everything(Nothing) is true -
>    Everything is permissible!
>    - Hassan i Sabbah
> _______________________________________________
> p4python mailing list
> p4python at perforce.com <mailto:p4python at perforce.com>
> http://maillist.perforce.com/mailman/listinfo/p4python <http://maillist.perforce.com/mailman/listinfo/p4python>
> 
> _______________________________________________
> 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/20141107/d655e511/attachment-0002.html>


More information about the p4python mailing list