#!/usr/bin/python 

# Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2010.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import getopt

__author__ = "Elisabetta Ronchieri"

m={'-u':'used-space',
'-f':'free-space',
'-r':'reserved-space',
'-t':'total-space',
'-a':'available-space'}

s={'used-space':'', 
'free-space':'',
'reserved-space':'',
'total-space':'',
'available-space':''}

if __name__=="__main__":

  try:
    opts, args = getopt.getopt(sys.argv[1:], "u:f:r:t:a:")
  except getopt.GetoptError, err:
    # print help information and exit:
    print str(err) 
    sys.exit(2)

  for o, a in opts:
    if o in m.keys():
      s[m[o]]=int((int(a)*(1000*1000*1000))/(1024*1024*1024))
    else:
      sys.exit(2) 

  print s
