CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Mon Aug 21, 2017 10:32 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next
Author Message
 Post subject: Subversion
PostPosted: Fri Jul 20, 2012 3:23 pm 
Offline

Joined: Mon Jun 18, 2012 10:30 am
Posts: 2
Hi,

I am looking for an entry point to the script engine to use the subversion functionality.

The script example 4 only runs the svn.exe but the documentation on the ScriptEngine shows, there are interfaces for all svn functionalities like update, checkout, comit.

I am quite new to python (and even newer to IronPython) but I would expect something like this to work:

Code:
proj = projects.primary
print('Versioned:', proj.is_versioned())



I use CoDeSys 3.5 Patch 4 and the the SVN package (3.5.0.40)

Could you provide an example, please?

Best regards
Manuel


Top
   
 Post subject: Re: Subversion
PostPosted: Fri Jul 20, 2012 3:43 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi, Manuel,

As we will very likely support other versioning systems in the future, we did encapsulate the svn functions into their own namespace, to avoid collisions.

The "global" functions are provided by the "svn" object. Here's an example to access the log of an URL:
Code:
from __future__ import print_function

url = "svn://localhost/testrepo/trunk/";

log = svn.get_log(url, slice(-1, 100), 32);

for entry in log:
    print(entry.revision, entry.time, entry.message, entry.author, len(entry.changes))

print("Head revsion:", svn.get_log(url, -1)[0].revision)
   
print("... finished ...")

The project and object specific functions are encapsulated in a "svn" member:
Code:
from __future__ import print_function

proj = projects.primary

print(proj.svn.is_versioned)

proj.svn.commit("Testcommit")

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Tue Aug 21, 2012 6:25 pm 
Offline

Joined: Mon Jun 18, 2012 10:30 am
Posts: 2
Hi M. Schaber,

I didn't have time to test it, up to today.
But now it works fine (even with a couple of trailing semicolons :wink:)

I only had to change the url (of course) and the revision-slice:
Code:
head = svn.get_log(url, -1)[0].revision
log = svn.get_log(url, slice(0, head), 0)


My repository starts with revision 38 and I only get the last entry, when I start with -1.
But that doesn't really bother me.

Thanks a lot for the quick help.

Regards
Manuel


Top
   
 Post subject: Re: Subversion
PostPosted: Wed Aug 22, 2012 7:37 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi, Manuel,

Manuel_E wrote:
I didn't have time to test it, up to today.
But now it works fine (even with a couple of trailing semicolons :wink:)


Sorry for them, it seems I'm clearly writing too much C# code nowadays. I'll try to get a doctors certificate for semicolonitis, and then re-negotiate my contract here. :-)

Manuel_E wrote:
I only had to change the url (of course) and the revision-slice:
Code:
head = svn.get_log(url, -1)[0].revision
log = svn.get_log(url, slice(0, head), 0)


My repository starts with revision 38 and I only get the last entry, when I start with -1.


In Subversion, -1 is the head revision, 0 is the "empty" non-revision in an empty repository before the first commit, and 1 is the first actually committed revision.

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Fri Jul 25, 2014 4:58 pm 
Offline

Joined: Tue Apr 13, 2010 1:59 pm
Posts: 21
Hello,

Is there a way to get the working copy information as stated in SVN_VERSION_INFO?
This would be useful to get, at least, the repository URL, and if the working copy is clean, etc.

This object is non exportable in PLCOpenXML, or native format, and I dont see any members in the scriptlib that allow its access.
the get_log method needs the URL and posts information as seen on the server, regardless of the working copy.

Thank you!


Top
   
 Post subject: Re: Subversion
PostPosted: Mon Jul 28, 2014 2:32 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi,

There are two entries in our issue database to enable this functionality:

SVN-33: Expose essential information of versioned objects and projects - this aims to expose information like status, working copy info, log etc. via scripting API.

SVN-185: Allow read-only access to SVN_VERSION_INFO object - this will expose the ST declaration code as read-only text to the script.

(External web access to the Jira database for the SVN product may not yet work, this problem is currently worked on.)

As usual, you can use your official support contact to get you listed as an interested customer in those issues.

PLCOpenXML Export is currently not planned, but if there is explicit demand, we may as well include it. You can file this as a "Requirement" using your support contact.

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Mon Jul 28, 2014 2:36 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi,

After some short discussion with our product management, I did file PLCOpenXML export as SVN-187.

HTH!

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Mon Jan 19, 2015 5:23 pm 
Offline

Joined: Mon Sep 26, 2005 2:16 pm
Posts: 22
Any suggestions that would detail how to SVN update the entire project via Python Script.

e.g. looking for python equivalent of:
>>Project>>SVN>>Update Project


Pointer to proper documentation would be greatly appreciated.


Regards,

John.


Top
   
 Post subject: Re: Subversion
PostPosted: Mon Jan 19, 2015 5:35 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 203
Hello jking22.

To update a versioned project you call the method update() on the project object:
Code:
proj = projects.primary
proj.update()

You find the SVN related documentation in the ScriptEngine documentation (sub-directory OnlineHelp in the CODESYS directory) under _3S.CoDeSys.SubversionIntegration.ScriptDriver.

BR
Martin

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Mon Jan 19, 2015 7:16 pm 
Offline

Joined: Mon Sep 26, 2005 2:16 pm
Posts: 22
Thanks Martin,

This helps.

A few comments though...
1. I think/hope you mean "proj.svn.update()" rather than "proj.update()"... I had to change this to get it to work properly.

2. The help file seems quite confusing. Do you have a list of common objects? e.g.
*proj.svn.
*project.static_Analysis.???
*Others?


Top
   
 Post subject: Re: Subversion
PostPosted: Tue Jan 20, 2015 10:14 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 203
Hello jking22.

jking22 wrote:
1. I think/hope you mean "proj.svn.update()" rather than "proj.update()"... I had to change this to get it to work properly.

2. The help file seems quite confusing. Do you have a list of common objects? e.g.
*proj.svn.
*project.static_Analysis.???
*Others?

1.) You are right. I never used the SVN Integration with Scripting. I looked through the documentation but missed the part about the ".svn".
2.) Sorry, but that's the only documentation we have right now. You could try the build-in method dir([object]) to find the modules, classes and objects. See the python documentation.

BR
Martin

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Tue Jan 20, 2015 10:45 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
We know that the current presentation of the documentation is suboptimal, at least, and we have plans to improve the documentation by making it more "pythonic" and include it directly in the online help, in a similar process as we currently establish for the IEC libraries.

However, other task currently have higher priority, so it was never scheduled for a release.

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

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


Top
   
 Post subject: Re: Subversion
PostPosted: Thu Aug 25, 2016 1:17 pm 
Offline

Joined: Mon Aug 08, 2016 11:51 am
Posts: 3
Any idea why this following snippet throws ArgumentTypeException when trying to update project with revision number (see comments)...seems that update_to wants to work with timestamp and refuses to take revision number as a parameter...which in our case is irrelevant.

from __future__ import print_function

from scriptengine import *

import datetime
# 30/06/16 18:00
date = datetime.datetime(2016, 06, 30, 18, 00)

projectpath = r'c:\work\Pythontrunk\trunkpython.project'

proj = projects.open(projectpath)

#proj.svn.update() # updates to head, works well

"""
void update_to(
long revision,
bool recursive = true,
bool omit_externals = false
)
"""

proj.svn.update_to(867, True, False) # doesn't work: "expected DateTime, got int"
#proj.svn.update_to(long(867), True, False) # doesn't work: "expected DateTime, got long"
#proj.svn.update_to(date, True, False) # even this doesn't work : "expected DateTime, got datetime"

projects.primary.save()


Top
   
 Post subject: Re: Subversion
PostPosted: Fri Aug 26, 2016 3:47 pm 
Offline

Joined: Wed Aug 03, 2016 3:00 pm
Posts: 8
lauriollila wrote:
Any idea why this following snippet throws ArgumentTypeException when trying to update project with revision number (see comments)...seems that update_to wants to work with timestamp and refuses to take revision number as a parameter...which in our case is irrelevant.
I can reproduce this error. but i found two workarounds. ether you can user something like:
proj.svn.update_to(867)
or
proj.svn.update_to(revision=867,recursive=True,omit_externals=false).


M.Schaber wrote:
SVN-33: Expose essential information of versioned objects and projects - this aims to expose information like status, working copy info, log etc. via scripting API.
I am curoius about this issue, but i have no access to Jira.
I need to get the svn-revision number of a manually checked out project.


Top
   
 Post subject: Re: Subversion
PostPosted: Tue Sep 06, 2016 8:55 am 
Offline

Joined: Wed Aug 03, 2016 3:00 pm
Posts: 8
Can please someone look up if "SVN-33" is planned?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next

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:  
Powered by phpBB® Forum Software © phpBB Limited