def run(self): users = getActiveUsers(self.env.config) dirsDB = self.env.config.getSection('cp.backendpaths.countpaths') option = getUserOptions(self.env.config, ['diskspaceUsed'])[0][0] odirs = '' for dir in dirsDB: d = dir.values()[0] if d[0] == 'textarea': odirs += d[1].strip() + "\n" # parse dirs with options odirs = parseOptions(odirs, self.env.config) for user in users: # parse dirs with userdata dirs = parseUser(odirs, user) dirs = dirs.splitlines() bytes = 0.0 for dir in dirs: dir = dir.split(":") # empty dirs are not good if dir[0] is '': continue exclude = [] if len(dir) > 1 and dir[1] != '': # are there dirs to exclude? exclude = dir[1].split(",") bytes += self.getDirSize(dir[0], exclude) # turn bytes to megabytes bytes /= 1024 * 1024 # update user self.env.db.query("UPDATE wcf" + self.env.wcfnr + "_user_option_value \ SET userOption" + str(option) + " = '" + str(bytes) + "' \ WHERE userID = " + str(user["userID"])) return 'success'
def run(self): users = getActiveUsers(self.env.config) dirsDB = self.env.config.getSection('cp.backendpaths.countpaths') option = getUserOptions(self.env.config, ['diskspaceUsed'])[0][0] odirs = '' for dir in dirsDB: d = dir.values()[0] if d[0] == 'textarea': odirs += d[1].strip() + "\n" # parse dirs with options odirs = parseOptions(odirs, self.env.config) for user in users: # parse dirs with userdata dirs = parseUser(odirs, user) dirs = dirs.splitlines() bytes = 0.0 for dir in dirs: dir = dir.split(":") # empty dirs are not good if dir[0] is '': continue exclude = [] if len(dir) > 1 and dir[1] != '': # are there dirs to exclude? exclude = dir[1].split(",") bytes += self.getDirSize(dir[0], exclude) # turn bytes to megabytes bytes /= 1024*1024 # update user self.env.db.query("UPDATE wcf" + self.env.wcfnr + "_user_option_value \ SET userOption" + str(option) + " = '" + str(bytes) + "' \ WHERE userID = " + str(user["userID"])) return 'success'
def createHome(self, userID): user = self.env.db.queryDict( 'SELECT * \ FROM wcf' + self.env.wcfnr + '_user user \ JOIN cp' + self.env.cpnr + '_user cpuser ON (user.userID = cpuser.userID) \ WHERE user.userID = ' + userID)[0] dirsDB = self.env.config.getSection('cp.backendpaths.createpaths') dirs = '' for dir in dirsDB: d = dir.values()[0] if d[0] == 'textarea': dirs += d[1].strip() + "\n" dirs = dirs.strip() dirs = parseOptions(dirs, self.env.config) dirs = parseUser(dirs, user) self.env.logger.append('creating homedir for ' + userID + ': ' + dirs) dirs = dirs.splitlines() for dir in dirs: dir = dir.split(":") dir[2] = int(dir[2], 8) dir[3] = dir[3].split(".") dir[3][0] = getUID(dir[3][0]) dir[3][1] = getGID(dir[3][1]) mkPath(dir[0], dir[1], dir[2], dir[3][0], dir[3][1]) return 'success'
def createHome(self, userID): user = self.env.db.queryDict('SELECT * \ FROM wcf' + self.env.wcfnr + '_user user \ JOIN cp' + self.env.cpnr + '_user cpuser ON (user.userID = cpuser.userID) \ WHERE user.userID = ' + userID)[0] dirsDB = self.env.config.getSection('cp.backendpaths.createpaths') dirs = '' for dir in dirsDB: d = dir.values()[0] if d[0] == 'textarea': dirs += d[1].strip() + "\n" dirs = dirs.strip() dirs = parseOptions(dirs, self.env.config) dirs = parseUser(dirs, user) self.env.logger.append('creating homedir for ' + userID + ': ' + dirs) dirs = dirs.splitlines() for dir in dirs: dir = dir.split(":") dir[2] = int(dir[2], 8) dir[3] = dir[3].split(".") dir[3][0] = getUID(dir[3][0]) dir[3][1] = getGID(dir[3][1]) mkPath(dir[0], dir[1], dir[2], dir[3][0], dir[3][1]) return 'success'