zoukankan      html  css  js  c++  java
  • 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:PerforcedepotProjectsa.txt'
        addFolder=r'D:PerforcedepotProjects...'
        '''
        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.

  • 相关阅读:
    AngularJs用户登录的一些处理
    百度地图api-查询周边
    Git常用命令整理
    AngularJs控制器运行前方法,操控导航栏隐藏
    AngularJs中,如何在数据加载完成后,执行Js脚本
    ZZ:Linux的chattr与lsattr命令详解
    ZZ:实战 SSH 端口转发
    Python 删除 恢复 Redshift
    [原创]Python 命令 恢复 删除 RDS
    AWS CLI 命令学习 之 bat 控制EC2 启停
  • 原文地址:https://www.cnblogs.com/frost-hit/p/7270029.html
Copyright © 2011-2022 走看看