I have the following wheezy template:
#for i in pos:
#i[0] : #swi['x'] : #i[1]
#end
which for instance would output:
Z:val:x
yet, I would like to do something like:
#swi[#i[1]!s]
but it returns syntax error.
I need to lookup in swi using the current iteration data.
Traceback (most recent call last):
File "toto.py", line 53, in <module>
template = engine.get_template('x')
File "/Soft/fox_dev/redhat/dist/other/lib/python2.6/site-packages/wheezy.template-0.1.151-py2.6.egg/wheezy/template/engine.py", line 41, in get_template
self.compile_template(name)
File "/Soft/fox_dev/redhat/dist/other/lib/python2.6/site-packages/wheezy.template-0.1.151-py2.6.egg/wheezy/template/engine.py", line 89, in compile_template
source, name)['render']
File "/Soft/fox_dev/redhat/dist/other/lib/python2.6/site-packages/wheezy.template-0.1.151-py2.6.egg/wheezy/template/compiler.py", line 26, in compile_source
source = adjust_source_lineno(source, name, self.source_lineno)
File "/Soft/fox_dev/redhat/dist/other/lib/python2.6/site-packages/wheezy.template-0.1.151-py2.6.egg/wheezy/template/comp.py", line 21, in adjust_source_lineno
source = compile(source, name, 'exec', ast.PyCF_ONLY_AST)
File "x", line 7
w(' '); w(i[0]); w(' : '); w(swi[#i[1]]); w(' : '); w(i[1]); w('\n')
^
SyntaxError: invalid syntax
i've tried:
#swi[#i[1]!s]
#swi['#i[1]!s']
#swi[#i[1]]
#swi['#i[1]']
the answer is:
#swi[i[1]]
I'm not sure why the # is not allowed here...
Related
I Try to make plugin in qgis and I have a problem. Below is my code:
destination_layer = QgsProject.instance().mapLayersByName('Destination')[0]
matrix = QgsProject.instance().mapLayersByName('join')[0]
for f in matrix.getFeatures():
origin_expr = QgsExpression('Site Name={}'.format(f['Site Name']))
destination_expr = QgsExpression('Site Name={}'.format(f['Site Name_2']))
origin_feature = origin_layer.getFeatures(QgsFeatureRequest(origin_expr))
origin_coords = [(f.geometry().asPoint().x(), f.geometry().asPoint().y())
for f in origin_feature]
destination_feature = destination_layer.getFeatures(QgsFeatureRequest(destination_expr))
destination_coords = [(f.geometry().asPoint().x(), f.geometry().asPoint().y())
for f in destination_feature]
params = {
'INPUT':'NCR Road',
'START_POINT':'{},{}'.format(origin_coords[0][0], origin_coords[0][1]),
'END_POINT':'{},{}'.format(destination_coords[0][0], destination_coords[0][1]),
'STRATEGY':0,
'ENTRY_COST_CALCULATION_METHOD':0,
'DIRECTION_FIELD':'',
'VALUE_FORWARD':'',
'VALUE_BACKWARD':'',
'VALUE_BOTH':'',
'DEFAULT_DIRECTION':2,
'SPEED_FIELD':'',
'DEFAULT_SPEED':50,
'TOLERANCE':0,
'OUTPUT': 'Shortest Path Layer' }
print('Executing analysis')
processing.runAndLoadResults("qneat3:shortestpathpointtopoint", params)
Then when I run my code, it show this error:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS32~1.0\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 16, in <module>
IndexError: list index out of range
Why it is not working in plugin?
We need more information like which code is on line 90? Anyway I would double check and making sure your index is doing correct things
'START_POINT':'{},{}'.format(origin_coords[0][0], origin_coords[0][1]),
'END_POINT':'{},{}'.format(destination_coords[0][0], destination_coords[0][1]),
And
destination_layer = QgsProject.instance().mapLayersByName('Destination')[0]
matrix = QgsProject.instance().mapLayersByName('join')[0]
I've started working on a curses program in python and I have come across this issue. The code "logo.addstr(count, 1, line)" gives this error:
Traceback (most recent call last):
File "intro.py", line 90, in <module>
curses.wrapper(main)
File "/usr/lib/python3.7/curses/__init__.py", line 102, in wrapper
return func(stdscr, *args, **kwds)
File "intro.py", line 22, in main
show_rank_logo()
File "intro.py", line 87, in show_rank_logo
logo.addstr(count, 1, line)
_curses.error: addwstr() returned ERR
If you replace "count" with 1, the lines will show up but on one line (as it should). This file is ASCII art so I want it to display in the window (named logo) all at once. This is why I added a count to the loop. But the variable which equals 1 somehow gives an error.
def show_rank_logo():
logo = curses.newwin(35, 105, 1, 51)
logo.box()
count = 1
with open('platinum_logo.txt') as file:
for line in file.readlines():
logo.addstr(count, 1, line)
count += 1
logo.refresh()
Looking for any help!
I want to analyze log file of mongodb. I am referred to use m-tools. But I'm getting following error.
I've typed in terminal
mlonginfo /..logfilelocation../ --queries
Error:
QUERIES [============================== ] 74.1 % Traceback (most recent call last):
File "/usr/local/bin/mloginfo", line 9, in <module>
load_entry_point('mtools==1.1.8', 'console_scripts', 'mloginfo')()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/mloginfo.py", line 82, in main
tool.run()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/mloginfo.py", line 77, in run
section.run()
File "/usr/local/lib/python2.7/dist-packages/mtools/mloginfo/sections/query_section.py", line 51, in run
for i, le in enumerate(logfile):
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logfile.py", line 208, in __iter__
le = self.next()
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logfile.py", line 190, in next
ret = le.set_datetime_hint(self._datetime_format, self._datetime_nextpos, self.year_rollover)
File "/usr/local/lib/python2.7/dist-packages/mtools/util/logevent.py", line 246, in set_datetime_hint
if not self.split_tokens[self._datetime_nextpos-1][0].isdigit():
IndexError: list index out of range
Thanks in advance.
I have a document:
class Hamburger(Document):
size = IntField(default=0, required=True)
which I can use fine
h = Hamburger()
h.size = 5
h.save()
until I try an update_one for example
Hamburger.objects().update_one(set__size=5)
which throws this exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 467, in update_one
upsert=upsert, multi=False, write_concern=write_concern, **update)
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 430, in update
update = transform.update(queryset._document, **update)
File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/transform.py", line 207, in update
field = cleaned_fields[-1]
IndexError: list index out of range
It is possible to have a Document with a field called size? Is there any way to achieve this?
I have enabled LDAP on tuleap. But when I go to subversion> Browse SVN tree, I get following error
An Exception Has Occurred
Python Traceback
Traceback (most recent call last): File
"/usr/share/viewvc/lib/viewvc.py", line 3814, in main
request.run_viewvc() File "/usr/share/viewvc/lib/viewvc.py", line 318, in run_viewvc
if not svnaccess.check_read_access(user.user_getname(), self.rootpath, self.where): File
"/usr/share/tuleap/src/www/../utils/svn/svnaccess.py", line 130, in
check_read_access
username = get_name_for_svn_access(svnrepo, username) File "/usr/share/tuleap/src/www/../utils/svn/svnaccess.py", line 119, in
get_name_for_svn_access
return codendildap.get_login_from_username(username) File "/usr/share/tuleap/src/www/../utils/svn/codendildap.py", line 60, in
get_login_from_username
return get_login_from_eduid(row['ldap_id']) File "/usr/share/tuleap/src/www/../utils/svn/codendildap.py", line 43, in
get_login_from_eduid
l = ldap_connect() File "/usr/share/tuleap/src/www/../utils/svn/codendildap.py", line 33, in
ldap_connect
l = ldap.initialize(server) File "/usr/lib64/python2.6/site-packages/ldap/functions.py", line 85, in
initialize
return LDAPObject(uri,trace_level,trace_file,trace_stack_limit) File "/usr/lib64/python2.6/site-packages/ldap/ldapobject.py", line
69, in __init__
self._l = ldap.functions._ldap_function_call(_ldap.initialize,uri) File
"/usr/lib64/python2.6/site-packages/ldap/functions.py", line 57, in
_ldap_function_call
result = func(*args,**kwargs) LDAPError:(0, 'Error')
$sys_ldap_server = 'X.X.X.X:xxx'; $sys_ldap_cn='cn'; $sys_ldap_people_dn='ou=Users,dc=xxxx,dc=org'; $sys_ldap_search_user='(|(uid=%words%)(cn=%words%))'; $sys_ldap_default_user_status='A'; $sys_ldap_svn_auth=1; $sys_ldap_daily_sync=1; $sys_ldap_user_management=1; $sys_ldap_grp_enabled = 1; $sys_ldap_grp_dn='ou=groups,dc=xxxx,dc=org'; $sys_ldap_grp_cn = 'cn'; $sys_ldap_grp_member='uniquemember';
The LDAP server configuration variable should be defined with ldap:// (or ldaps:// for SSL LDAP)