web2py Exception in sql rows - python

when i do the following code:
family_members =db(db.member.id == membership_id).select
(db.member.name,db.member.id)
family_members.colnames = ('Name','Membership ID')
It cause the following error...
Traceback (most recent call last):
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
restricted.py", line 184, in restricted
File "/home/abeer/Desktop/resources/web2py/New_version/web2py_src/
web2py/applications/init/views/default/updateMember.html", line 142,
in <module>
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
globals.py", line 112, in write
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
html.py", line 103, in xmlescape
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sql.py", line 3326, in xml
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sqlhtml.py", line 980, in __init__
File "/home/abeer/Desktop/web2py/New_version/web2py_src/web2py/gluon/
sql.py", line 621, in __getattr__
KeyError: '_extra'
P.S. : when i commented the line (family_members.colnames = ('Name','Membership ID')), it works fine, but I don't understand why.

Do not use colnames. That attribute is internal to web2py. Use db.table.field.label='..' or SQLTABLE(rows, headers={...}) depending on what you need.

Related

Miniconda: cannot launch spyder

I have always been able to launch spyder without any issues. But today I started running into the following error messages. I don't understand why is it complaining no workingdir? How do I resolve this, as I cannot even launch spyder ?
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\start.py", line 253, in main
mainwindow.main(options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 1956, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\utils.py", line 289, in create_window
main.setup()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 771, in setup
PLUGIN_REGISTRY.register_plugin(self, PluginClass,
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 342, in register_plugin
instance = self._instantiate_spyder5_plugin(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 193, in _instantiate_spyder5_plugin
plugin_instance.initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugins\new_api.py", line 669, in initialize
self.on_initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\plugin.py", line 82, in on_initialize
container.set_history(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 323, in set_history
workdir = self._get_init_workdir()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 183, in _get_init_workdir
workdir = self.get_conf('startup/fixed_directory')
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\config\mixins.py", line 76, in get_conf
return CONF.get(section, option, default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\manager.py", line 499, in get
value = config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 980, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 511, in get
raise cp.NoSectionError(section)
configparser.NoSectionError: No section: 'workingdir'

Python buildozer, ValueError

Good afternoon! I'm asking for help, I can't figure out python buildozer for a day, I've already prepared everything, and at the final stage, when the "buildozer android debug" command is entered into the terminal, it gives such an error at the end. Can anyone tell me what to do about it and how to fix it?
Here is the error itself:
Traceback (most recent call last):
File "/usr/local/bin/buildozer", line 11, in <module>
load_entry_point('buildozer==0.40.dev0', 'console_scripts', 'buildozer')()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 1071, in run_command
self.target.run_commands(args)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/target.py", line 92, in run_commands
func(args)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/target.py", line 102, in cmd_debug
self.buildozer.prepare_for_build()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 178, in prepare_for_build
self.target.install_platform()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/targets/android.py", line 666, in install_platform
self._install_android_ndk()
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/targets/android.py", line 459, in _install_android_ndk
cwd=self.buildozer.global_platform_dir)
File "/usr/local/lib/python3.6/dist-packages/buildozer-0.40.dev0-py3.6.egg/buildozer/__init__.py", line 699, in download
urlretrieve(url, filename, report_hook)
File "/usr/lib/python3.6/urllib/request.py", line 1826, in retrieve
block = fp.read(bs)
File "/usr/lib/python3.6/tempfile.py", line 624, in func_wrapper
return func(*args, **kwargs)
ValueError: read of closed file
I tried to find an answer to this question, but so far without success.

Module 'cryptography.utils' has no attribute 'bit_length'

I am currently trying to figure out how to use netmiko to automate some of my routine work.Such as getting configuration backup, creating vlans etc.I've managed to use it on Aruba and Huawei Switches without problem.But on alcatel switch I'm facing this issue:
Unknown exception: module 'cryptography.utils' has no attribute 'bit_length'
Traceback (most recent call last):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 2075, in run
self.kex_engine.parse_next(ptype, m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 101, in parse_next
return self._parse_kexdh_gex_reply(m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 281, in _parse_kexdh_gex_reply
self.transport._verify_key(host_key, sig)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 1886, in _verify_key
if not key.verify_ssh_sig(self.H, Message(sig)):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\dsskey.py", line 148, in verify_ssh_sig
key = dsa.DSAPublicNumbers(
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 212, in public_key
return backend.load_dsa_public_numbers(self)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 871, in load_dsa_public_numbers
dsa._check_dsa_parameters(numbers.parameter_numbers)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\tplink\tplink_jetstream.py", line 145, in _override_check_dsa_parameters
if crypto_utils.bit_length(parameters.q) not in [160, 256]:
AttributeError: module 'cryptography.utils' has no attribute 'bit_length'
Traceback (most recent call last):
File "C:\Users\melih.celik\Desktop\New_Backup\Yedek\Coding\Rand stuff\ssh_deneme(toplu).py", line 75, in
config_backup(cihaz_secim,ip_address,username,password)
File "C:\Users\melih.celik\Desktop\New_Backup\Yedek\Coding\Rand stuff\ssh_deneme(toplu).py", line 12, in config_backup
net_connect=ConnectHandler(**switch) #Baglanti kuruldu.
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\ssh_dispatcher.py", line 312, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 346, in init
self._open()
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 351, in _open
self.establish_connection()
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\base_connection.py", line 920, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\client.py", line 406, in connect
t.start_client(timeout=timeout)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 660, in start_client
raise e
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 2075, in run
self.kex_engine.parse_next(ptype, m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 101, in parse_next
return self._parse_kexdh_gex_reply(m)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\kex_gex.py", line 281, in _parse_kexdh_gex_reply
self.transport._verify_key(host_key, sig)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\transport.py", line 1886, in _verify_key
if not key.verify_ssh_sig(self.H, Message(sig)):
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\paramiko\dsskey.py", line 148, in verify_ssh_sig
key = dsa.DSAPublicNumbers(
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\primitives\asymmetric\dsa.py", line 212, in public_key
return backend.load_dsa_public_numbers(self)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 871, in load_dsa_public_numbers
dsa._check_dsa_parameters(numbers.parameter_numbers)
File "C:\Users\melih.celik\AppData\Local\Programs\Python\Python39\lib\site-packages\netmiko\tplink\tplink_jetstream.py", line 145, in _override_check_dsa_parameters
if crypto_utils.bit_length(parameters.q) not in [160, 256]:
AttributeError: module 'cryptography.utils' has no attribute 'bit_length'
Thanks for your help in advance.
It looks like tplink_jetstream.py assumes that a (now removed) helper function is available to it. The simplest fix here would be to go into that file and modify the line containing crypto_utils.bit_length(parameters.q) to read parameters.q.bit_length() instead.

Django testrunner not working properly

the following code:
class CreateSurveyFromCsvTextTests(TestCase):
def test_parses_survey_passed_in_as_csv_and_returns_xml_representation(self):
self.assertTrue(True)
throws the following error:
ERROR: test_parses_survey_passed_in_as_csv_and_returns_xml_representation (dkobo.formbuilder.tests.CreateSurveyFromCsvTextTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/test/testcases.py", line 178, in __call__
self._pre_setup()
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/test/testcases.py", line 749, in _pre_setup
self._fixture_setup()
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/test/testcases.py", line 861, in _fixture_setup
if not connections_support_transactions():
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/test/testcases.py", line 848, in connections_support_transactions
for conn in connections.all())
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/test/testcases.py", line 848, in <genexpr>
for conn in connections.all())
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/utils/functional.py", line 49, in __get__
res = instance.__dict__[self.func.__name__] = self.func(instance)
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 664, in supports_transactions
self.connection.leave_transaction_management()
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 317, in leave_transaction_management
if managed == self.get_autocommit():
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 324, in get_autocommit
self.ensure_connection()
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 124, in ensure_connection
self.connect()
File "/home/nico/.virtualenvs/kf/local/lib/python2.7/site-packages/django/db/utils.py", line 86, in __exit__
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
AttributeError: 'DatabaseWrapper' object has no attribute 'Database'
----------------------------------------------------------------------
I know this doesn't tell you much about the problem, and it's probably an environment problem, but I'm new to Linux/Python (switched from Windows/.Net 7 days ago) and wouldn't really know where to start gathering information, let alone diagnosing the error.
The problem was that the database was not configured. Adding the default entry for DATABASE in settings.py and the running python manage.py syncdb fixed it.

GAE can't generate discovery file

I upgraded my GAE SDK to Version 1.8.5 and cannot generate a discovery file anymore with endpointscfg.py gen_discovery_doc -o.-f rpc .../main.FlyFlap.APi
I get the errors below.
I tried to delete the file google_appengine/lib/cacerts/urlfetch_cacerts.txt and certs.txt like it is suggested here, but it didn't help. Does someone got same problems?
Traceback (most recent call last):
File "/usr/local/bin/endpointscfg.py", line 196, in <module>
run_file(__file__, globals())
File "/usr/local/bin/endpointscfg.py", line 192, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 472, in <module>
sys.exit(main(sys.argv))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 467, in main
args.callback(args)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 348, in _GenDiscoveryDocCallback
output_path, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 188, in GenDiscoveryDoc
service_configs = GenApiConfig(service_class_names, hostname=hostname)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 144, in GenApiConfig
module_name, base_service_class_name = service_class_name.rsplit('.', 1)
ValueError: need more than 1 value to unpack
updated osx and it works again.

Categories

Resources