Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qa error: update_package' object has no attribute 'get_logger' #62

Open
psonis opened this issue Jul 19, 2018 · 16 comments
Open

qa error: update_package' object has no attribute 'get_logger' #62

psonis opened this issue Jul 19, 2018 · 16 comments

Comments

@psonis
Copy link

psonis commented Jul 19, 2018

I get this error in the terminal when running it...
I use ckan 2.6.6.
The archiver/report works but I get no start in the openess section

[2018-07-19 13:08:34,246: ERROR/MainProcess] Task qa.update_package[another-test-ef74] raised unexpected: AttributeError("'update_package' object has no attribute 'get_logger'",) Traceback (most recent call last): File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__ return self.run(*args, **kwargs) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 83, in update_package log = update_package.get_logger() File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/local.py", line 143, in __getattr__ return getattr(self._get_current_object(), name) AttributeError: 'update_package' object has no attribute 'get_logger'

@psonis psonis changed the title qa error qa error: update_package' object has no attribute 'get_logger' Jul 19, 2018
@ghost
Copy link

ghost commented Jul 31, 2018

same problem here

@psonis
Copy link
Author

psonis commented Aug 6, 2018

Did you manage to solve it?

@ghost
Copy link

ghost commented Aug 6, 2018

The plugin is for some reason not able to fetch a logger instance. I solved the problem by manually creating my own logger instance in the qa script.
So only a quick and dirty fix.

@psonis
Copy link
Author

psonis commented Aug 6, 2018

Still its a fix! Could you help me create one as well?

@ghost
Copy link

ghost commented Aug 8, 2018

in "ckanext-qa/ckanext/qa/tasks.py" comment out all lines with "log = ..." then add the following lines after the import statements at the top of the file:

import logging
log = logging.getLogger(name)

that should do the trick!

@psonis
Copy link
Author

psonis commented Aug 8, 2018

thanks for the fix... the error is gone but still no stars, the Openess section is empty and now I get the error below.

Also, If I remove qa from the plugins sections in my .ini file I get a similar message for the archiver plugin. Please see https://github.com/ckan/ckanext-archiver/issues/59

2018-08-08 11:37:48,828 ERROR [ckanext.qa.tasks] Exception occurred during QA update_package: AttributeError: 'NoneType' object has no attribute 'ugettext' [2018-08-08 11:37:48,832: ERROR/MainProcess] Task qa.update_package[test-37f2] raised unexpected: AttributeError("'NoneType' object has no attribute 'ugettext'",) Traceback (most recent call last): File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__ return self.run(*args, **kwargs) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 89, in update_package update_package_(package_id, log) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 106, in update_package_ qa_result = resource_score(resource, log) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 230, in resource_score score_reason = _("Unknown error: %s") % str(e) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pylons/i18n/translation.py", line 106, in ugettext return pylons.translator.ugettext(value) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/registry.py", line 137, in __getattr__ return getattr(self._current_obj(), attr) AttributeError: 'NoneType' object has no attribute 'ugettext'

Any ideas?

@ghost
Copy link

ghost commented Aug 8, 2018

This is a problem with ckans translation function "_" , in your stacktrace

"score_reason = _("Unknown error: %s") % str(e)"

I dont know yet why this is not working. I have the same problem with my ckan installation. Maybe a configuration problem. A very ugly hack is to simply mock the "_" function by inserting

def _(s): return s

on top of the qa and archiver scripts which disables translations.

@psonis
Copy link
Author

psonis commented Aug 8, 2018

I wasn't using any other language anyways... so it will do just fine!
Could you please be more specific as to which files should I add the def _(s): return s line?
Thanks in advance.

@ghost
Copy link

ghost commented Aug 8, 2018

try ckanext-qa/ckanext/qa/tasks.py

@psonis
Copy link
Author

psonis commented Aug 8, 2018

ok here's an update..
I added the line and no I get the stars on the left!
...but the process in the terminal still hangs. See the error below.

Perhaps it should be added in another file or in report or in archiver? Really dont have a clue. Thanks.

[2018-08-08 12:53:54,574: ERROR/MainProcess] Task qa.update_package[test-754f] raised unexpected: AttributeError("'NoneType' object has no attribute 'ugettext'",) Traceback (most recent call last): File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(*args, **kwargs) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__ return self.run(*args, **kwargs) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 90, in update_package update_package_(package_id, log) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 115, in update_package_ _update_search_index(package.id, log) File "/home/hit/ckan/lib/default/src/ckanext-qa/ckanext/qa/tasks.py", line 440, in _update_search_index package = toolkit.get_action('package_show')(context_, {'id': package_id}) File "/home/hit/ckan/lib/default/src/ckan/ckan/logic/__init__.py", line 431, in wrapped result = _action(context, data_dict, **kw) File "/home/hit/ckan/lib/default/src/ckan/ckan/logic/action/get.py", line 976, in package_show package_dict = model_dictize.package_dictize(pkg, context) File "/home/hit/ckan/lib/default/src/ckan/ckan/lib/dictization/model_dictize.py", line 301, in package_dictize result_dict['license_title'] = pkg.license.title.split('::')[-1] File "/home/hit/ckan/lib/default/src/ckan/ckan/model/license.py", line 50, in __getattr__ return self._data[name] File "/home/hit/ckan/lib/default/src/ckan/ckan/model/license.py", line 201, in __getitem__ value = getattr(self, key) File "/home/hit/ckan/lib/default/src/ckan/ckan/model/license.py", line 242, in title return _("Open Data Commons Open Database License (ODbL)") File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/pylons/i18n/translation.py", line 106, in ugettext return pylons.translator.ugettext(value) File "/usr/lib/ckan/default/local/lib/python2.7/site-packages/paste/registry.py", line 137, in __getattr__ return getattr(self._current_obj(), attr) AttributeError: 'NoneType' object has no attribute 'ugettext'

@ghost
Copy link

ghost commented Aug 8, 2018

yes, you can see it in the stacktrace:

"/home/hit/ckan/lib/default/src/ckan/ckan/model/license.py", line 242, in title return _("Open Data Commons Open Database License (ODbL)")

here is the "_" function used again, but this time not in the qa or archiver plugin. If you want to go down this road you can try to insert the mock there too until all errors go away.

@psonis
Copy link
Author

psonis commented Aug 8, 2018

looks like a slippery slope... tried it and now a get a new error...

so your suggestion is to run the archiver/qa in the terminal and just CRTL-C when it hangs?

@ghost
Copy link

ghost commented Aug 8, 2018

I have no real solution at the moment, currently I try to make the "_" Function work again

@psonis
Copy link
Author

psonis commented Aug 8, 2018

thanks for all this! let me know if you think of anything else.

@ghost
Copy link

ghost commented Aug 8, 2018

still a hack but better: in both tasks.py (in qa and archiver):

search for

class FakePylons:
    translator = None

and replace it with

class FakeTranslator:
    def ugettext(s, a): return a

class FakePylons:
    translator = FakeTranslator()

with this all errors go away for me, but you should still watch the logs of the archiver run as it showed some configuration problems of my installation

@psonis
Copy link
Author

psonis commented Aug 8, 2018

yep, now it works! hopefully there will be an official fix, but this will do just fine!
thanks again for all your effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant