Hi,
I am facing an issue basically I have code which would generate the description of the Item Code based on the variants of an item code, now the problem is that I have some characters which are causing issues in my production server and not in my test environment both are on v11-staging so the only difference which I can see is that the production server is on python 2.7 and test env is on python 3.0
The error is as below:
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
main()
File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
click.Group(commands=commands)(prog_name='bench')
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 129, in execute
ret = frappe.get_attr(method)(*args, **kwargs)
File "/home/frappe/frappe-bench/apps/rigpl_erpnext/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/variant_copy.py", line 13, in check_wrong_variants
copy_from_template()
File "/home/frappe/frappe-bench/apps/rigpl_erpnext/rigpl_erpnext/rigpl_erpnext/scheduled_tasks/variant_copy.py", line 45, in copy_from_template
it_doc.save()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 260, in save
return self._save(*args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 296, in _save
self.run_before_save_methods()
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 876, in run_before_save_methods
self.run_method("validate")
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1048, in composer
return composed(self, method, *args, **kwargs)
File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1033, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "/home/frappe/frappe-bench/apps/rigpl_erpnext/rigpl_erpnext/rigpl_erpnext/item.py", line 23, in validate
generate_description(doc,method)
File "/home/frappe/frappe-bench/apps/rigpl_erpnext/rigpl_erpnext/rigpl_erpnext/item.py", line 357, in generate_description
concat1 = concat1 + str(suffix[0][0][1:-1])
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201d' in position 0: ordinal not in range(128)
Now the 2 special characters I want to show in my item description which are causing this issue are:
and
So I have tried using the symbol directly from character map where it causes the above error and also I have tried Ø or ° in there place but problem with using this instead of the symbol directly from the character map is that it would export the reports with the similar Ø into excel.
Now I am kind of stuck between python unicode error and usability.
If I use the symbol Ø or º in description I am getting a unicode error in python 2.5 but it works fine with exporting of the reports into excel
But if I use Ø or ° instead of symbols I am not getting the error in python 2.5 but it would then export these symbols as values in excel which causes a lot of confusion.
Also I am very much perplexed as to why this same code is working perfectly with my test env on my notebook with same DB and same code, the only reason I can think of is that it has python 3.0
Please any one can tell me what should I do get this error removed.