def put_module(handler, names): module = Module(handler.track.host) added = [] result = dict(version=version) for name in names: uri, module_name = UriLocation(handler.request)(name) log.info('uri={0}, module_name={1}'.format(uri, module_name)) response, _, code = UrlFetch().get(uri) module_name = module_name[:-3] last_version = module.latest_version(module_name) module_version_name = module.sys_module_name(module_name, last_version+1) if last_version and response == module.get_source(module_name, last_version): msg = 'Module source has not changed for {0}'.format( module_version_name) result['data'] = dict(message=msg) try: code, mod = module.add_sys_module(module_version_name, response) log.debug('{0}, {1}'.format(mod, code)) except Exception, e: msg = 'error={0}'.format(e) raise exception_response(400, title='Unable to compile {0}:{1}, {2}'.format(module.host(), module_version_name, msg)) module.add(module_name, response) added.append(module_version_name)
def put_module(handler, names): module = Module(handler.track.host) added = [] result = dict(version=version) for name in names: uri, module_name = UriLocation(handler.request)(name) log.info('uri={0}, module_name={1}'.format(uri, module_name)) response, _ = UrlFetch().get(uri) module_name = module_name[:-3] last_version = module.latest_version(module_name) module_version_name = module.sys_module_name(module_name, last_version + 1) if last_version and response == module.get_source( module_name, last_version): msg = 'Module source has not changed for {0}'.format( module_version_name) result['data'] = dict(message=msg) try: code, mod = module.add_sys_module(module_version_name, response) log.debug('{0}, {1}'.format(mod, code)) except Exception, e: _, t, v, tbinfo = compact_traceback() msg = u'error={0}'.format(e) stack_trace = u'traceback is: ({0}: {1} {2})'.format(t, v, tbinfo) log.error(msg) raise exception_response( 400, title='Unable to compile {0}:{1}, {2}'.format( module.host(), module_version_name, msg), traceback=stack_trace) module.add(module_name, response) added.append(module_version_name)
def put_module(handler, names): module = Module(handler.track.host) added = [] result = dict(version=version) for name in names: uri, module_name = UriLocation(handler.request)(name) log.info('uri={0}, module_name={1}'.format(uri, module_name)) response, _, code = UrlFetch().get(uri) module_name = module_name[:-3] last_version = module.latest_version(module_name) module_version_name = module.sys_module_name(module_name, last_version + 1) if last_version and response == module.get_source( module_name, last_version): msg = 'Module source has not changed for {0}'.format( module_version_name) result['data'] = dict(message=msg) else: # code changed, adding new module try: code, mod = module.add_sys_module(module_version_name, response) log.debug('{0}, {1}'.format(mod, code)) except Exception, e: msg = 'error={0}'.format(e) raise exception_response( 400, title='Unable to compile {0}:{1}, {2}'.format( module.host(), module_version_name, msg)) module.add(module_name, response) added.append(module_version_name) result['data'] = dict(message='added modules: {0}'.format(added))