@@ -0,0 +1,1288 @@
+#%0A# Copyright (c) 2005-2006 rPath, Inc.%0A#%0A# All Rights Reserved%0A#%0A%0Aimport os%0Aimport mint_error%0A%0A# the length of the maintenanceLockPath file is used as the maintenance mode%0A# as defined below. no file equates to a length of zero.%0A# the reason for this is that an os.stat is far cheaper than opening a file%0A# descriptor, and this function will potentially be called thousands of times%0A# per second.%0A%0ANORMAL_MODE  = 0%0ALOCKED_MODE  = 1%0A%0A# client side%0Adef getMaintenanceMode(cfg):%0A    if os.path.exists(cfg.maintenanceLockPath):%0A        return os.stat(cfg.maintenanceLockPath).st_size%0A    else:%0A        return NORMAL_MODE%0A%0A# call this thru xmlrpc only. must verify admin rights.%0Adef setMaintenanceMode(cfg, maintMode):%0A    if maintMode == NORMAL_MODE:%0A        try:%0A            os.unlink(cfg.maintenanceLockPath)%0A        except OSError, e:%0A            if e.errno != 2:%0A                raise%0A    else:%0A        f = open(cfg.maintenanceLockPath, 'w')%0A        f.write(chr(0) * maintMode)%0A        f.close()%0A%0Adef enforceMaintenanceMode(cfg, auth = None, msg = None):%0A    e = msg and mint_error.MaintenanceMode(msg) or mint_error.MaintenanceMode%0A    mode = getMaintenanceMode(cfg)%0A    if mode == NORMAL_MODE:%0A        return%0A    if auth is None:%0A        raise e%0A    if not auth.admin:%0A        raise e%0A

add maintenance.py