CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Wed Oct 18, 2017 4:59 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Mar 02, 2016 11:04 am 
Offline

Joined: Wed Nov 25, 2015 8:38 am
Posts: 4
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 viewtopic.php?t=1890 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


Top
   
PostPosted: Wed Mar 02, 2016 12:35 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 217
Hi anson2004.

anson2004 wrote:
I follow this post viewtopic.php?t=1890 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 wrote:
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.

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

anson2004 wrote:
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

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Thu Mar 03, 2016 1:47 pm 
Offline

Joined: Wed Nov 25, 2015 8:38 am
Posts: 4
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


Top
   
PostPosted: Thu Mar 03, 2016 2:42 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 217
Hi anson2004.

anson2004 wrote:
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

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Jun 17, 2016 12:50 pm 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
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


Top
   
PostPosted: Mon Jun 20, 2016 11:16 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 217
Hi DBe.

DBe wrote:
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 SubversionIntegration.ScriptDriver of the CHM file ScriptEngine_SVN_4040.chm. 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

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Wed Jun 29, 2016 2:08 pm 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
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


Top
   
PostPosted: Thu Jun 30, 2016 10:30 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
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

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Nov 18, 2016 11:15 am 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
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


Top
   
PostPosted: Fri Nov 18, 2016 12:34 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 217
Hi DBe.

DBe wrote:
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:
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

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Fri Nov 18, 2016 2:10 pm 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
Hi Martin,

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

Best regards
Dirk


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 11 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited