|
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright Buildbot Team Members
# this class is known to contain cruft and will be looked at later, so # no current implementation utilizes it aside from scripts.runner.
""" Base class for services that manage users manually. This takes care of the service.MultiService work needed by all the services that subclass it. """
""" Perspective registered in buildbot.pbmanager and contains the real workings of `buildbot user` by working with the database when perspective_commandline is called. """
""" This formats the results of the database operations for printing back to the caller
@param op: operation to perform (add, remove, update, get) @type op: string
@param results: results from db queries in perspective_commandline @type results: list
@returns: string containing formatted results """
# list, alternating ident, uid else: # list of dictionaries # list, alternating ident, None # list of dictionaries else:
def perspective_commandline(self, op, bb_username, bb_password, ids, info): """ This performs the requested operations from the `buildbot user` call by calling the proper buildbot.db.users methods based on the operation. It yields a deferred instance with the results from the database methods.
@param op: operation to perform (add, remove, update, get) @type op: string
@param bb_username: username portion of auth credentials @type bb_username: string
@param bb_password: hashed password portion of auth credentials @type bb_password: hashed string
@param ids: user identifiers used to find existing users @type ids: list of strings or None
@param info: type/value pairs for each user that will be added or updated in the database @type info: list of dictionaries or None
@returns: results from db.users methods via deferred """
# get identifier, guaranteed to be in user from checks # done in C{scripts.runner} identifier=user)
else: else:
else: # get identifier, guaranteed to be in user from checks # done in C{scripts.runner} identifier=ident)
# if only an identifier was in user, we're updating only # the bb_username and bb_password. uid=uid, identifier=ident, bb_username=bb_username, bb_password=bb_password) else: log.msg("Unable to find uid for identifier %s" % user) else: # when adding, we update the user after the first attr uid=uid, identifier=ident, bb_username=bb_username, bb_password=bb_password, attr_type=attr, attr_data=user[attr]) else: log.msg("Unable to find uid for identifier %s" % user) identifier=ident, attr_type=attr, attr_data=user[attr])
# result is None from updateUser calls
""" Service that runs to set up and register CommandlineUserManagerPerspective so `buildbot user` calls get to perspective_commandline. """
"to connect and use `buildbot user`")
# set up factory and register with buildbot.pbmanager self.username, self.passwd, factory)
|