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 ...
随机推荐
- spotless-maven-plugin java代码自动格式化mvn spotless:apply -fn
<plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven ...
- AWS S3
Amazon Simple Storage Service (Amazon S3) Amazon S3 提供了一个简单 Web 服务接口,可用于随时在 Web 上的任何位置存储和检索任何数量的数据.此 ...
- KafKa 启动
Zookeeper 运行kafka需要使用Zookeeper,所以要先启动Zookeeper,如果没有Zookeeper,可以使用kafka自带打包和配置好的Zookeeper 1.进入kafka的b ...
- MYSQL分表与分区
什么是分表分区分表分区的区别实现方式上数据处理上提高性能上实现的难易度上mysql分表和分区的联系如何分区概述分区技术支持分区类型及举例注意应用场景示例订单表比预想中扩张速度快坑爹的日志表每半月一个分 ...
- ant.design初探
第一部分: 前言 推荐网站: https://ant.design/docs/spec/introduce-cn ant.design是基于react开发的一个解放ui和前端的工具,它提供了一致的设计 ...
- 【c++】构造函数初始化列表中成员初始化的次序性
上代码 #include <iostream> using namespace std; class A { public: A(int v): j(v + 2), i(j) {} voi ...
- JavaScript设计模式系列学习笔记目录
说明 本系列笔记参考书籍<JavaScript设计模式>.<JavaScript高级程序设计3> 参考博客:汤姆大叔博客:http://www.cnblogs.com/TomX ...
- bzoj 5372: [Pkusc2018]神仙的游戏
Description 小D和小H是两位神仙.他们经常在一起玩神仙才会玩的一些游戏,比如"口算一个4位数是不是完全平方数". 今天他们发现了一种新的游戏:首先称s长度为len的前缀 ...
- Shell脚本之awk详解
一.基本介绍 1.awk: awk是一个强大的文本分析工具,在对文本文件的处理以及生成报表,awk是无可替代的.awk认为文本文件都是结构化的,它将每一个输入行定义为一个记录,行中的每个字符串定义为一 ...
- WebDriverWait介绍
转自:https://www.cnblogs.com/ella-yao/p/7778678.html WebDriverWait介绍 package com.test.elementwait; imp ...