Update README
[vzubcmon.git] / resource.py
blobffe0e74a6bab7c678cad9bfaa9c58eba4033e741
1 # coding: utf-8
2 """
3 Author: Enrico Tröger
4 License: GPLv2
5 """
7 ###########################################################################
8 class VzUbcMonResource(object):
9 """
10 Simple data structure to represent a UBC resource
11 """
13 #----------------------------------------------------------------------
14 def __init__(self, held=None, maxheld=None, barrier=None,
15 limit=None, failcnt=None, resource_seq=None):
16 if resource_seq:
17 self.held = int(resource_seq[0])
18 self.maxheld = int(resource_seq[1])
19 self.barrier = int(resource_seq[2])
20 self.limit = int(resource_seq[3])
21 self.failcnt = int(resource_seq[4])
22 else:
23 if not isinstance(held, basestring)and not isinstance(held, int):
24 raise AttributeError('You must specify either a resource using keyword arguments or a complete resource sequence')
25 self.held = int(held)
26 self.maxheld = int(maxheld)
27 self.barrier = int(barrier)
28 self.limit = int(limit)
29 self.failcnt = int(failcnt)
31 #----------------------------------------------------------------------
32 def __repr__(self):
33 return '%s:%s (%s)' % (self.barrier, self.limit, self.failcnt)