Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'int' object has no attribute 'decode' #10

Open
newhwa opened this issue Sep 16, 2018 · 13 comments
Open

AttributeError: 'int' object has no attribute 'decode' #10

newhwa opened this issue Sep 16, 2018 · 13 comments

Comments

@newhwa
Copy link

newhwa commented Sep 16, 2018

File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 2295, in wsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except:
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask_compat.py", line 35, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\ProgramData\Anaconda3\lib\site-packages\flask_compat.py", line 35, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\Users<user>\Python\jhao104\SSDBAdmin\SSDBAdmin\apps\index.py", line 34, in index
server_info = SSDBClient(request).serverInfo()
File "C:\Users<user>\Python\jhao104\SSDBAdmin\SSDBAdmin\model\SSDBClient.py", line 51, in serverInfo
info_list = [.decode() for _ in self.__conn.execute_command('info')]
File "C:\Users<user>\Python\jhao104\SSDBAdmin\SSDBAdmin\model\SSDBClient.py", line 51, in
info_list = [
.decode() for _ in self.__conn.execute_command('info')]
AttributeError: 'int' object has no attribute 'decode'

@jhao104
Copy link
Owner

jhao104 commented Sep 17, 2018

@newhwa 拉的那个版本,用的python那个版本?

@newhwa
Copy link
Author

newhwa commented Sep 20, 2018

@newhwa 拉的那个版本,用的python那个版本?

Python 3.6.6+

@newhwa 拉的那个版本,用的python那个版本?

最近用
git clone https://github.com/jhao104/SSDBAdmin.git
安装, 应该就是master 最新版本
$python --verson

Python 3.6.6+

@jhao104
Copy link
Owner

jhao104 commented Sep 20, 2018

info_list = [_.decode() for _ in self.__conn.execute_command('info')]

看日志像是info出来的有int型;
你试试改成
info_list = [_ if isinstance(_,int) else _.decode() for _ in self.__conn.execute_command('info')]

我这边测试info出来的都是byte,如果可以的话告诉我一声。我改下

@liuxthu
Copy link

liuxthu commented Nov 13, 2018

您好,目前解析出现几个问题:
1 [_.decode() for _ in self.__conn.execute_command('info')] 解析出来全是数字,无法一一对应,如果按建议中更改的话,def _parseDiskUsage(_stats):出问题
2 除主页功能外,其他功能要么提示响应错误,要不是无相关命令unknown command 'hlist' 、 ‘qlist’等,是否需要安装另外的环境

@jhao104
Copy link
Owner

jhao104 commented Nov 13, 2018

您好,目前解析出现几个问题:
1 [_.decode() for _ in self.__conn.execute_command('info')] 解析出来全是数字,无法一一对应,如果按建议中更改的话,def _parseDiskUsage(_stats):出问题
2 除主页功能外,其他功能要么提示响应错误,要不是无相关命令unknown command 'hlist' 、 ‘qlist’等,是否需要安装另外的环境

你拉的哪个分支代码? 用的什么python版本

@liuxthu
Copy link

liuxthu commented Nov 20, 2018

您好,目前解析出现几个问题:
1 [_.decode() for _ in self.__conn.execute_command('info')] 解析出来全是数字,无法一一对应,如果按建议中更改的话,def _parseDiskUsage(_stats):出问题
2 除主页功能外,其他功能要么提示响应错误,要不是无相关命令unknown command 'hlist' 、 ‘qlist’等,是否需要安装另外的环境

你拉的哪个分支代码? 用的什么python版本

抱歉,现在才回复。我摘取的是主分支,python版本 3.6

@testerSunshine
Copy link

SSDBAdmin/SSDBAdmin/model/SSDBClient.py
Line 51 in e7c0257
info_list = [_.decode() for _ in self.__conn.execute_command('info')]
看日志像是info出来的有int型;
你试试改成
info_list = [_ if isinstance(_,int) else _.decode() for _ in self.__conn.execute_command('info')]

我这边测试info出来的都是byte,如果可以的话告诉我一声。我改下

[2018-12-03 17:23:18,980] ERROR in app: Exception on /ssdbadmin/queue/ [GET]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/py_work/SSDBAdmin/SSDBAdmin/apps/queue.py", line 36, in queueLists
    page_size=int(page_size))
  File "/usr/local/py_work/SSDBAdmin/SSDBAdmin/model/SSDBClient.py", line 82, in queueList
    items_list = [_.decode() for _ in self.__conn.execute_command('qlist', name_start, name_end, limit)]
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/redis/client.py", line 668, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/redis/client.py", line 680, in parse_response
    response = connection.read_response()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/redis/connection.py", line 629, in read_response
    raise response
redis.exceptions.ResponseError: unknown command 'qlist'

按照上述改完之后,出现另外一个问题,
python版本: Python 3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)

@jhao104
Copy link
Owner

jhao104 commented Dec 4, 2018

@testerSunshine 兄弟 这是ssdb工具 你不会连的是redis吧 qlist就是ssdb支持的命令啊 怎么会unknown command 'qlist'
http://ssdb.io/docs/zh_cn/commands/index.html

@Goldtype
Copy link

@testerSunshine兄弟这是SSDB工具你不会连的是redis的吧 qlist就是SSDB支持的命令啊怎么会未知命令'的QList'
http://ssdb.io/docs/zh_cn/commands/index.html

我连接的是redis,请问这个工具可以兼容redis嘛

这个问题这样调整就不会报错了
info_list = [str(_) for _ in self.__conn.execute_command('info')] # _.decode() 修改为str

@Goldtype
Copy link

我是在 jhao104/proxy_pool 这个项目里看到作者推荐的有您的项目,于是使用的,以为可以兼容redis,如果不能兼容,我还是装个SSDB再看看

@jhao104
Copy link
Owner

jhao104 commented Mar 29, 2019

我是在 jhao104/proxy_pool 这个项目里看到作者推荐的有您的项目,于是使用的,以为可以兼容redis,如果不能兼容,我还是装个SSDB再看看

redis的可视化工具有很多的,网上一大堆。这是只是为ssdb写的一个工具

@Goldtype
Copy link

Goldtype commented Apr 3, 2019

我是在jhao104 / proxy_pool这个项目里看到作者推荐的有您的项目,于是使用的,以为可以兼容redis的,如果不能兼容,我还是装个SSDB再看看

Redis的的可视化工具有很多的,网上一大堆。这是只是为SSDB写的一个工具

感谢回复,我已经开始使用SSDB了。有些小问题如果您有空的话,希望解答一下。

SSDB的hash中 能否高效的根据 value找key
(我通过hkeys、hget 可以实现这个需求,但是效率太慢了,2万条数据查了2分钟,可能是我的使用方法不对,请问有什么可以优化的途径)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@newhwa @jhao104 @testerSunshine @Goldtype @liuxthu and others