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 ...
随机推荐
- python 中mysql数据库的读写
1.读取数据库 import pymysql id=[] name=[] explain=[] db=pymysql.Connection(host=,user="root", p ...
- 安装orcle服务器端后,不需要安装客户端,可通过plsql登录
用PL/SQL连接oracle数据库,不管是本地的还是远程的,一般都需要安装oracle客户端(500M左右)比较大,而且在各个系统上安装也有些讲究,需要修改相应配置文件,有点麻烦,像平时开发时候,我 ...
- 【爬虫】-xpath语法熟悉及实战
本文为自学记录,部分内容转载于 w3school python3网络爬虫实战 知乎专栏:写点python 如有侵权,请联系删除. 语法 1.选取节点 XPath 使用路径表达式在 XML 文档中选取节 ...
- Comparison of Symbolic Deep Learning Frameworks
http://blog.revolutionanalytics.com/2016/08/deep-learning-part-1.html Deep Learning Part 1: Comparis ...
- AngularJs学习笔记--Managing Service Dependencies
原版地址:http://docs.angularjs.org/guide/dev_guide.services.managing_dependencies angular允许service将其他ser ...
- springboot整合mybatis(映射文件方式和注解方式)
springboot作为一个微服务框架,给我们开发人员提供极大的便利,秉着约定大于配置的原则,通过starter包的形式为我们做了许多默认的配置,在进行数据持久化到关系型数据库时,我们一般都会首选sp ...
- springboot+redis实现缓存数据
在当前互联网环境下,缓存随处可见,利用缓存可以很好的提升系统性能,特别是对于查询操作,可以有效的减少数据库压力,Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存 ...
- Python ImportError: No module named 'requests'解决方法
前言:最近在学习python,安装了python3.5的环境后,在网上下载了一个python文件运行的时候,提示ImportError: No module named 'requests'(找不到r ...
- jdk 自动化脚本
添加没有登录权限 需要理解linux用户,首先登陆的是root用户,拥有所有的权限,但是该权限太大,一般都会分配其他用户使用,并且在部署程序时,需要分配一个没有登录权限的用户,这样改程序不能随意被修改 ...
- 设置全局theme及读取theme方法
在web.config中设置了默认的Theme,其部分如下的配置节点: <system.web> <pages theme="Default" controlRe ...