"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/data/connector.py" between
buildbot-3.0.2.tar.gz and buildbot-3.1.0.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

connector.py  (buildbot-3.0.2):connector.py  (buildbot-3.1.0)
skipping to change at line 16 skipping to change at line 16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details. # details.
# #
# You should have received a copy of the GNU General Public License along with # 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 # this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Copyright Buildbot Team Members # Copyright Buildbot Team Members
import functools
import inspect import inspect
import textwrap
from twisted.internet import defer from twisted.internet import defer
from twisted.python import reflect from twisted.python import reflect
from buildbot.data import base from buildbot.data import base
from buildbot.data import exceptions from buildbot.data import exceptions
from buildbot.data import resultspec from buildbot.data import resultspec
from buildbot.data.types import Entity
from buildbot.util import pathmatch from buildbot.util import pathmatch
from buildbot.util import service from buildbot.util import service
class Updates: class Updates:
# empty container object; see _scanModule, below # empty container object; see _scanModule, below
pass pass
class RTypes: class RTypes:
# empty container object; see _scanModule, below # empty container object; see _scanModule, below
pass pass
class DataConnector(service.AsyncService): class DataConnector(service.AsyncService):
submodules = [ submodules = [
'buildbot.data.build_data',
'buildbot.data.builders', 'buildbot.data.builders',
'buildbot.data.builds', 'buildbot.data.builds',
'buildbot.data.buildrequests', 'buildbot.data.buildrequests',
'buildbot.data.workers', 'buildbot.data.workers',
'buildbot.data.steps', 'buildbot.data.steps',
'buildbot.data.logs', 'buildbot.data.logs',
'buildbot.data.logchunks', 'buildbot.data.logchunks',
'buildbot.data.buildsets', 'buildbot.data.buildsets',
'buildbot.data.changes', 'buildbot.data.changes',
'buildbot.data.changesources', 'buildbot.data.changesources',
skipping to change at line 137 skipping to change at line 141
def control(self, action, args, path): def control(self, action, args, path):
endpoint, kwargs = self.getEndpoint(path) endpoint, kwargs = self.getEndpoint(path)
return endpoint.control(action, args, kwargs) return endpoint.control(action, args, kwargs)
def produceEvent(self, rtype, msg, event): def produceEvent(self, rtype, msg, event):
# warning, this is temporary api, until all code is migrated to data # warning, this is temporary api, until all code is migrated to data
# api # api
rsrc = self.getResourceType(rtype) rsrc = self.getResourceType(rtype)
return rsrc.produceEvent(msg, event) return rsrc.produceEvent(msg, event)
@functools.lru_cache(1)
def allEndpoints(self): def allEndpoints(self):
"""return the full spec of the connector as a list of dicts """return the full spec of the connector as a list of dicts
""" """
paths = [] paths = []
for k, v in sorted(self.matcher.iterPatterns()): for k, v in sorted(self.matcher.iterPatterns()):
paths.append(dict(path="/".join(k), paths.append(dict(path="/".join(k),
plural=str(v.rtype.plural), plural=str(v.rtype.plural),
type=str(v.rtype.entityType.name), type=str(v.rtype.entityType.name),
type_spec=v.rtype.entityType.getSpec())) type_spec=v.rtype.entityType.getSpec()))
return paths return paths
@functools.lru_cache(1)
def get_graphql_schema(self):
"""Return the graphQL Schema of the buildbot data model
"""
types = {}
schema = textwrap.dedent("""
# custom scalar types for buildbot data model
scalar Date # stored as utc unix timestamp
scalar Binary # arbitrary data stored as base85
scalar JSON # arbitrary json stored as string, mainly used for properti
es values
""")
# type dependencies must be added recursively
def add_dependent_types(ent):
typename = ent.toGraphQLTypeName()
if typename not in types and isinstance(ent, Entity):
types[typename] = ent
for dtyp in ent.graphQLDependentTypes():
add_dependent_types(dtyp)
# root query contain the list of item available directly
# mapped against the rootLinks
schema += "type Query {\n"
for rootlink in sorted(v['name'] for v in self.rootLinks):
ep = self.matcher[(rootlink,)][0]
typ = ep.rtype.entityType
typename = typ.toGraphQLTypeName()
add_dependent_types(typ)
# build the queriable parameters, via keyFields
keyfields = []
for field in ep.rtype.keyFields:
field_type = ep.rtype.entityType.fields[field].toGraphQLTypeName
()
keyfields.append(f"{field}: {field_type}")
keyfields = ", ".join(keyfields)
if keyfields:
keyfields = f"({keyfields})"
schema += f" {ep.rtype.plural}{keyfields}: [{typename}]!\n"
schema += "}\n"
for name, typ in types.items():
type_spec = typ.toGraphQL()
schema += f"type {name} {{\n"
for field in type_spec.get('fields', []):
field_type = field['type']
if not isinstance(field_type, str):
field_type = field_type['type']
schema += f" {field['name']}: {field_type}\n"
schema += "}\n"
return schema
 End of changes. 6 change blocks. 
0 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)