P4python: python interface to Perforce API
P4python is the python interface to Perforce API, it helps to do Perforce operations through python. i will share basic operations: sync / submmit / add / delete
you need to know some details about Perforce cmd, please find it in the below link:
you need to use below codes for Perforce connect, login and disconnect.
def P4Connection(src,dst):
try:
p4.connect()
p4.run_login()
operation(src,dst)
except P4Exception:
for e in p4.errors: # Display errors
print e
finally:
p4.disconnect()
you can define operations in the operation() function. i will show sync/submmit/add/delete files
def sync(file):
'''
User can sync single file, all the files in the same directory, the files with same suffix,or the files with same version.
it depends on the rule of file
#single file://depot/Projects/a.txt
#all files: //depot/Projects/...
#same suffix: //depot/Projects/*.pptx
'''
p4.run_sync(file)
def submmit():
#open=p4.run_open(srcFile) ###you may need to open the file manually
change = p4.fetch_change()
change['Description']='Auto submit'
p4.run_submit(change)
def add(file):
'''
#User can add single file, or all the files in the same folder
addFile=r'D:\Perforce\depot\Projects\a.txt'
addFolder=r'D:\Perforce\depot\Projects\...'
'''
p4.run_add(file)
#user need to change the description and submmit the changelist manually after add new files.
submmit()
def delete(file):
'''
#User can delete single file, or all the files in the same folder
delFile='//depot/Projects/a.txt'
delFolder='//depot/Projects/...'
'''
p4.run_delete(file)
#User need to submmit the changelist manually like Add operation
submmit()
Hope that it can be helpful for Perforce operations.
P4python: python interface to Perforce API的更多相关文章
- Libsvm:脚本(subset.py、grid.py、checkdata.py) | MATLAB/OCTAVE interface | Python interface
1.脚本 This directory includes some useful codes: 1. subset selection tools. (子集抽取工具) subset.py 2. par ...
- python调用openstack的api,create_instance的程序解析
python调用openstack的api,create_instance的程序解析 2017年10月17日 15:27:24 CloudXli 阅读数:848 版权声明:本文为博主原创文章,未经 ...
- Python+Flask搭建mock api server
Python+Flask搭建mock api server 前言: 近期由于工作需要,需要一个Mock Server调用接口直接返回API结果: 假如可以先通过接口文档的定义,自己模拟出服务器返回结果 ...
- Python获得百度统计API的数据并发送邮件
Python获得百度统计API的数据并发送邮件 小工具 本来这么晚是不准备写博客的,当是想到了那个狗子绝对会在开学的时候跟我逼逼这个事情,所以,还是老老实实地写一下吧. Baidu统计API的使 ...
- python操作三大主流数据库(12)python操作redis的api框架redis-py简单使用
python操作三大主流数据库(12)python操作redis的api框架redis-py简单使用 redispy安装安装及简单使用:https://github.com/andymccurdy/r ...
- Python 调用图像融合API
Python 调用图像融合API 本文记录使用Python,调用腾讯AI开放平台的图像融合API.官网给出的Demo用的是PHP,博主作为Python的粉丝,自然想用它来和『最好的』的语言一较高下,顺 ...
- 用Python调用华为云API接口发短信
[摘要] 用Python调用华为云API接口实现发短信,当然能给调用发短信接口前提条件是通过企业实名认证,而且有一个通过审核的短信签名,话不多说,showcode #!/usr/bin/python3 ...
- python为前端提供API
作为一名前端来学习后端语言,有难度啊.这里把第一次尝试的过程做个记录 1.网上看到Python给前端提供API可以使用python的flaskweb框架 #py文件 import json from ...
- 数理统计(二)——Python中的概率分布API
数理统计(二)——Python中的概率分布API iwehdio的博客园:https://www.cnblogs.com/iwehdio/ 数理统计中进行假设检验需要查一些分布的上分位数表.在scip ...
随机推荐
- Android开发多媒体应用之SoundPool的使用的代码
内容过程中,把写内容过程中比较好的内容段记录起来,下面的内容是关于Android开发多媒体应用之SoundPool的使用的内容,希望对各位也有用途. public class MainActivity ...
- 街机模拟.samsho2
1.sdyrugal https://www.douyu.com/599516 2.红中哥:西瓜视频 搜索 "红中哥游戏解说" 我搜索到的地址:https://live.ixig ...
- python安装方法
1.下载Python安装包 2.配置环境变量 path=%path%;C:\Python27 3.安装pip 默认已安装 4.配置pip环境变量 path=%path%;C:\Python27\Scr ...
- Access computer files on iPad without using iTunes.
going to my CSDN blog ---> https://blog.csdn.net/qq_37746801/article/details/89708103
- python excel读写数据
python 读取excel内容,包含表格日期处理 # -*- coding: utf- -*- import xlrd #读取excel表格 workbook=xlrd.open_workbook( ...
- java.lang.NumberFormatException: For input string: "1" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang
java.lang.NumberFormatException: For input string: "1" at java.lang.NumberFormatException ...
- Codeforces 809D. Hitchhiking in the Baltic States
Description 给出 \(n\) 个数 \(a_i\),每一个数有一个取值 \([l_i,r_i]\) ,你来确定每一个数,使得 \(LIS\) 最大 题面 Solution 按照平时做法,设 ...
- 【AAA】AAA协议介绍
AAA AAA简介 AAA是认证(Authentication).授权(Authorization)和计费(Accounting)的简称,是网络安全中进行访问控制的一种安全管理机制,提供认证.授权和计 ...
- 30 行代码实现 JS 中的 MVC
一连串的名字走马观花式的出现和更迭,它们中一些已经渐渐淡出了大家的视野,一些还在迅速茁壮成长,一些则已经在特定的生态环境中独当一面舍我其谁.但不论如何,MVC已经并将持续深刻地影响前端工程师们的思维方 ...
- [转]JavaScript和html5 canvas生成圆形印章
本文转自:http://www.cnblogs.com/dragondean/p/6013529.html 代码: function createSeal(id,company,name){ var ...