How to disable svn lock acquisition via python API

2019-07-23
2019-08-20
  • varleybullard

    varleybullard - 2019-07-23

    Hi,

    I have started to setup a continuous integration for our project using the python api and have noticed that when loading/running project with the svn add on , codesys can leave some objects in the svn tree locked.

    Can anyone advise how python API can be used to request codesys runtime not acquire any SVN locks ?

    At the moment we run this code snippet in a non-codesys checkout of the project to clear locks but it would be better to prevent them from being used at all.

        def unlock_project(self, path):
            output = subprocess.check_output(['svn', 'status', '-u', path]).splitlines()[0:-1]
            for line in output:
                line_str = line.decode(encoding='utf-8', errors='replace')
                locked_path = line_str.split()[2]
                print('Found locked path at: "{0}"'.format(locked_path))
                force_lock = subprocess.check_output(['svn', 'lock',  locked_path, '--force'])
                print(force_lock.decode(encoding='utf-8', errors='replace'))
                remove_lock = subprocess.check_output(['svn', 'unlock', locked_path, '--force'])
                print(remove_lock.decode(encoding='utf-8', errors='replace'))
    

    Any advice gratefully received,

    Kind regards
    Varley

     

    Related

    Talk.ru: 2

  • mkeller

    mkeller - 2019-07-29

    Hi Varley.

    Depending what you want to do you may set the project to offline mode or disable locking.

    proj = projects.primary
    \# Disable locking for the whole machine
    svn.default_auto_locking_mode = SvnAutoLockingMode.Never
    \# Deisable locking for the current project
    proj.svn.project_auto_locking_mode = SvnAutoLockingMode.Never
    

    BR
    Martin

     
  • varleybullard

    varleybullard - 2019-08-14

    Hi Martin,

    Thanks - that works just fine, although we may still need to force the unlock in case some team member has left the project locked by accident.

    Best regards
    Varley

     
  • mkeller

    mkeller - 2019-08-20

    Hi Varley.

    varleybullard hat geschrieben:
    Thanks - that works just fine, although we may still need to force the unlock in case some team member has left the project locked by accident.

    If it is a object in a project, which is under version control, you can use the following code to unlock it:

    if obj.svn.is_versioned and obj.svn.is_locked:
       obj.svn.unlock()
    

    BR
    Martin

     

Log in to post a comment.