FlexGW企业版镜像安装报错ValueError: invalid literal for int() with base 10: 'Sat Feb 22 13:20:42 2020'
问题描述:

2020-02-22 13:27:23,904 INFO: [Request Message]: GET https://119.253.11.11/vpn/dial/add
2020-02-22 13:28:24,140 INFO: [Request Message]: GET https://119.253.11.11/vpn/dial/settings
2020-02-22 13:28:30,335 INFO: [Request Message]: GET https://119.253.11.11/vpn/dial/console
2020-02-22 13:28:35,167 INFO: [Request Message]: GET https://119.253.11.11/vpn/dial/download
2020-02-22 13:36:36,768 INFO: [Request Message]: GET https://119.253.11.11/vpn/dial/
2020-02-22 13:36:36,782 ERROR: [Exception Request]: invalid literal for int() with base 10: 'Sat Feb 22 13:20:42 2020'
2020-02-22 13:36:36,782 ERROR: Exception on /vpn/dial/ [GET]
Traceback (most recent call last):
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/flexgw/python/lib/python2.7/site-packages/flask_login.py", line 758, in decorated_view
return func(*args, **kwargs)
File "/usr/local/flexgw/website/vpn/dial/views.py", line 35, in index
accounts = get_accounts(status=True)
File "/usr/local/flexgw/website/vpn/dial/services.py", line 253, in get_accounts
account['ct'] = datetime.fromtimestamp(int(status['ct'])).strftime('%Y-%m-%d %H:%M:%S')
ValueError: invalid literal for int() with base 10: 'Sat Feb 22 13:20:42 2020'
解决办法:
问题描述:
报错原因是格式化时间转换问题,此处需要时间戳,而此处得到是格式化时间字符串,所以我们只要把格式化时间转换成时间戳即可解决问题。
1.定位问题位置: vim /usr/local/flexgw/website/vpn/dial/services.py 找到253行,account['ct'] = datetime.fromtimestamp(int(status['ct'])).strftime('%Y-%m-%d %H:%M:%S') 2.修改代码解决问题,详细的参照下图:
添加 import time
修改 account['ct'] = datetime.fromtimestamp(int(time.mktime(time.strptime(status['ct'])))).strftime('%Y-%m-%d %H:%M:%S')




浙公网安备 33010602011771号