Home

Download

Higthligths

Firsteps

Tutorial

Advocacy

Specs&soluces

Docs

Faq

About AskApy

Contact

Admin

Tutorial




Create
  1. Introduction

    Before to run this tutorial, you should check or customize the ready to use examples
    provided in the cube mycub. For this purpose see firstep.

  2. Creation of our own Cube (ourcub)

    A cube is a directory, here named ourcub, created in one of the two deployment directory of AskApy.
    AskApy's deployement directories are listed below.

    Family global deployment directory :
    <INSTALL_DIR>\askapy\families\conf\<FAMILY>\apbs
    Child specific deployment directory :
    <INSTALL_DIR>\askapy\families\conf\<FAMILY>\<FAMILY>\apbs\

    _ Create the empty directory ourcub under the <INSTALL_DIR>\askapy\families\conf\<FAMILY>\apbs directory.

    For more information about AskApy directories organization see the Directory structure.
    For more information about cubes, from the command line type doc.py cube.

  3. Creation of our own Apb (OurApb)

    In this example the task do_ourtask run an existing script and return the exit code :

    from apy.apb import Apb

    class OurApb(Apb):
    def do_ourtask(self, *args, **keywords):
    profil, dir, list=keywords['profil'], keywords['dir'], keywords['list']
    import os

    l=''
    if list:l=' -l'

    return {'result':os.system('ourscript.bat' + ' -p ' + profil + ' -d ' + l)}


    _ Write this code into the file ourmodule.py under the directory ourcub.
    _ Create the empty file __init__.py under the directory ourcub.



  4. Declarion of our new Apb

    1. Cube.xml

      OurApb must be declared in the cube.xml file.
      _ Write the text below into the file cube.xml under the directory ourcub/CAR-INF (note: CAR-INF also must be created).

      <Cube Name="ourcub" module="ourcub.ourmodule">
           <LoadModule STartup="yes"/>
           <Roles/>

           <!-- Who can use this Cube -->
           <Authorized_roles>
                *anyone
           </Authorized_roles>

           <Apbs>

           <Apb Name="OurApb" default="yes">
                <!-- Who can use this Apb -->
                <Authorized_roles>
                     *anyone
                </Authorized_roles>

                <Tasks>
                     <Task Name="do_ourtask" default="yes">
                     <!-- Who can use this Task -->
                     <Authorized_roles>
                          *anyone
                </Authorized_roles>
                </Task>

           </Apb>

      </Cube>


    2. Cube_mapping.xml

      Create a dummy cube_mapping, empty because we have no role to map, our cube not being restricted to any role.
      _ Write the text below into the file cube_mapping.xml under the directory ourcub/CAR-INF.

      <Cube_mapping>
           <Roles/>
      </Cube_mapping>


    3. Declaring parameters

      Because AskApy needs to know what you parameters are, you need to declare them in a specific file:
      the parameters descriptor file.
      _ Create the file parameter.py under the directory ourcub/ourmodule_desc (note: ourmodule_desc also must be created).
      _ Create the empty file __init__.py under the directory ourcub/ourmodule_desc.

      _ Write the code below into parameter.py.

      from apy.optd import optdefinition as optdf
      from apy.task.apb_desc.parameter import Apb

      class OurApb(Apb):
      def do_ourtask(self, optBib, keywords=None):
      """
      This is a Parameter descriptor method for the task do_ourtask of the Apb OurApb.
      """
      optBib.setOptHelp('Global help.')
      optBib.setOptUsage('--profil PROFIL, --dir DIR --list')

      # You can group your options. You may have as many group you like.
      optgroup = optdf.OptGroup(name = "OurGroup", help ="An help text for option's group OurGroup.")
      optBib.add(optgroup)

      # This creates an option for the parameter profil.
      optdef = optdf.OptDefinition(name = "profil", wk ={'*type': 'str', '*required':True}, shortName = "p", longName = "profil", help = "Profils to treat.")
      optgroup.add(optdef)

      # This creates an option for the parameter dir.
      optdef = optdf.OptDefinition(name = "dir", wk ={'*checkIn':('conf', 'logs', 'list')}, shortName = "d", longName = "dir", help = "Directories to treat.")
      optgroup.add(optdef)

      # This creates an option for the parameter list. optdef = optdf.OptDefinition(name = "list", wk ={'*type': 'bool', '*withCoolTyping':True}, shortName = "l", longName = "list", typ = bool(1), help = "Do list directories ?")
      optgroup.add(optdef)


      Note
      if you do not declare the OurApb class, in parameter.py, AskApy will assume that your task supports only one string parameter.


    At this step our cube looks like this :

    <INSTALL_DIR>\askapy\families\conf\<FAMILY>\apbs\
         ourcub
              __init__.py
              ourmodule.py
              CAR-INF
                   cube.xml
              ourmodulle-desc
              ourmodulle-desc\__init__.py
                   parameter.py



Use

_ Restart the child (ex child10)

child.py child10@child0 -s -k _u admin _p pass
child.py child10@child0 -s

Graphically
From the browser :
Type in the address bar http://127.0.0.1:8012/cub/ourcub/apb/OurApb/task/do_ourtask
From the AskApy graphical tools :
From a command line type view.py http://127.0.0.1:8010/cub/ourcub/apb/OurApb/task/do_ourtask
Note
Because we said default="yes" in these two line of the cube.xml:
<Apb Name="OurApb" default="yes">
<Task Name="do_ourtask" default="yes">
You can also simply type http://127.0.0.1:8012/cub/ourcub to access to the task do_ourtask of the Apb OurApb.

In text mode
From a command line type
ask.py _l {boot:child10@child0,cub:ourcub,apb:OurApb} _u paul _p pass
ask.py _t hello -n john -a 30
Note (1)
If you are on the same machine as child10 it easier to type :
ask.py _l {boot:child10@child0,cub:ourcub,apb:OurApb} _u paul _p pass
This way, you do not bother with ports or eitheir ssl is on or not.
Because of this syntax, if secure is True in the preferences.attrs file, ssl is set for the communication
and ssl client files are implicitly retreived too.

From a python client
from apy.clt import ask
apb=ask.IApb(apb_ual={'boot':'localhost:8010', 'cub':'ourcub', 'apb':'OurApb'}, apb_user='paul', apb_password='pass')
print apb.hello(name='john', age=30)
Note
If you are on the same machine as child10 it easier to type :
apb_ual={'boot':'child10@child0', 'cub':'ourcub', 'apb':'OurApb'}.
See Note (1).



Enhance



  1. Introduction

    At this stage when you run your task in graphical mode, it looks like this:
    view snapshot.
    browser snapshot.