I was trying to retrieve some data from DB in Python.and I got this error:
Traceback:
Traceback (innermost last):
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/app.py", line 49, in application
response = frappe.handler.handle()
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/handler.py", line 66, in handle
execute_cmd(cmd)
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/handler.py", line 77, in execute_cmd
method = get_attr(cmd)
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/handler.py", line 98, in get_attr
method = frappe.get_attr(cmd)
File "/home/adminuser/frappe-bench- hitech/apps/frappe/frappe/__init__.py", line 519, in get_attr
return getattr(get_module(modulename), methodname)
AttributeError: 'module' object has no attribute 'generate_barcode'
here is what I was doing:
#frappe.whitelist()
def generate_barcode(self):
brand=self.get("brand_code")
final_barcode="%05d" % random.randint(0,9999)
return {'final_barcode':final_barcode,'brand':brand}
can anyone help me?
The whitespace before #frappe.whitelist() could be the problem.
Related
When I run my code, I get this error: AttributeError: 'str' object has no attribute 'is_stale'. Any idea what's going wrong?
Code:
from uber_rides.session import Session
from uber_rides.client import UberRidesClient
ACCESS_TOKEN = "[redacted]"
session = Session(oauth2credential=ACCESS_TOKEN)
client = UberRidesClient(session)
response = client.get_products(37.77, -122.41)
Error message:
Traceback (most recent call last):
File "/Users/slandeta/uber/uber_api.py", line 8, in <module>
response = client.get_products(37.77, -122.41)
File "/Users/slandeta/opt/anaconda3/lib/python3.9/site-packages/uber_rides/client.py", line 127, in get_products
return self._api_call('GET', 'v1.2/products', args=args)
File "/Users/slandeta/opt/anaconda3/lib/python3.9/site-packages/uber_rides/client.py", line 96, in _api_call
self.refresh_oauth_credential()
File "/Users/slandeta/opt/anaconda3/lib/python3.9/site-packages/uber_rides/client.py", line 718, in refresh_oauth_credential
if credential.is_stale():
AttributeError: 'str' object has no attribute 'is_stale'
I am using bencode library and I am trying to encode and decode binary data:
>>> import bencode
>>> bencode.Bencoder.decode(bencode.Bencoder.encode({'x': b'xyz'}))
Traceback (most recent call last):
File "<input>", line 1, in <module>
bencode.Bencoder.decode(bencode.Bencoder.encode({'x': b'xyz'}))
File "/home/pt12lol/virtualenv-python3/lib/python3.5/site-packages/bencode/__init__.py", line 228, in decode
return _decode(becode_string)
File "/home/pt12lol/virtualenv-python3/lib/python3.5/site-packages/bencode/__init__.py", line 197, in _decode
data = _decode_item(pf, six.next(src))
File "/home/pt12lol/virtualenv-python3/lib/python3.5/site-packages/bencode/__init__.py", line 178, in _decode_item
tok = next()
File "/home/pt12lol/virtualenv-python3/lib/python3.5/site-packages/bencode/__init__.py", line 147, in _tokenizer
s = m.group(m.lastindex) #
http://stackoverflow.com/questions/22489243/re-in-python-lastindex-attribute
AttributeError: 'NoneType' object has no attribute 'group'
How can I manage it?
Traceback (most recent call last):
File "E:\blahblahblah\emailsend.py", line 26, in <module>
msg.attach(MIMEText(file))
File "E:\blahblahblah\Python 2.7.11\lib\email\mime\text.py", line 30, in __init__
self.set_payload(_text, _charset)
File "E:\blahblahblah\Python 2.7.11\lib\email\message.py", line 226, in set_payload
self.set_charset(charset)
File "E:\blahblahblah\Python 2.7.11\lib\email\message.py", line 268, in set_charset
cte(self)
File "E:\blahblahblah\Python 2.7.11\lib\email\encoders.py", line 73, in encode_7or8bit
orig.encode('ascii')
AttributeError: 'file' object has no attribute 'encode'https://stackoverflow.com/questions/ask#
I've been looking this up a lot but I haven't found an answer.
The only important parts of the code is this:
file = open('newfile.txt')
msg.attach(MIMEText(file))
There are other parts but I've debugged it and I get the error at the 'msg.attach(MIMEText(file))' line.
Any help?
MIMEText takes the content of the file, not the file object.
msg.attach(MIMEText(open("newfile.txt").read()))
I am trying to setup commonsearch and i am the point where backend imports alexa1m data to rocksdb, but it die with error( error below ).
Traceback (most recent call last):
File "urlserver/import.py", line 21, in <module>
ds.import_dump()
File "./urlserver/datasources/__init__.py", line 62, in import_dump
for i, row in self.iter_dump():
File "./urlserver/datasources/__init__.py", line 102, in iter_dump
f = self.open_dump()
File "./urlserver/datasources/__init__.py", line 144, in open_dump
return GzipStreamFile(f)
File "/cosr/back/venv/src/gzipstream/gzipstream/gzipstreamfile.py", line 62, in __init__
super(GzipStreamFile, self).__init__(self._gzipstream)
File "/usr/lib64/python2.6/io.py", line 921, in __init__
raw._checkReadable()
AttributeError: '_GzipStreamFile' object has no attribute '_checkReadable'
have been fighting with this without progress for 2 days now.. if somebody could givme somekind of insight or advice i would be more than happy!
Found the solution, it was problem in the data parsed to the tool, not the tool itself.
I have python-memcached (1.57) and django-celery (3.1.17), celery (3.1.20) and python 3.5. I always get the error below when i try to implement http://docs.celeryproject.org/en/latest/tutorials/task-cookbook.html#ensuring-a-task-is-only-executed-one-at-a-time
Task tasks.live_task[a2ed1faf-0fce-4855-a206-40f2fbdae1a8] raised unexpected: TypeError("a bytes-like object is required, not 'str'",)
Traceback (most recent call last):
File "/app/current/venv/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/app/current/venv/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/app/current/src/helps.py", line 62, in wrapper
if acquire():
File "/app/current/src/helps.py", line 57, in acquire
return cache.add(id, "true", time_out)
File "/app/current/venv/lib/python3.5/site-packages/django/core/cache/backends/memcached.py", line 80, in add
return self._cache.add(key, value, self.get_backend_timeout(timeout))
File "/app/current/venv/lib/python3.5/site-packages/memcache.py", line 633, in add
return self._set("add", key, val, time, min_compress_len, noreply)
File "/app/current/venv/lib/python3.5/site-packages/memcache.py", line 983, in _set
server, key = self._get_server(key)
File "/app/dashboard/current/venv/lib/python3.5/site-packages/memcache.py", line 413, in _get_server
serverhash = serverHashFunction(str(serverhash) + str(i))
File "/app/current/venv/lib/python3.5/site-packages/memcache.py", line 65, in cmemcache_hash
(((binascii.crc32(key) & 0xffffffff)
TypeError: a bytes-like object is required, not 'str'
python-memchached is not supported on python 3.5
If you've used python-memchached, The following commands will help you.
pip uninstall python-memcached
pip install python3-memcached