Closed feldsam closed 8 years ago
feldsam, what version of pymongo do you use? I can't manage to work your code in 'refresh_charts.py':
- for i in list(res):
+ for i in list(res['result']):
Traceback (most recent call last):
File "./refresh_charts2.py", line 179, in <module>
main()
File "./refresh_charts2.py", line 175, in main
top_hosts()
File "./refresh_charts2.py", line 33, in top_hosts
for i in res['result']:
TypeError: 'CommandCursor' object has no attribute '__getitem__'
I've tested it with pymongo 3.1.1 and 3.3.0
Hello, I just installed using pip install -r requirements_py2.txt
Metadata-Version: 1.1
Name: pymongo
Version: 2.5.2
Summary: Python driver for MongoDB <http://www.mongodb.org>
Home-page: http://github.com/mongodb/mongo-python-driver
Author: Bernie Hackett
Author-email: bernie@10gen.com
License: Apache License, Version 2.0
Location: /usr/lib64/python2.7/site-packages
Requires:
Probably, best will will be add package version to requirements.txt file....
According to pymongo 2.5.2 docs some things are changed:
In pymongo >= 3 we see this:
http://api.mongodb.com/python/current/api/pymongo/collection.html
update(spec, document, upsert=False, manipulate=False, multi=False, check_keys=True, **kwargs)
Update a document(s) in this collection. DEPRECATED - Use replace_one(), update_one(), or update_many() instead. Changed in version 3.0: Removed the safe parameter. Pass w=0 for unacknowledged write operations.
http://api.mongodb.com/python/current/api/pymongo/command_cursor.html
So I'll revert your changes for refresh scripts and update requirements to match modern versions.
Oh, sorry, You should also check Flask. I dont't know if latrest version installed or not. I just run that pip and decide that it install latest packeges and app was broken due to missing package versions defined......
What OS do you use? Flask imports is ok for now.
CentOS Linux release 7.2.1511 (Core) Linux backup.feldhost.cz 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Signed-off-by: Kristián Feldsam feldsam@gmail.com