<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>P4Python - Perforce Public Depot</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso8859-1"> <LINK href="index_files/rubystyle.css" type=text/css rel=stylesheet> </HEAD> <BODY> <TABLE width="100%" border=0> <TBODY> <TR> <TD> </TD> <TD> <H2>P4Python: Python interface to the Perforce API</H2></TD></TR></TBODY> </TABLE> <H3>Contents</H3> <OL> <LI><a href="#official">New Official P4Python</a><LI><a href="#old_p4python"> Old P4Python</a></OL> <A name=intro></A> <h2><b><a name="official"></a>New Official P4Python</b></h2> <p><b>Please note that Perforce have now released <a href="http://www.perforce.com/product/components/apis#p4python" target="_blank">P4Python as a supported product</a> (as of 2007.3). You can get the 2011.1 <a href="ftp://ftp.perforce.com/perforce/r11.1/bin.tools/p4python.tgz">source tarball here</a> (or see previous link for other versions including prebuilt Windows binaries).</b></p> <p><b>This has been done with my agreement and support.</b></p> <p>The new version is <a href="http://www.perforce.com/perforce/doc.current/manuals/p4script/03_python.html" target="_blank"> fully documented</a> (or <a href="http://www.perforce.com/perforce/doc.current/manuals/p4script/p4script.pdf" target="_blank">PDF here</a>).</p> <p>A summary of differences between the official version 2007.3-2009.2 and my version 1.x can be found in the release notes and is <a href="#diff"> given below</a>.</p> <p>As of 2008.1 the official version will compile and build with Python 2.4. Perforce does not have one on their FTP site, but you can download a pre-built binary here: <a href="official/dist/P4Python-2008.1.win32-py2.4.exe"> P4Python-2008.1.win32-py2.4.exe</a>.</p> <h2>Old P4Python</h2> <p>The older version of P4Python (version numbering 1.x) <a href="old_p4python.html"><b>is still available</b> and documented here</a>. It is now deprecated and will not be maintained.</p> <h2 id="diff">Differences between P4Python 1.x and Perforce P4Python</h2> <p>From the Release Notes:</p> <pre>7. Compatibility with the P4Python from the Public Depot Perforce P4Python is significantly different from the version of P4Python in the Perforce Public Depot. Perforce P4Python contains several improvements and interface changes intended to make P4Python consistent with the other scripting interfaces and with Python in general. If you are migrating from Public Depot version of P4Python, edit your scripts to ensure that the scripts comply with the new interface. The differences are detailed below. New module name The P4Python module has been renamed from p4 to P4. For example: Old: >>> import p4 >>> p4c = p4.P4() New: >>> import P4 >>> p4 = P4.P4() By convention, Public Depot P4Python used 'p4c' as an instance variable because 'p4' was used as a module name. Now that the module has been renamed 'P4', you can use 'p4' for your instance variables. All demos and tests use the new convention. Deleted methods The following methods have been deleted from the P4 class and are no longer available: dropped - Use connected() parse_forms - Form parsing is now always on tagged - See tagged attribute below. New methods The following methods are new to Perforce P4Python: connected - Returns True if the client is connected format_xxx - Converts a dict-based specification into a string (replace xxx with spec type, for example: format_client) identify - Returns information about P4Python parse_xxx - Converts a string into a P4.Spec object (replace xxx with spec type) run_filelog - Runs 'p4 filelog' and returns an array of P4.DepotFile objects run_login - Runs 'p4 login' using current password run_password - Runs 'p4 passwd' with old and new password run_submit - Runs 'p4 submit' Attributes Perforce P4Python provides the following attributes. Attributes can be set in the P4() constructor or by using their 'setters and getters'. For example: >>> import P4 >>> p4 = P4.P4(client="myclient", port="1666") >>> p4.user = 'me' Most attributes can be set and read. Except where indicated, attributes are strings. api_level API compatibility level, INTEGER charset The character set to use. String, not a constant as in previous versions client Client to use (P4CLIENT) cwd Current Working Directory debug Debug level (for debugging P4Python), INTEGER errors Array of errors returned by the server (Read-Only), LIST exception_level Determines whether exceptions are thrown, INTEGER host Client Host input Input for next command, can be STRING, LIST or DICTIONARY maxlocktime MaxLockTime for commands, INTEGER maxresults MaxResults for commands, INTEGER maxscanrows MaxScanRows for commands, INTEGER p4config_file Returns the config file path (Read-Only) password Value of P4PASSWD port Value of P4PORT prog Name of the script, shown in the server log server_level Returns the server level (Read-Only) tagged Boolean value, determines whether to use tagged mode, INTEGER ticket_file Returns the name of the ticket file user Value of P4USER warnings Array of warnings returned by the server (Read-Only), LIST Tagged mode and form parsing In Perforce P4Python 2007.3, form parsing and tagged output are enabled by default. (In Public Depot P4Python, tagged output and form parsing mode were disabled by default, but most scripts enabled them immediately.) Form parsing cannot be disabled explicitly, but tagged output can be enabled or disabled by setting p4.tagged as follows: p4.tagged = False # Disabled p4.tagged = True # Enabled This method can be used to disable form parsing, because form parsing does not work when tagged output is disabled. </pre> <p><font size="2">File: $Id: //guest/robert_cowham/perforce/API/python/index.html#28 $</font></p> </BODY></HTML>
|#28||8056||robert_cowham||Updated doc linka|
|#24||6517||robert_cowham||Clarified and updated links|
|#23||6382||robert_cowham||Split into 2 docs to clarify status.|
|#22||6361||robert_cowham||Link to new executables.|
Added link to official version and deprecation of this one.
Also add binary.
|#20||6135||robert_cowham||Check in 1.1 changes|
|#19||5968||robert_cowham||Latest build with Python 2.5|
|#18||5967||robert_cowham||- Upgrade to use Perforce API 2007.2 (new structure of api dirs and minor code change)|
- Bug fix in spec handling as suggested by Peter Fornwall
- Also changed API handling suggested by Peter to allow standard argument parsing
- Upgraded version to 1.0
- Build for Python 2.5 - no code changes.
- Document new switch for setup.
Added set_protocol() and api() methods.
Updated index.html and new Windows dist.
- Reworked test harness to use new Perforce sample depot so anyone can run it.
- Fixed problem with binary output (via print) reported by Keith Perry
- Added link to RPM build by Jason Dillon in index.html
|#13||5374||robert_cowham||Note re 2005.2 API|
|#12||5200||robert_cowham||Had mistakenly lost various pointers to releases.|
|#11||5165||robert_cowham||Point out where to get gcc 3 p4api.|
|#10||5101||robert_cowham||Updated docs and added new Linux binary.|
|#7||4964||robert_cowham||Saved first version of docs.|
|#5||4909||robert_cowham||Added new installer|
|#4||4858||robert_cowham||Added new binaries.|
Changed example to show better usage.
Raise AttributeError if appropriate.
|#2||4768||robert_cowham||Fix references for TOC etc.|
|#1||4767||robert_cowham||Forgot the most important thing!|