header

Using the Python Client API

The Python client for AMGA is distributed in the in the glite.amga.api-python RPM. After installation the amga package is available with the mdclient and mdinterface modules. The mdclient class offers an interface similar to the MDClient interface in C++ plus methods for most AMGA command. All arguments are automatically quoted before being sent to the server.

The following is an example script which creates a directory, cd's into it and then gets the "sin" and "events" attributes of all entries in the directory.

  #!/usr/bin/env python

  #import amga classes
  from amga import mdclient, mdinterface

  #instantiate an AMGA client connecting to localhost:8822 as 'guest'
  client = mdclient.MDClient('localhost', 8822, 'guest')

  try:
      print "Creating directory /pytest ..."
      client.createDir("/pytest")    
  except mdinterface.CommandException, ex:
      print "Error:", ex

  try:
      print "cd /pytest"
      client.cd("/pytest")
  except mdinterface.CommandException, ex:
      print "Error:", ex

  try:
      print "Getting all attributes of the files in /pytest..."
      client.getattr('/pytest', ['sin', 'events'])
      while not client.eot(): 
          file, values=client.getEntry()
          print "->",file, values
  except mdinterface.CommandException, ex:
      print "Error:", ex

Generated on Mon Apr 16 13:59:18 2012 for AMGA by  doxygen 1.4.7