Changeset 6e33086 for fedd/federation/experiment_info.py
- Timestamp:
- Nov 28, 2011 7:34:11 PM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- ec3aa4d
- Parents:
- 45e880d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/experiment_info.py
r45e880d r6e33086 2 2 3 3 import copy 4 from datetime import datetime, timedelta 5 from numbers import Number 4 6 5 7 class allocation_info: … … 38 40 self.log = [] 39 41 self.alloc = { } 42 self.last_update = datetime.now() 40 43 41 44 def add_allocation(self, a): … … 47 50 def get_all_allocations(self): 48 51 return self.alloc.values() 52 53 def updated(self): 54 self.last_update = datetime.now() 55 56 def older_than(self, secs=None, dt=None): 57 """ 58 If the last update of this info was more than secs seconds ago, or 59 before dt (a datetime), return True. If both secs and dt or neither is 60 given return False. If the last update time is completelt unknown 61 (which should never happen) return True. 62 """ 63 if self.last_update is None: 64 return True 65 elif dt is None and isinstance(secs, Number): 66 return self.last_update + timedelta(seconds=secs) < datetime.now() 67 elif secs is None and isinstance(dt, datetime): 68 return self.last_update < dt 69 else: 70 return False 71 49 72 50 73 def get_info(self):
Note: See TracChangeset
for help on using the changeset viewer.