[FRPythoneers] Seeking Help - Java ByteArray in Python

Lawrence Tilly lawrence.tilly at gmail.com
Mon Feb 25 10:02:49 MST 2013


Greetings all.

I have been a lurker since 2010 but haven't had much need to post yet.  I
have need however for some assistance and hope someone here can provide
some guidance.

My primary use of Python (technically Jython) is as a systems admin, mostly
for IBM WebSphere based products.  I've been using WAS for over a decade
but up until a couple years ago IBM's administrative language of choice was
jacl which is what I had done most previous work in.  During our last major
upgrade we moved to IBM's new go-forward of Jython (and there was much
rejoicing).  I developed and support a pretty thorough administration and
deployment library our company has been using for IBM's WebSphere, Portal
and Process Server technologies.  For the most part what I can't work out
quickly from the docs and trail/error I've been able to resolve via google
and it's all been a very enjoyable and rewarding process so far.  Recently
though I've hit a wall.

We have brought in a new WebSphere component, WODM (a rules engine), and
I'm integrating the administrative and deployment functionality into my
library.  For a number of frustrating reasons however IBM does not cleanly
support RuleApp deployment via their WebSphere command line interface
(wsadmin).  Instead they have ant and java techniques for deployment.  The
functionality is there in wsadmin, but only bare documentation.  Using
what's available I quickly worked out most administrative tasks we need to
automate but I'm having a problem with part of the "install a new ruleapp"
effort.

In short, I am stumped on how to produce a byte array from a local jar file
which needs to be passed as a parameter.  I am doing most of this work
calling one of the WODM administrative mbeans and have no problem with any
of the other commands against it.

http://pic.dhe.ibm.com/infocenter/dmanager/v7r5/topic/com.ibm.dserver.reference.res/html/api/html/ilog/rules/res/model/mbean/IlrJMXRepositoryMBean.html
(importRuleApps)

I have an example of how this byte array is being created in java (as I
said, I have examples of this process using the java API):

private byte[] getContentOfRuleAppArchive(File jarFileName) throws
IOException {
       ByteArrayOutputStream jarContent = new ByteArrayOutputStream();
       FileInputStream is = null;
       try {
           is = new FileInputStream(jarFileName);

           byte[] buffer = new byte[1024];
           int i = 0;
           while ((i = is.read(buffer)) != -1) {
               jarContent.write(buffer, 0, i);
           }
       } finally {
           if (is != null)
               is.close();
       }

       return jarContent.toByteArray();
   }

...but have been unable to duplicate this in Python.  I have found a few
examples on the web but keep getting an 'invalid archive' exception so I'm
obviously not doing it right.  Any assistance here would be GREATLY
appreciated.

For those of you not familiar with WebSphere, IBM packs a pretty old
version of Python in the product.

wsadmin>sys.version_info
(2, 1, 0, 'final', 0)


I have used some external libraries in the past for XML management though
so if what I need to do has to be done via an external library I can
probably do that.  But I'd prefer a solution that works directly with the
bundled version in case something comes up for support down the road.


I can happily provide a little more specifics but don't want to clog up the
list here if not needed.

advTHANKSance!
-Lawrence
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.community.tummy.com/pipermail/frpythoneers/attachments/20130225/56c4c494/attachment.html>


More information about the FRPythoneers mailing list