Why does pyramid give exception of zipimporter.get_filename() - python

I am writing a simple pyramid application, and I try to run it pserve development.ini.
I got this:
Traceback (most recent call last):
File "/apps/my/python/packages/.mytest/current/bin/pserve", line 5, in <module>
sys.exit(pyramid.scripts.pserve.main())
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 316, in run
global_conf=vars)
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/scripts/pserve.py", line 340, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 58, in fix_call
reraise(*exc_info)
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/compat.py", line 23, in reraise
exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
File "/users/is/pypi/egg_cache/p/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/users/is/pypi/egg_cache/at/mytest-1.9.0-py2.7.egg//mytest/__init__.py", line 108, in main
File "/users/is/pypi/egg_cache/p/pyramid-1.5.1-py2.7.egg/pyramid/config/__init__.py", line 930, in scan
ignore=ignore)
File "/users/is/pypi/egg_cache/v/venusian-1.0a7-py2.7.egg/venusian/__init__.py", line 187, in scan
fn = loader.get_filename()
TypeError: zipimporter.get_filename() takes exactly 1 argument (0 given)
anyone could tell me how it comes?

Ok. I choose not to delete this question as I believe it might help other people who have the same problems.
Basically venusian does not support zipped egg. So when you produce your egg for pyramid, do not do it as zip egg.

Related

odoo v11 converter does not exist

all modules has been installed correctly since I restored it from a working backup.
the problem is, it doesn't read properly. does anyone know how to fix this?
2022-02-15 02:40:22,799 31154 ERROR tester werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 205, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 193, in execute
application_iter = app(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/service/server.py", line 292, in app
return self.app(e, s)
File "/home/ria/olive/tigernixerp11/odoo/service/wsgi_server.py", line 166, in application
return application_unproxied(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/service/wsgi_server.py", line 154, in application_unproxied
result = handler(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1321, in __call__
return self.dispatch(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1295, in __call__
return self.app(environ, start_wrapped)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/wsgi.py", line 599, in __call__
return self.app(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1510, in dispatch
result = ir_http._dispatch()
File "/home/ria/olive/tigernixerp11/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File "/home/ria/olive/tigernixerp11/addons/web_editor/models/ir_http.py", line 22, in _dispatch
return super(IrHttp, cls)._dispatch()
File "/home/ria/olive/tigernixerp11/addons/http_routing/models/ir_http.py", line 322, in _dispatch
rule, arguments = cls._find_handler(return_rule=True)
File "/home/ria/olive/tigernixerp11/odoo/addons/base/ir/ir_http.py", line 84, in _find_handler
return cls.routing_map().bind_to_environ(request.httprequest.environ).match(return_rule=return_rule)
File "/home/ria/olive/tigernixerp11/odoo/addons/base/ir/ir_http.py", line 238, in routing_map
cls._routing_map = http.routing_map(mods, False, converters=cls._get_converters())
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 988, in routing_map
routing_map.add(werkzeug.routing.Rule(url, endpoint=endpoint, methods=routing['methods'], **kw))
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 1197, in add
rule.bind(self)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 681, in bind
self.compile()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 731, in compile
_build_regex(self.is_leaf and self.rule or self.rule.rstrip('/'))
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 721, in _build_regex
variable, converter, c_args, c_kwargs)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 689, in get_converter
raise LookupError('the converter %r does not exist' % converter_name)
LookupError: the converter 'str' does not exist
restoring in another computer doesn't seem to have any problem butthis computer seems to be unable to read properly

function() takes 1 positional argument but 2 were given

I'm trying to clone this Django repo and run it on my local machine, but I've run into the classic function() takes 1 positional argument but 2 were given error.
After cloning the repo I created a virtual environment and installed all the dependencies,
But when I run
py manage.py migrate
I get the above-mentioned error.
What's confusing me is that the error is occurring in a python file automatically generated in the virtual environment and according to other questions on SO about this, the code seems correct.
Here's the trace
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
django.setup()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\apps.py", line 22, in ready
ExportMigrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django_prometheus\migrations.py", line 39, in ExportMigrations
executor = MigrationExecutor(connections[alias])
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
if self.has_table():
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\migrations\recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 202, in connect
self.init_connection_state()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 245, in init_connection_state
if self.features.is_sql_auto_is_null_enabled:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\features.py", line 150, in is_sql_auto_is_null_enabled
return self.connection.mysql_server_data['sql_auto_is_null']
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\mysql\base.py", line 366, in mysql_server_data
with self.temporary_connection() as cursor:
File "C:\Python\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\lenovo\Desktop\dev\work\django-sspanel\sspanel_env\lib\site-packages\django\db\backends\base\base.py", line 237, in _cursor
return self._prepare_cursor(self.create_cursor(name))
TypeError: create_cursor() takes 1 positional argument but 2 were given
Base.py in the virtual environment.
def _cursor(self, name=None):
self.ensure_connection()
with self.wrap_database_errors:
return self._prepare_cursor(self.create_cursor(name))
def create_cursor(self, name=None):
"""Create a cursor. Assume that a connection is established."""
raise NotImplementedError('subclasses of BaseDatabaseWrapper may require a create_cursor() method')
I was hoping that someone could try cloning the repo and running it locally to see whether they could recreate the problem or maybe help me understand what's causing it.

How to run python unittest inside PyCharm with buffer=True

Building on top of How to assert output with nosetest/unittest in python? I would like to acieve this inside Pyharm. However, pycharm does not run:
$ python -m tests.test_mymodule --buffer
Rather it does:
$ /usr/bin/python2.7 /opt/helpers/pycharm/utrunner.py \
/home/oz123/PycharmProjects/account/tests/test_mymodule.py true
So, I ran it with:
$ /usr/bin/python2.7 /opt/helpers/pycharm/utrunner.py \
/home/oz123/PycharmProjects/account/tests/test_mymodule.py --buffer true
And it crashes with:
##teamcity[testFinished duration='72' name='test_1_list_files']
Traceback (most recent call last):
File "/opt/helpers/pycharm/utrunner.py", line 151, in <module>
TeamcityTestRunner().run(all, **options)
File "/opt/helpers/pycharm/tcunittest.py", line 249, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/case.py", line 396, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/case.py", line 356, in run
result.addError(self, sys.exc_info())
File "/opt/helpers/pycharm/tcunittest.py", line 108, in addError
TestResult.addError(self, test, err)
File "/usr/lib/python2.7/unittest/result.py", line 19, in inner
return method(self, *args, **kw)
File "/usr/lib/python2.7/unittest/result.py", line 116, in addError
self.errors.append((test, self._exc_info_to_string(err, test)))
File "/usr/lib/python2.7/unittest/result.py", line 167, in _exc_info_to_string
output = sys.stdout.getvalue()
AttributeError: 'file' object has no attribute 'getvalue'
Does any one know where does pycharm store the output? How can I access it?

Nose Test Error

I am using the command
nosetests -v --with-coverage --cover-package=task --cover-erase --cover-html-dir=cover --cover-html --with-xunit task
to run the test cases
but in the end after running all the testcases I get the nosetests.xml blank and the following error.
Traceback (most recent call last):
File "/home/nishant-un/env/bin/nosetests", line 9, in <module>
load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 118, in __init__
**extra_args)
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 197, in runTests
result = self.testRunner.run(self.test)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/core.py", line 61, in run
test(result)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 176, in __call__
return self.run(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/suite.py", line 223, in run
test(orig)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/case.py", line 45, in __call__
return self.run(*arg, **kwarg)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/case.py", line 138, in run
result.addError(self, err)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/proxy.py", line 118, in addError
formatted = plugins.formatError(self.test, err)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 94, in __call__
return self.call(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 136, in chain
result = meth(*arg, **kw)
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 223, in formatError
test.capturedLogging = records = self.formatLogRecords()
File "/home/nishant-un/env/local/lib/python2.7/site-packages/nose/plugins/logcapture.py", line 231, in formatLogRecords
return [safe_str(format(r)) for r in self.handler.buffer]
File "/usr/lib/python2.7/logging/__init__.py", line 723, in format
return fmt.format(record)
File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
record.message = record.getMessage()
File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
I have tried almost everything that i found in google. Even deleted .coverage file and all .pyc but it still shows the same error.Any Idea..?
This TypeError is because of mixing different formats.
Your error is inside formatLogRecords()
Instead of:
msg = msg % self.args
You should use format():
myMsg = "{} {} {} {} {}".format(param1, param2, param3, param4)
And even much better approach will be:
args = ['1', '2', '3', '4']
myMsg = (' '.join('{}'.format(k) for k in args))
Result:
>>> 1 2 3 4
That way your args can be with a flexible.
One thing to try is to run nose with no log capturing --nologcapture. Most likely you have a rogue logging somewhere at the import level, and it chokes nose before tests can run.
You can usually expose those bugs easily if you just run python task.py on your test files - the error will get thrown immediately.
If this still does not solve your problem, try running nose within python using nose.run() within your test __main__ function, and fire it off with python -m pdb task.py it will let you debug such errors, even if --pdb option in nose does not work.

Launching nose with --with-gae option raises ValueError for missing lib/ipaddr

Setting up the testing framework and I can't seem to get past this error:
Traceback (most recent call last):
File "/usr/local/bin/nosetests", line 8, in <module>
load_entry_point('nose==1.1.2', 'console_scripts', 'nosetests')()
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/core.py", line 118, in __init__
**extra_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/core.py", line 135, in parseArgs
self.config.configure(argv, doc=self.usage())
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/config.py", line 338, in configure
self.plugins.configure(options, self)
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/plugins/manager.py", line 271, in configure
cfg(options, config)
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/plugins/manager.py", line 94, in __call__
return self.call(*arg, **kw)
File "/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg/nose/plugins/manager.py", line 162, in simple
result = meth(*arg, **kw)
File "build/bdist.macosx-10.7-intel/egg/nosegae.py", line 80, in configure
File "/usr/local/bin/dev_appserver.py", line 76, in <module>
DIR_PATH = get_dir_path(os.path.join('lib', 'ipaddr'))
File "/usr/local/bin/dev_appserver.py", line 66, in get_dir_path
'file and %s.' % sibling)
ValueError: Could not determine directory that contains both, this file and lib/ipaddr.
It's a correct error coming from dev_appserver.py... there is no lib/ipaddr in the /usr/local/bin directory.
Why is nosetests triggering the raising of this error? Why does dev_appengine try to look for lib/ipaddr in the first place?

Categories