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 ...
随机推荐
- Shiro源码解析-Session篇
上一篇Shiro源码解析-登录篇中提到了在登录验证成功后有对session的处理,但未详细分析,本文对此部分源码详细分析下. 1. 分析切入点:DefaultSecurityManger的login方 ...
- Ntp客户端
function parseMsg (buffer) { if (buffer.length !== 48) return; const pkt = {}, now = new Date().getT ...
- chromedriver for mac
- python __getattribute__、__getattr__、__setattr__详解
__getattribute__ 官方文档中描述如下: 该方法可以拦截对对象属性的所有访问企图,当属性被访问时,自动调用该方法(只适用于新式类).因此常用于实现一些访问某属性时执行一段代码的特性. 需 ...
- 20190430-screen、client、offset、scroll等JS中各种宽度距离
参考文献: JavaScript概念之screen/client/offset/scroll/inner/avail的width/left
- (转)Linux:使用libgen.h:basename,dirname
Linux:使用libgen.h:basename,dirname basename以及dirname是两个命令: [test1280@localhost ~]$ which basename /bi ...
- EasyNetQ自定义异常消息处理
20140310补充: rabbitmq有requeue属性,可以选择消息是否返回队列,另,本文的解决方式非常之山寨,只能应用于发送和接收方式. 这几天在折腾消息队列,在.Net环境下有基于Rabbi ...
- 在unity中使用protobuf
https://www.jianshu.com/p/b135676dbe8d 上面的提供序列化和常见的序列化有点不一样 下面的是常见的序列化的,但是他没有讲怎么用工具生成.proto--->.c ...
- c#,利用WPF的ScaleTransform和TranslateTransform实现图片的缩放效果
一.缩放要求 1.缩放对象在可视区域内,已对象的中心点进行缩放. 2.缩放对象比可视区大,并且对象各边界都在可视区外围,那么已鼠标位置进行缩放. 3.缩放对象比可视区大,但是缩放后某一边界在可视区的对 ...
- Golang教程:switch 语句
switch 是一个条件语句,用于将一个表达式的求值结果与可能的值的列表进行匹配,并根据匹配结果执行相应的代码.可以认为 switch 语句是编写多个 if-else 子句的替代方式. 举例是说明问题 ...