I am trying to configure RBAC (setting a webserver_config.py of Flask-AppBuilder) with AUTH_LDAP, and after successfully logging through LDAP, I am getting the following error:
File "/usr/local/lib/python3.6/site-packages/airflow/www_rbac/templates/appbuilder/navbar_menu.html", line 47, in top-level template code
<li>{{ menu_item(item2) }}</li>
File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 574, in _invoke
rv = self._func(*arguments)
File "/usr/local/lib/python3.6/site-packages/airflow/www_rbac/templates/appbuilder/navbar_menu.html", line 21, in template
<a tabindex="-1" href="{{item.get_url()}}">
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/menu.py", line 24, in get_url
return url_for(f"{self.baseview.endpoint}.{self.baseview.default_view}")
File "/usr/local/lib/python3.6/site-packages/flask/helpers.py", line 370, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2215, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/flask/helpers.py", line 358, in url_for
endpoint, values, method=method, force_external=external
File "/usr/local/lib/python3.6/site-packages/werkzeug/routing.py", line 2020, in build
raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'BaseView.list'. Did you mean 'DagModelView.list' instead?
I am using airflow 1.10.9 with werkzeug==0.16.0.
Do you have any hints, please?
Thank you in advance.
I understood the problem and fixed the problem.
It was related to the RBAC activation (in airflow) and a previous plugin of mines, which hadn't default_view = "index" defined in Plugin's view.
Related
How to use senlinclient with keystone session? Can anyone give me an example? Thanks.
from keystoneauth1 import session
from keystoneauth1.identity import v3
from senlinclient.client import Client as senlinClient
def get_senlin_client_by_session(session):
return senlinClient(api_ver=1, session=session)
admin_auth = v3.Password(username='admin',
password='xxxxxx',
auth_url='http://vip:5000/v3',
project_name='admin',
user_domain_name='Default',
project_domain_name='Default'
)
session = session.Session(auth=admin_auth)
senlin_client = get_senlin_client_by_session(session)
print(senlin_client)
I tried the above example, but the following error will be reported.
File "/usr/lib/python2.7/site-packages/senlinclient/client.py", line 23, in Client
return cls(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/senlinclient/v1/client.py", line 28, in __init__
self.service = self.conn.cluster
File "/usr/lib/python2.7/site-packages/openstack/service_description.py", line 95, in __get__
allow_version_hack=True,
File "/usr/lib/python2.7/site-packages/openstack/config/cloud_region.py", line 457, in get_session_client
session=self.get_session(),
File "/usr/lib/python2.7/site-packages/openstack/config/cloud_region.py", line 324, in get_session
"Problem with auth parameters")
openstack.exceptions.ConfigException: Problem with auth parameters
The problem has been solved.
openstack rocky uses python2-senlinclient-1.8.0-1.el7.noarch and python2-openstacksdk-0.17.3-1.el7.noarch. I upgraded python2-senlinclient to version 1.9.0 and the problem was solved.
I write a simple custom module, and would like to access the pillar data.
I test it like this (file salt/_modules/foo.py):
def bar():
assert 0, __pillar__
sls file salt/tmp/test_pillar_in_custom_module.sls:
{{ salt['foo.bar']() }}
And I execute it like this:
salt-ssh --log-leve=all foohost state.sls tmp.test_pillar_in_custom_module pillar='{systems: [foosys]}' 2> tmp/o
Relevant part of tmp/o:
Traceback (most recent call last):
File "/var/tmp/.root_dcdf8c_salt/salt-call", line 27, in <module>
salt_call()
File "/var/tmp/.root_dcdf8c_salt/pyall/salt/scripts.py", line 431, in salt_call
client.run()
File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/call.py", line 57, in run
caller.run()
File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/caller.py", line 138, in run
ret = self.call()
File "/var/tmp/.root_dcdf8c_salt/pyall/salt/cli/caller.py", line 237, in call
ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
File "/var/tmp/.root_dcdf8c_salt/pyall/salt/executors/direct_call.py", line 12, in execute
return func(*args, **kwargs)
File "/var/tmp/.root_dcdf8c_salt/running_data/var/cache/salt/minion/extmods/modules/foo.py", line 2, in bar
assert 0, __pillar__
AssertionError: {}
But the dict __pillar__ is empty.
I read the docs: https://docs.saltstack.com/en/latest/topics/development/modules/developing.html#pillar
The __pillar__ dictionary contains the pillar for the respective
minion.
While __pillar__ is defined for every module, it's only filled in for
some.
In my custom module it is empty.
Is there a way to access the pillar in a custom module?
I've tried to get Workspace from config which I do have access to, but it fails with the following error:
import azureml.core
print("SDK version:", azureml.core.VERSION)
from azureml.core.workspace import Workspace
ws = Workspace.from_config()
print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep='\n')
SDK version: 0.1.80 Found the config file in:
C:\Users\gubert\Repos\Gimmonix\HotelMappingAI\aml_config\config.json
get_workspace error using subscription_id=xxxxxxxxxxxxxxxxxxxxxxx,
resource_group_name=xxxxxxxxxxxx, workspace_name=gmx-ml-mapping
Traceback (most recent call last): File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_project_commands.py",
line 320, in get_workspace workspace_name) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_base_sdk_common\workspace\operations\workspaces_operations.py",
line 78, in get raise
models.ErrorResponseWrapperException(self._deserialize, response)
azureml._base_sdk_common.workspace.models.error_response_wrapper.ErrorResponseWrapperException:
Operation returned an invalid status code 'Forbidden'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py",
line 38, in main(sys.argv) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_main_.py",
line 265, in main wait=args.wait) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_main_.py",
line 256, in handle_args run_main(addr, name, kind, *extra, **kwargs)
File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_local.py",
line 52, in run_main runner(addr, name, kind == 'module', *extra,
**kwargs) File "c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd\runner.py",
line 32, in run set_trace=False) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd\pydevd.py",
line 1283, in run return self._exec(is_module, entry_point_fn,
module_name, file, globals, locals) File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd\pydevd.py",
line 1290, in _exec pydev_imports.execfile(file, globals, locals) #
execute the script File
"c:\Users\gubert.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd\ptvsd_vendored\pydevd_pydev_imps_pydev_execfile.py",
line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob,
loc) File "c:\Users\gubert\Repos\Gimmonix\HotelMappingAI\test.py",
line 8, in ws = Workspace.from_config() File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml\core\workspace.py",
line 153, in from_config auth=auth) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml\core\workspace.py",
line 86, in init auto_rest_workspace = _commands.get_workspace(auth,
subscription_id, resource_group, workspace_name) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_project_commands.py",
line 326, in get_workspace resource_error_handling(response_exception,
WORKSPACE) File
"C:\Users\gubert.azureml\envs\myenv\lib\site-packages\azureml_base_sdk_common\common.py",
line 270, in resource_error_handling raise
ProjectSystemException(response_message)
azureml.exceptions._azureml_exception.ProjectSystemException: {
"error_details": { "error": { "code": "AuthorizationFailed",
"message": "The client 'xxxxxxxxxx#microsoft.com' with object id
'xxxxxxxxxxxxx' does not have authorization to perform action
'Microsoft.MachineLearningServices/workspaces/read' over scope
'/subscriptions/xxxxxxxxxxxxxx/resourceGroups/CarsolizeCloud - Test
Global/providers/Microsoft.MachineLearningServices/workspaces/gmx-ml-mapping'."
} }, "status_code": 403, "url":
"https://management.azure.com/subscriptions/xxxxxxxxxxxxx/resourceGroups/CarsolizeCloud%20-%20Test%20Global/providers/Microsoft.MachineLearningServices/workspaces/gmx-ml-mapping?api-version=2018-03-01-preview"
}
Try using the newest SDK version 1.0.10, this is a fairly old preview version you're using. If you still have a problem, let me know as I work on this SDK.
i want to connect woocommerce and odoo. i have problem with woocommmerce connector installation in Odoo. i got the woocommerce connector from https://github.com/OCA/connector-woocommerce . i have upload this module into addons folder in odoo.. When i tried to update the module list in odoo, i got this error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 537, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception).
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 574, in dispatch
result = self._call_function(**self.params)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 310, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 307, in checked_call
return self.endpoint(*a, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 803, in __call__
return self.method(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 403, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 948, in call_button
action = self._call_kw(model, method, args, {})
File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 393, in old_api
result = new_api(recs, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 397, in new_api
result = [method(rec, *args, **kwargs) for rec in self]
File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/wizard/base_module_update.py", line 15, in update_module
self.updated, self.added = self.env['ir.module.module'].update_list()
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 239, in wrapper
return new_api(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 462, in new_api
result = method(self._model, cr, uid, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/openerp/addons/base/module/module.py", line 654, in update_list
handler.load_addons()
File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1308, in load_addons
m = __import__('openerp.addons.' + module)
File "/usr/lib/python2.7/dist-packages/openerp/modules/module.py", line 80, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/usr/lib/python2.7/dist-packages/openerp/addons/connector_woocommerce/__init__.py", line 22, in <module>
from . import model
File "/usr/lib/python2.7/dist-packages/openerp/addons/connector_woocommerce/model/__init__.py", line 22, in <module>
from . import backend
File "/usr/lib/python2.7/dist-packages/openerp/addons/connector_woocommerce/model/backend.py", line 23, in <module>
from woocommerce import API
ImportError: No module named woocommerce
It seems like you do not have installed woocommerce REST api on your system.
install woocommerce using your terminal. here is the command
sudo pip install woocommerce
EDIT:
Open python prompt in terminal
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from woocommerce import API
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named woocommerce
If it says No module named woocommerce means you have some installation issue with woocommerce.
I was facing same problem while installing woocommerce connector in odoo. After that i have installed woocommerce module by
pip install woocommerce. I was working on windows platform.
I was getting same problem after successfully installing woocommerce python module.
Here Problem is odoo is not finding woocommerce in it's addon folder.
So solution is here :
open folder "C:\Python27\Lib\site-packages".
This is the path where python modules are installed. From this folder find the folder 'woocommerce'.
copy this folder and put this in odoo server path which is
"D:\Odoo 8.0-20160107\server" .
Now restart odoo
Hope this will help you.
I was using plone.directives.form version 1.0 with Plone 4.2.5 and after upgrading to 4.2.6 I started seeing the following traceback and I guess its due to plone.directives.form being upgraded to version 1.1.
How can I avoid this error? The only line of code that is not from default Plone on the traceback is on der.freitag.handlers where it does a transaction.commit() and the content type is just a regular dexterity content type.
1385740390.020.496977141203 http://10.100.0.207:8081/website/front-page/atomkraft/++add++der.freitag.customizablearticlelink
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.z3cform.layout, line 70, in __call__
Module plone.z3cform.layout, line 54, in update
Module plone.dexterity.browser.add, line 112, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 138, in update
Module z3c.form.action, line 99, in execute
Module z3c.form.button, line 315, in __call__
Module z3c.form.button, line 170, in __call__
Module plone.dexterity.browser.add, line 99, in handleAdd
Module z3c.form.form, line 247, in createAndAdd
Module plone.dexterity.browser.add, line 78, in add
Module plone.dexterity.utils, line 152, in addContentToContainer
Module Products.BTreeFolder2.BTreeFolder2, line 455, in _setObject
Module zope.event, line 31, in notify
Module zope.component.event, line 24, in dispatch
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module zope.component.event, line 32, in objectEventNotify
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module der.freitag.handlers, line 126, in set_customizable_article_link_id
Module transaction._manager, line 89, in commit
Module transaction._transaction, line 329, in commit
Module transaction._transaction, line 443, in _commitResources
Module ZODB.Connection, line 567, in commit
Module ZODB.Connection, line 623, in _commit
Module ZODB.Connection, line 658, in _store_objects
Module ZODB.serialize, line 422, in serialize
Module ZODB.serialize, line 431, in _dump
PicklingError: Can't pickle <class 'plone.directives.form.schema.Schema'>: attribute lookup plone.directives.form.schema.Schema failed
EDIT: the object that is being created has a relation field (a z3c.relationfield.schema.RelationChoice) and it turns out that zc.relation keeps a list of all interfaces provided by each member of any relation. Thus, after upgrading from plone.directives.form version 1.0 to version 1.1 the interfaces on plone.directives.form can no longer be resolved.
From z3c.relationfield documentation I don't see any option to update relations, so the only solution would be to get all relations and recreate them?
Just for reference that's how I fixed it:
While still on plone.directives.form 1.0 update your objects so that they do no longer provide the plone.directives.form.schema.Schema interface.
Then re-create the relations:
from z3c.relationfield import RelationValue
from zc.relation.interfaces import ICatalog
from zope.app.intid.interfaces import IIntIds
from zope.component import getUtility
from zope.event import notify
from zope.lifecycleevent import ObjectModifiedEvent
logger = logging.getLogger(LOGGER)
relations_catalog = getUtility(ICatalog)
intids = getUtility(IIntIds)
relations = [rel for rel in relations_catalog.findRelations()]
len_relations = len(relations)
logger.info('Relations needed to update: {0}'.format(len_relations))
for relation in relations:
# get the object link and the object linked
object_with_link = relation.from_object
object_linked_to = relation.to_object
# remove the broken relation
object_with_link.reference = None
# let the catalog remove the old relation
notify(ObjectModifiedEvent(object_with_link))
# create a new relation
object_linked_to_intid = intids.getId(object_linked_to)
new_relation = RelationValue(object_linked_to_intid)
object_with_link.reference = new_relation
# let the catalog know about this new relation
notify(ObjectModifiedEvent(object_with_link))
After this, stop the instance, run buildout again to update plone.directives.form to version 1.1 and voilĂ !
The Schema class is now in plone.supermodel.model, not plone.directives.form.schema.
However, the real problem you should try to fix is that the code is for some reason trying to store a schema in the ZODB. Pickling/unpickling Zope interfaces is not supported.
In case someone runs into this type of problem and cannot bring the old package back, here's another approach:
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import system
from Testing.makerequest import makerequest
from zope.component.hooks import setSite
from zope.globalrequest import setRequest
from zc.relation.interfaces import ICatalog
from z3c.relationfield.event import _relations
from z3c.relationfield.event import _setRelation
from zope.component import getUtility
app = makerequest(app)
newSecurityManager(None, system)
portal = app.Plone
setSite(portal)
portal.REQUEST['PARENTS'] = [portal]
portal.REQUEST.setVirtualRoot('/')
setRequest(portal.REQUEST)
THRESHOLD = 100
relations_catalog = getUtility(ICatalog)
paths = ['/'.join(r.from_object.getPhysicalPath())
for r in relations_catalog.findRelations() if r.from_object]
relations_catalog.clear()
counter = 0
for path in paths:
obj = app.unrestrictedTraverse(path)
for name, relation in _relations(obj):
_setRelation(obj, name, relation)
counter += 1
if counter % THRESHOLD == 0:
transaction.savepoint()
transaction.commit()
One more option, I developed a package called collective.diversion that is designed to ease the pain of pickling errors when moving a class. Neither of the above scripts worked for me, however using collective.diversion did.
Adding the package to the buildout and including the following ZCML caused the items to be loaded, and they'll be persisted back in the correct place on write, so reindexing the catalogue should be sufficient.
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:diversion="http://namespaces.plone.org/diversion">
<diversion:class
old="plone.directives.form.schema.Schema"
new="plone.supermodel.model.Schema"
/>
</configure>