def add_results(info, results): "Return sweet results" build_dict = { 'success': info.get('success', False), 'started': info.get('start_time', ''), 'finished': info.get('end_time', ''), 'tags': info['tags'], 'client': { 'arch': info.get('arch', ''), 'host': info.get('host', ''), 'user': '******', }, 'results': [] } for result in results: success = False #Status code of 0 means successful if result.get('status', False) == 0: success = True build_dict['results'].append({ 'success': success, 'name': result.get('name', ''), 'errout': result.get('errout', ''), 'output': result.get('output', ''), 'command': result.get('command', ''), 'type': result.get('type', ''), 'version_type': result.get('version_type', ''), 'version_info': result.get('version_info', ''), }) environ = { 'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, 'SERVER_PROTOCOL': 'HTTP/1.1', } r = WSGIRequest(environ) r.data = build_dict r.META['CONTENT_TYPE'] = 'application/json' package = unicode(info.get('package')) try: pro, created = Project.objects.get_or_create(name=package, slug=slugify(package)) except: pass ProjectBuildListHandler().create(r, package) return "Processed Correctly"
def add_results(info, results): "Return sweet results" build_dict = {'success': info.get('success', False), 'started': info.get('start_time', ''), 'finished': info.get('end_time', ''), 'tags': info['tags'], 'client': { 'arch': info.get('arch', ''), 'host':info.get('host', ''), 'user': '******', }, 'results': [] } for result in results: success = False #Status code of 0 means successful if result.get('status', False) == 0: success = True build_dict['results'].append( {'success': success, 'name': result.get('name', ''), 'errout': result.get('errout', ''), 'output': result.get('output', ''), 'command': result.get('command', ''), 'type': result.get('type', ''), 'version_type': result.get('version_type', ''), 'version_info': result.get('version_info', ''), } ) environ = { 'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, 'SERVER_PROTOCOL': 'HTTP/1.1', } r = WSGIRequest(environ) r.data = build_dict r.META['CONTENT_TYPE'] = 'application/json' package = unicode(info.get('package')) try: pro, created = Project.objects.get_or_create(name=package, slug=slugify(package)) except: pass ProjectBuildListHandler().create(r, package) return "Processed Correctly"
def __open__(self, apiCall, method, data=None): request = {'REQUEST_METHOD':method} if self.version: request['HTTP_X_VERSION'] = self.version request = WSGIRequest(request) request.data = data or {} if self.__user__: request.user = self.__user__ (handler, ignored, kwargs) = resolve(self.baseUrl + apiCall) emitterFormat = kwargs.pop('emitter_format', 'json') result = handler.handler.__getattribute__(CALL_MAP[method])(request, **kwargs) if isinstance(result, HttpResponse): return result.content return result