FAQ Set property value from command line

From DANSE

Q: How do I set the value of a property from the command line?

Use --<property-name>=<value>. Simple example: suppose I have an application myApp with the property "filename":

$ python myApp.py --filename=/home/tim/tmp/mostAmazingDataEver.nx5

More complicated example: suppose I have an application called yourApp that has a facility called FileReader that in turn has a property called filename:

$ python myApp.py --FileReader.filename=/home/tim/tmp/lessAmazingData.nx5

How do I set it from a .pml file?

Consider the second situation above, where an application named yourApp has a component named FileReader. We could create a file called FileReader.pml tp define the properties of the FileReader component. The easy way to create such a file is with inventory.py:

$ inventory.py --name=FileReader
creating inventory template in 'FileReader.pml'

FileReader.pml looks like this:

<?xml version="1.0"?>
<!--
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!                                 T. M. Kelley
!                   (C) Copyright 2005  All Rights Reserved
!
! {LicenseText}
!
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->


<!DOCTYPE inventory>

<inventory>

  <component name='FileReader'>
    <property name='key'>value</property>
  </component>

</inventory>


<!-- version-->
<!-- $Id$-->

<!-- Generated automatically by XMLMill on Mon Apr 11 15:03:31 2005-->

<!-- End of file -->

All we need to do is set the property named "filename" to the value we want. The value is the element content:

    <property name='filename'>/home/tim/tmp/lessAmazingData.nx5</property>

So the whole file looks like:

<?xml version="1.0"?>
<!--
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!                                 T. M. Kelley
!                   (C) Copyright 2005  All Rights Reserved
!
! {LicenseText}
!
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->


<!DOCTYPE inventory>

<inventory>

  <component name='FileReader'>
    <property name='filename'>/home/tim/tmp/lessAmazingData.nx5</property>
  </component>

</inventory>


<!-- version-->
<!-- $Id$-->

<!-- Generated automatically by XMLMill on Mon Apr 11 15:03:31 2005-->

<!-- End of file -->
Personal tools
Document Uploads/Links