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的更多相关文章

  1. 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 ...

  2. python调用openstack的api,create_instance的程序解析

    python调用openstack的api,create_instance的程序解析 2017年10月17日 15:27:24 CloudXli 阅读数:848   版权声明:本文为博主原创文章,未经 ...

  3. Python+Flask搭建mock api server

    Python+Flask搭建mock api server 前言: 近期由于工作需要,需要一个Mock Server调用接口直接返回API结果: 假如可以先通过接口文档的定义,自己模拟出服务器返回结果 ...

  4. Python获得百度统计API的数据并发送邮件

    Python获得百度统计API的数据并发送邮件 小工具  本来这么晚是不准备写博客的,当是想到了那个狗子绝对会在开学的时候跟我逼逼这个事情,所以,还是老老实实地写一下吧.   Baidu统计API的使 ...

  5. python操作三大主流数据库(12)python操作redis的api框架redis-py简单使用

    python操作三大主流数据库(12)python操作redis的api框架redis-py简单使用 redispy安装安装及简单使用:https://github.com/andymccurdy/r ...

  6. Python 调用图像融合API

    Python 调用图像融合API 本文记录使用Python,调用腾讯AI开放平台的图像融合API.官网给出的Demo用的是PHP,博主作为Python的粉丝,自然想用它来和『最好的』的语言一较高下,顺 ...

  7. 用Python调用华为云API接口发短信

    [摘要] 用Python调用华为云API接口实现发短信,当然能给调用发短信接口前提条件是通过企业实名认证,而且有一个通过审核的短信签名,话不多说,showcode #!/usr/bin/python3 ...

  8. python为前端提供API

    作为一名前端来学习后端语言,有难度啊.这里把第一次尝试的过程做个记录 1.网上看到Python给前端提供API可以使用python的flaskweb框架 #py文件 import json from ...

  9. 数理统计(二)——Python中的概率分布API

    数理统计(二)——Python中的概率分布API iwehdio的博客园:https://www.cnblogs.com/iwehdio/ 数理统计中进行假设检验需要查一些分布的上分位数表.在scip ...

随机推荐

  1. spring、springmvc和mybatis整合(xml方式)

    今天搭建一个基于xml的ssm整合demo.话不多说,直接上代码. 我的开发环境如下: web服务器:tomcat8 开发工具:STS JDK版本:1.8 项目构建工具:maven 1.pom.xml ...

  2. ios UISearchDisplayController 实现 UITableView 搜索功能

    UISearchDisplayController 是苹果专为 UITableView 搜索封装的一个类. 里面内置了一个 UITableView 用于显示搜索的结果.它可以和一个需要搜索功能的 co ...

  3. 解决ajax请求返回Json无法解析"\"字符的问题

    原因:获取身份证信息,涉及图片路径,存在“\”字符,导致Json解析错误 解决思路:将返回类型从"json"改成"text",此时返回的数据类型变成字符串,将字 ...

  4. org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jboss.resteasy.plug

    之前做的项目是resteasy的上传,代码没有问题,断点都不进来呢. 我以为可以直接移植到SpringMVC,但是SpringMVC不支持MultipartFormDataInput , 用Multi ...

  5. The Internet Communications Engine (Ice) 跨平台异构通讯方案 第二弹-Hello world!

    如果不知道ICE是什么的同学,请看上一篇的ICE简介:http://www.cnblogs.com/winds/p/3864677.html 好了,HelloWorld,从中间语言讲起. 首先,我们新 ...

  6. 移除TFS服务器关系

    移除TFS服务器关系:1.将项目和从以前的TFS服务器断开.2.退出VS.3.找到C:\Documents and Settings\Administrator\Local Settings\Appl ...

  7. 【转】.net MVC 生命周期

    对于Asp.net MVC,我对它的生命周期还是兴趣很浓,于是提出两个问题: 一个HTTP请求从IIS移交到Asp.net运行时,Asp.net MVC是在什么时机获得了控制权并对请求进行处理呢?处理 ...

  8. Python基础学习总结(三)

    4.if语句 If语句可以检查判定当前条件,并执行相应措施. if a in A: if a 条件: 执行命令1 4 else: 执行命令2 if判断条件还可以简写 if x: print('True ...

  9. POJ1651 Multiplication Puzzle(相邻乘积之和最小,区间DP)

    http://blog.csdn.net/libin56842/article/details/9747021 http://www.cnblogs.com/devil-91/archive/2012 ...

  10. python os.popen 乱码问题

    os.popen('ipconfig') 命令返回的结果在调试时乱码了: output1 = os.popen('ipconfig') o1=output1.read() 我猜这里输出的内容要和控制台 ...