Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

need python example of loading project from a svn revision

anson2004
2016-03-02
2016-11-18
  • anson2004 - 2016-03-02

    Hi,

    I am new to Codesys Python script language.

    I want to setup a build system and later deploy it to Jenkins CI.

    The first prototype of build system might include following 1 SVN checkout 2 set and open a project 3 load/install library 4 compile and login

    I follow this post l viewtopic.php?t=1890 l and successfully open a project and print the value. But with SVN example it failed and I do not understand how this svn code checkout repo even.

    So could someone provide a python example of checkout svn repo first, then setup a Codesys project? It is even better if there is a way to include library.

    Also I would like to know where could I find the document of python script? It will be useful for me to see how much I can do using python script.

    Best regard,

    Yiqing

     
  • mkeller - 2016-03-02

    Hi anson2004.

    anson2004 hat geschrieben:
    I follow this post l viewtopic.php?t=1890 l and successfully open a project and print the value. But with SVN example it failed and I do not understand how this svn code checkout repo even.

    anson2004 hat geschrieben:
    So could someone provide a python example of checkout svn repo first, then setup a Codesys project? It is even better if there is a way to include library.

    \# checkout my project
    svn.checkout("svn://svnserver/somefolder/MyProject", r"c:\temp", "MyProject")
    

    anson2004 hat geschrieben:
    Also I would like to know where could I find the document of python script? It will be useful for me to see how much I can do using python script.

    You can find the API documentation "ScriptEngine.chm" in the sub directory OnlineHelp in the CODESYS main directory. The API documentation "ScriptEngine_SVN_4040.chm" can be found in one of its sub directories.

    BR
    Martin

     
  • anson2004 - 2016-03-03

    Hi Martin,

    Thank you very much.

    The svn checkout work.

    I have a problem after svn checkout. I try to login to a specific target device using set_gateway_and_address method. I specify correct guid and address. But I got runtime error:

    Exception: The object 'Device' cannot be modified because it could not be locked in the SVN repository.
    Details: Path '/svn_url/Device/svnobj' is already locked by user 'xxx.xx' in filesystem 'a6267ff8-34b0-244c-8b93-125bfbd9a58b'

    What could go wrong?

    Yiqing

     
  • mkeller - 2016-03-03

    Hi anson2004.

    anson2004 hat geschrieben:
    Exception: The object 'Device' cannot be modified because it could not be locked in the SVN repository.
    Details: Path '/svn_url/Device/svnobj' is already locked by user 'xxx.xx' in filesystem 'a6267ff8-34b0-244c-8b93-125bfbd9a58b'

    Set the automatic locking in the SVN settings (see Options) to "Never acquire a lock automatically" and try again.

    BR
    Martin

     
  • DBe - 2016-06-17

    Hello together,

    svn checkout works? Really? How?
    What is the namespace ov svn.checkout()?
    What is the object that the function can be applied to?

    Within docs I found SubversionIntegration.ScriptDriver - but how to use it?
    Within forum I found "Find some API within ScriptEngine_SVN_4040.chm"
    Within this forum I found several approaches:
    1. svn.checkout() or projects.primary.svn.checkout?
    2. system.commands["svn", "copy"].execute("svn://new/destination/url", "false", "commit message")
    3. os.popen('"' + SVNEXE + '" cat ' + XMLURL, 'r') as pipe:....

    Does any of these ideas work for checkout?

    Best regards
    Dirk

     
  • mkeller - 2016-06-20

    Hi DBe.

    DBe hat geschrieben:
    Within this forum I found several approaches:
    1. svn.checkout() or projects.primary.svn.checkout?
    2. system.commands["svn", "copy"].execute("svn://new/destination/url", "false", "commit message")
    3. os.popen('"' + SVNEXE + '" cat ' + XMLURL, 'r') as pipe:....

    If you have CODESYS SVN you can use the API described in the of the CHM file . For example, you can checkout a project using svn.checkout('url', 'directory', 'project_name') in a python script and run it in CODESYS.

    If you don't have CODESYS SVN you can only work with the normal files. For example, you can checkout a project file and open it in CODESYS but you don't have any SVN features or operation inside CODESYS.

    BR
    Martin

     
  • DBe - 2016-06-29

    Hi Martin,

    in fact we use Tortoise SVN and ENI Server for storing Codesys sources.
    We don't store the projects due to their size and other collaboration reasons.
    So I assume Tortoise SVN sources can not be checked out by Codesys SVN, right or wrong?
    One possible solution that appears to me could be:
    1. Store Codesys sources with Tortoise SVN
    2. Use Codesys SVN to check out sources via API for continous integration build process only
    If Tortoise and Codesys SVN can coexist just for a simple check-out then investing 500€ for this package will be my preferred solution.

    Best regards
    Dirk

     
  • Anonymous - 2016-06-30

    Originally created by: M.Schaber

    Hi,

    the CODESYS SVN AddOn stores the CODESYS projects as a tree of files and directories, so you can commit and compare on a per-object basis.

    As CODESYS projects are "natively" stored in an object database, the mapping is not straight forward, and you won't be able to work on CODESYS Sources using TortoiseSVN.

    On the other hand, the SVN AddOn will not work with a CODESYS project file stored with TortoiseSVN.

    As you write about ENI server - this product is not really supported any more (for CODESYS V3).

    HTH,
    Markus

     
  • DBe - 2016-11-18

    Hi,

    is it possible to give svn user and password as a parameter to svn.checkout or similiar (e.g. AuthenticationRequest)?
    Or should I go with the auth cache set manually for each user within Codesys UI?

    Reason: A build server script would like to access the codesys machine via ssh, programatically do a checkout of a project and codesys build.

    Best regards
    Dirk

     
  • mkeller - 2016-11-18

    Hi DBe.

    DBe hat geschrieben:
    is it possible to give svn user and password as a parameter to svn.checkout or similiar (e.g. AuthenticationRequest)?
    Or should I go with the auth cache set manually for each user within Codesys UI?

    Some example code:

    def set_username(req):
    Β  Β  print_all(req)
    Β  Β  req.username = "userX"
    Β  Β  req.password = "test"
    Β  Β  req.save = True # Optional
    svn.auth_username_password += set_username
    \#svn.checkout(...)
    

    For more details please look at the Scripting API for SVN which is installed with the CODESYS SVN Add-On.

    BR
    Martin

     
  • DBe - 2016-11-18

    Hi Martin,

    thank you again - this works fine for all ssh scenarios and users!
    No auth cache needed anymore

    Best regards
    Dirk

     

Log in to post a comment.