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

  • 相关阅读:
    oracle_dblink配置
    Data Pump(数据抽取)介绍
    亲测 logminer挖掘
    基础命令
    锁_rac环境kill锁表会话后出现killed状态(解决)
    ASM磁盘组空间不足--ORA-15041:DISGROUP DATA space exhausted (生产库案例)
    where子句的具体含义
    Oracle常用脚本——通过RMAN配置RAC环境的分布式磁带机
    如何创建动态的多维数组且内存空间连续
    Hibernate级联删除
  • 原文地址:https://www.cnblogs.com/frost-hit/p/7270029.html
Copyright © 2020-2023  润新知