{"id":392,"date":"2015-11-12T20:37:58","date_gmt":"2015-11-13T04:37:58","guid":{"rendered":"https:\/\/www.pnfsoftware.com\/blog\/?p=392"},"modified":"2015-11-13T09:38:44","modified_gmt":"2015-11-13T17:38:44","slug":"writing-jeb2-scripts-in-python","status":"publish","type":"post","link":"https:\/\/www.pnfsoftware.com\/blog\/writing-jeb2-scripts-in-python\/","title":{"rendered":"Writing client scripts for JEB2 using Python"},"content":{"rendered":"<p>The latest\u00a0release of JEB2, <a href=\"https:\/\/www.pnfsoftware.com\/jeb\/changelist\">version 2.0.14<\/a>, introduces a feature familiar\u00a0to JEB1 users: <strong>client scripts written in Python<\/strong>.<\/p>\n<p>Both Standard and Business licenses permit running\u00a0scripts. They can be written using the Python 2.5 or 2.7 syntax and features, and are executed by\u00a0<strong>Jython<\/strong>. (A <a href=\"http:\/\/www.jython.org\/dowload.html\">Jython stand-alone package<\/a> is required to run scripts. We recommend version 2.5. Download it and drop it in your JEB2\u00a0<em>scripts\/<\/em>\u00a0sub-directory.)<\/p>\n<p>Feature-wise, scripts use the standard JEB2 core APIs. They are also using the client API, available in the <strong>com.pnfsoftware.jeb.client.api<\/strong> package. As usual, refer to our <a href=\"https:\/\/www.pnfsoftware.com\/jeb\/devportal\">Developer Portal<\/a> and <a href=\"https:\/\/www.pnfsoftware.com\/jeb\/apidoc\">Javadoc website<\/a> for API reference and usage.<\/p>\n<p>A client script implements the <strong>IScript<\/strong> interface. Upon execution, the script <strong>run()<\/strong> entry-point method is provided an <strong>IClientContext<\/strong> or derived object, such as an\u00a0<strong>IGraphicalClientContext<\/strong> for UI clients. (The official RCP desktop client falls in the latter category.)<\/p>\n<p>Here is the simplest of all scripts:<\/p>\n<pre>from com.pnfsoftware.jeb.client.api import IScript\r\nclass JEB2SampleScript(IScript):\r\n  def run(self, ctx):\r\n    print('Hello, JEB2')<\/pre>\n<p>Within the official desktop client, scripts can be executed via the <strong>File, Scripts<\/strong> menu item.<\/p>\n<p>Finally, remember that scripts are meant to execute small, light-weight actions. Heavy lifting operations (such as parsing or background event-driven tasks) should be implemented by back-end plugins in Java.<\/p>\n<p><strong>Check out <a href=\"https:\/\/github.com\/pnfsoftware\/jeb2-samplecode\/tree\/master\/scripts\">our GitHub repository for more sample scripts<\/a>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The latest\u00a0release of JEB2, version 2.0.14, introduces a feature familiar\u00a0to JEB1 users: client scripts written in Python. Both Standard and Business licenses permit running\u00a0scripts. They can be written using the Python 2.5 or 2.7 syntax and features, and are executed by\u00a0Jython. (A Jython stand-alone package is required to run scripts. We recommend version 2.5. Download &hellip; <a href=\"https:\/\/www.pnfsoftware.com\/blog\/writing-jeb2-scripts-in-python\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Writing client scripts for JEB2 using Python<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8],"tags":[],"class_list":["post-392","post","type-post","status-publish","format-standard","hentry","category-api-jeb2","category-jeb2"],"_links":{"self":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=392"}],"version-history":[{"count":0,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/392\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}