rblog

Splitting text using Python

Created a script just to test how to split text using Python. First I have to split on the delimiter ‘__’, then on the ‘.’.

#!/usr/bin/python
propertyFilename="commons-ear__R01_INC_002.properties"
print propertyFilename
versionWithFileExt = propertyFilename.split('__')
print versionWithFileExt
version = versionWithFileExt[1].split('.')
print version
#And to get the final string
print version[0]

Not that hard, but what confused me when reading the Python documentation was that str.split() is deprecated. But as it turned out, that is in version 2.7, currently we are using 2.4, find out by issuing the command
ls -l /usr/bin/python*

From version 2.7 you should instead use stringObject.rpartition(sep), see more at about.com

Adding a description when installing an application using wsadmin

Using wsadmin to install an application I wanted to add a description to an application edition. Was not able to find any documentation telling me what are valid parameters to apply to the options string, so I just tried “-description”, returning the error

WASX7107E: Invalid options specified: "[description]"; valid options are:
CloneWorkClassClientTask
MapModulesToServers
BindJndiForEJBNonMessageBinding
BindJndiForEJBMessageBinding
MapEJBRefToEJB
MapWebModToVH
CtxRootForWebMod
EnsureMethodProtectionFor20EJB
MapSharedLibForMod
SharedLibRelationship
JSPCompileOptions
JSPReloadForWebMod
CustomActivationPlan
GetServerName
preCompileJSPs
nopreCompileJSPs
distributeApp
nodistributeApp
useMetaDataFromBinary
nouseMetaDataFromBinary
deployejb
nodeployejb
createMBeansForResources
nocreateMBeansForResources
reloadEnabled
noreloadEnabled
deployws
nodeployws
processEmbeddedConfig
noprocessEmbeddedConfig
allowDispatchRemoteInclude
noallowDispatchRemoteInclude
allowServiceRemoteInclude
noallowServiceRemoteInclude
useAutoLink
nouseAutoLink
usedefaultbindings
defaultbinding.force
allowPermInFilterPolicy
noallowPermInFilterPolicy
verbose
update
update.ignore.old
update.ignore.new
installed.ear.destination
appname
edition
edition.desc
reloadInterval
validateinstall
filepermission
buildVersion
blaname
asyncRequestDispatchType
deployejb.rmic
deployejb.dbtype
deployejb.dbschema
deployejb.classpath
deployejb.dbaccesstype
deployejb.sqljclasspath
deployejb.complianceLevel
deployws.classpath
deployws.jardirs
defaultbinding.datasource.jndi
defaultbinding.datasource.username
defaultbinding.datasource.password
defaultbinding.cf.jndi
defaultbinding.cf.resauth
defaultbinding.ejbjndi.prefix
defaultbinding.virtual.host
defaultbinding.strategy.file
filepermission
target
server
node
cell
cluster
contextroot
custom
installed.ear.destination

So, in order to get the information, just create an error 🙂

The Fog of War

Spent the evening in front of the tv instead of going to bed early…damn! But, it was worth it – Swedish Television showed the movide “The Fog of War

The Fog of War: Eleven Lessons from the Life of Robert S. McNamara is a 2003 American documentary film about the life and times of former U.S. Secretary of Defense Robert S. McNamara.

[video:youtube:VgA98V1Ubk8]

Very interesting to hear McNamara telling the story himself. I am sure that McNamara wasn’t flawless, but that does not make it a good movie worth spending time seeing.

More than 100 times using my bike to work this year

Last Friday I had my 100’th time using my bike to work this year, which gives me about 3600 kilometers just commuting. What better way to celebrate that than having several large pieces of Vidars 50’th birthday cake, made all out of white chocolate, it was delicious!!!

Vidar starting the celebration having the first piece

Switch-case statement in Phyton

I’m not all that familiar with Phyton, but since Jython ,which is the Java implementation of Phyton, is the preferred scripting language for WebSphere I do need to dive into it now and then. Today I needed to check if input parameter to a script was equal to a given value, then check a property file for the corresponding key/value pair. If key/value pair not present then check if the common default value where there. If if all is false, then just break out of the script.

As you might have figured out this will get a bit messy, so I thought that maybe a switch-case statement could help me out to make it a bit cleaner. First I found this article at Bytebaker switch-case-statement-in-python showing a “fake” implementation of swich-case, since it turns out that Phyton does not have this functionality. “Yes!!!”, but then it turned out no…I read the comments to the post and at the end found the follow-up article “Switch-case statement in Python revisited“. So back to square one again…

Kiwi – not a good idea

At work we get a fruit basket twice a week. The past few weeks they have added a lot of kiwis which is a good idea in theory since kiwi is very good…but in real life at work, not such a good idea. We get a few plastic tools to help us eat the fruit, but it is not as sharp as a real knife making it impossible to peel the kiwi. And eating it with the spoon…did not turn out as I had hoped. Luckily I am an experienced kiwi eater so I had a paper towel underneath, but still, look at the result

Fire drill at work – what a lovely day!

When I was about to enter the building and go down to the locker room today I was a bit surprised since so many people where on their way out. Realized fast what is was since there where some of them where walking around with reflective vests. So I just had to turn around and go out and enjoy the sun. Good thing, since I then had time to do some stretching as well. Played around with my cell phone in the nice weather, took pictures of all the people outside, me in the sun, my new mtb shoes in the sun, people walking in to the building in the sun. Not the worst thing that could happen 🙂