Changeset 11816 for main/waeup.kofa/trunk/src/waeup/kofa/utils
- Timestamp:
- 24 Sep 2014, 15:20:55 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_utils.py
r11815 r11816 46 46 utils.SYSTEM_MAX_LOAD['swap-mem'] = None 47 47 assert utils.expensive_actions_allowed() == True 48 # even not-set values won't block us 49 del utils.SYSTEM_MAX_LOAD['swap-mem'] 50 assert utils.expensive_actions_allowed() == True 48 51 49 52 @unittest.skipIf( -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r11815 r11816 318 318 """ 319 319 max_values = self.SYSTEM_MAX_LOAD 320 if max_values['swap-mem'] is not None: 321 swap_mem = psutil.swap_memory() 322 max_val = max_values['swap-mem'] 320 for (key, func) in ( 321 ('swap-mem', psutil.swap_memory), 322 ): 323 max_val = max_values.get(key, None) 324 if max_val is None: 325 continue 326 mem_val = func() 323 327 if isinstance(max_val, float): 328 # percents 324 329 if max_val < 0.0: 325 330 max_val += 100.0 326 if swap_mem.percent > max_val:331 if mem_val.percent > max_val: 327 332 return False 328 333 else: 334 # number of bytes 329 335 if max_val < 0: 330 max_val += swap_mem.total331 if swap_mem.used > max_val:336 max_val += mem_val.total 337 if mem_val.used > max_val: 332 338 return False 333 339 return True
Note: See TracChangeset for help on using the changeset viewer.