Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pymongo import MongoClient
- from bson.objectid import ObjectId
- import os,pymongo
- dbuser = os.environ.get('muser', '')
- dbpass = os.environ.get('mpwd', '')
- uri = 'mongodb://{dbuser}:{dbpass}@machineip/test'.format(**locals())
- client = MongoClient(uri)
- db = client.data
- collection = db['test']
- print db.version
- cursor = collection.find({})
- for document in cursor:
- if document['version'] == '9.130.39.0.32.6.1':
- for project in document['projects']:
- project_id = project['_id']
- if project['submission']['status'] != 'queued':
- project.update(
- { "_id" : ObjectId(project_id)
- },
- { "$set":
- {
- "status": "queued"
- }
- Traceback (most recent call last):
- File "script.py", line 23, in <module>
- "status": "queued"
- TypeError: update expected at most 1 arguments, got 2
- {
- "_id" : ObjectId("5a95a1c32a2e2e0025e6d6e2"),
- "status" : "Submitting",
- "sanity" : "none",
- "version" : "9.130.39.0.32.6.1",
- "requestTime" : ISODate("2018-02-27T18:21:55.764Z"),
- "projects" : [
- {
- "name" : "BCMFurm_4364_B2_ekans",
- "_id" : ObjectId("5a95a1c32a2e2e0025e6d6eb"),
- "submission" : {
- "status" : "passed", --> this status should change to "queued"
- "system" : "machine.com"
- }
- },
- {
- "name" : "BCMFurm_4364_B2_sid",
- "_id" : ObjectId("5a95a1c32a2e2e0025e6d6ea"),
- "submission" : {
- "status" : "passed",--> this status should change to "queued"
- "system" : "machine.com"
- }
- },
- {
- "name" : "BCMFurm_4364_Notes",
- "_id" : ObjectId("5a95a1c32a2e2e0025e6d6e3"),
- "submission" : {
- "status" : "passed",--> this status should change to "queued"
- "system" : "machine.com"
- }
- }
- ],
- "Notes" : [],
- }
Add Comment
Please, Sign In to add comment