

def handle_deploy(self, handle, connection, match, data, hdr):
    try:
        _log.analyze(self.node.id, '+', data)
        if ('app_info' not in data):
            kwargs = {
                
            }
            if ('sec_credentials' in data):
                kwargs['credentials'] = data['sec_credentials']
                if ('sec_sign' in data):
                    kwargs['content'] = {
                        'file': data['script'],
                        'sign': {h: s.decode('hex_codec') for (h, s) in data['sec_sign'].iteritems()},
                    }
            (app_info, errors, warnings) = compiler.compile(data['script'], filename=data['name'], verify=(data['check'] if ('check' in data) else True), **kwargs)
            if errors:
                if any([e['reason'].startswith('401:') for e in errors]):
                    _log.error('Security verification of script failed')
                    self.send_response(handle, connection, None, status=calvinresponse.UNAUTHORIZED)
                else:
                    _log.exception('Compilation failed')
                    self.send_response(handle, connection, json.dumps({
                        'errors': errors,
                        'warnings': warnings,
                    }), status=calvinresponse.BAD_REQUEST)
                return
        else:
            if security_needed_check():
                _log.error("Can't combine compiled script with runtime having security")
                self.send_response(handle, connection, None, status=calvinresponse.UNAUTHORIZED)
                return
            app_info = data['app_info']
            errors = ['']
            warnings = ['']
        _log.analyze(self.node.id, '+ COMPILED', {
            'app_info': app_info,
            'errors': errors,
            'warnings': warnings,
        })
        d = Deployer(deployable=app_info, deploy_info=(data['deploy_info'] if ('deploy_info' in data) else None), node=self.node, name=(data['name'] if ('name' in data) else None), credentials=(data['sec_credentials'] if ('sec_credentials' in data) else None), verify=(data['check'] if ('check' in data) else True), cb=CalvinCB(self.handle_deploy_cb, handle, connection))
        _log.analyze(self.node.id, '+ Deployer instanciated', {
            
        })
        d.deploy()
        _log.analyze(self.node.id, '+ DEPLOYING', {
            
        })
    except Exception as e:
        _log.exception('Deployer failed')
        self.send_response(handle, connection, json.dumps({
            'errors': errors,
            'warnings': warnings,
            'exception': str(e),
        }), status=(calvinresponse.BAD_REQUEST if errors else calvinresponse.INTERNAL_ERROR))

dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/runtime/north/calvincontrol.py CalvinControl.handle_deploy/original