Helix Core P4Python Developer Guide

[Pages:76]Helix Core P4Python Developer Guide

2020.1 July 2020

Copyright ? 2007-2020 Perforce Software, Inc..

All rights reserved.

All software and documentation of Perforce Software, Inc. is available from . You can download and use Perforce programs, but you can not sell or redistribute them. You can download, print, copy, edit, and redistribute the documentation, but you can not sell it, or sell any documentation derived from it. You can not modify or attempt to reverse engineer the programs.

This product is subject to U.S. export control laws and regulations including, but not limited to, the U.S. Export Administration Regulations, the International Traffic in Arms Regulation requirements, and all applicable end-use, end-user and destination restrictions. Licensee shall not permit, directly or indirectly, use of any Perforce technology in or by any U.S. embargoed country or otherwise in violation of any U.S. export control laws and regulations.

Perforce programs and documents are available from our Web site as is. No warranty or support is provided. Warranties and support, along with higher capacity servers, are sold by Perforce.

Perforce assumes no responsibility or liability for any errors or inaccuracies that might appear in this book. By downloading and using our programs and documents you agree to these terms.

Perforce and Inter-File Branching are trademarks of Perforce.

All other brands or product names are trademarks or registered trademarks of their respective companies or organizations.

Any additional software included within Perforce is listed in "License Statements" on page 76.

Contents

How to use this guide

Syntax conventions Feedback Other documentation

P4Python

Introduction System Requirements and Release Notes Installing P4Python

Install P4Python using pip Install P4Python on Windows Install P4Python from a package Programming with P4Python Using keyword arguments Submitting a Changelist Logging into Helix server ticket-based authentication Connecting to Helix server over SSL Changing your password Timestamp conversion Working with comments in specs P4Python Classes P4 P4.P4Exception P4.DepotFile P4.Revision P4.Integration P4.Map P4.MergeData P4.Message P4.OutputHandler P4.Progress P4.Resolver P4.Spec Class P4 Class P4.P4Exception

5

5 5 6

7

7 7 7 8 8 8 10 12 12 13 13 13 14 14 15 15 19 19 20 20 20 21 22 22 22 23 23 23 44

3

Class P4.DepotFile

45

Class P4.Revision

45

Class P4.Integration

47

Class P4.Map

48

Class P4.MergeData

50

Class P4.Message

51

Class P4.OutputHandler

52

Class P4.Progress

53

Class P4.Resolver

55

Class P4.Spec

55

Glossary

57

License Statements

76

4

How to use this guide

This guide contains details about using the derived API for Python to create scripts that interact with Helix Core server. You can download the API from the Perforce web site. The derived API depends on the Helix C/C++ API. For details, see the Helix Core C/C++ Developer Guide.

This section provides information on typographical conventions, feedback options, and additional documentation.

Syntax conventions

Helix documentation uses the following syntax conventions to describe command line syntax.

Notation literal italics

[-f]

...

Meaning

Must be used in the command exactly as shown.

A parameter for which you must supply specific information. For example, for a serverid parameter, supply the ID of the server.

The enclosed elements are optional. Omit the brackets when you compose the command.

Previous argument can be repeated.

n p4 [g-opts] streamlog [ -l -L -t -m max ] stream1 ... means 1 or more stream arguments separated by a space

n See also the use on ... in Command alias syntax in the Helix Core P4

Command Reference

Tip ... has a different meaning for directories. See Wildcards in the Helix Core P4

Command Reference.

element1 | Either element1 or element2 is required. element2

Feedback

How can we improve this manual? Email us at manual@.

5

Other documentation

Other documentation

See .

Tip

You can also search for Support articles in the Perforce Knowledgebase. Earlier versions of this guide: 2018.2 To find even earlier versions of this guide, use the following URL and replace v17.2 with the version number you are looking for:

6

P4Python

Introduction

P4Python is a derived API, it is the Python interface to the Helix C/C++ API, see Helix Core C/C++ Developer Guide. P4Python enables you to write Python code that interacts with a Helix Core server. P4Python enables your Python scripts to:

n Get Helix server data and forms in dictionaries and lists. n Edit Helix server forms by modifying dictionaries. n Provide exception-based error handling and optionally ignore warnings. n Issue multiple commands on a single connection (performs better than spawning single

commands and parsing the results).

System Requirements and Release Notes

P4Python is supported on Windows, Linux, and OS X. For system requirements, see the release notes at .

Note

When passing arguments, make sure to omit the space between the argument and its value, such as

in the value pair -u and username in the following example: change = p4.run_changes("-uusername", "-m1")[0] If you include a space ("-u username"), the command fails.

Installing P4Python

Important

Before installing P4Python, any previously installed versions should be uninstalled.

In this section: n "Install P4Python using pip" on the next page n "Install P4Python on Windows" on the next page n "Install P4Python from a package" on the next page

7

Install P4Python using pip

Install P4Python using pip

As of P4Python 2015.1, the recommended mechanism for installing P4Python is via pip. For example: pip install p4python pip installs binary versions of P4Python where possible, otherwise it attempts to automatically build

P4Python from source. For instruction on building P4Python from source, see the Building P4Python from Source section of the P4Python Release notes.

Note When P4Python is built without the --apidir option, setup attempts to connect to

ftp. to download the correct version of the P4API binary. If the P4API download is successful, it is unpacked into a temporary directory.

Linux: when P4Python is built without the --ssl option, setup.py looks at the installed

OpenSSL and checks to see if it is a supported version. P4Python 2019.1 and later: OpenSSL libraries are REQUIRED, version 1.0.2+ or version 1.1.1+. If

a supported version of OpenSSL is not found, setup.py will download and install one from

ftp..

Install P4Python on Windows

Windows users can download an installer containing pre-built packages for P4Python from the Perforce web site at .

Install P4Python from a package

1. Configure the Perforce package repository. As root, follow the instructions for your OS distribution:

Ubuntu 16.04:

Create the file /etc/apt/sources.list.d/perforce.list with the following

content:

deb xenial release

Ubuntu 18.04:

Create the file /etc/apt/sources.list.d/perforce.list with the following

content:

deb bionic release

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download