def main(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') epmongo = EPMongo() # epmongo = EPMongo( # uri="mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001", # db_name='epdb-prod') wb = load_workbook('defaultTerminal.xlsx') ws = wb.active max_row = ws.max_row for row in range(2, max_row + 1): default_terminal = {} port_id = ws.cell(row=row, column=3).value stdb = ws.cell(row=row, column=6).value stot = ws.cell(row=row, column=8).value if stdb: default_terminal.setdefault('STDB', ObjectId(stdb)) if stot: default_terminal.setdefault('STOT', ObjectId(stot)) if default_terminal: logging.info('row={} {}:{}'.format(row, port_id, default_terminal)) logging.info( epmongo.update_one( "ports", {'_id': ObjectId(port_id)}, {"$set": { 'defaultTerminal': default_terminal }}))
@Filename: update_organization_status @Author: Gui """ import logging import datetime from epMongo import EPMongo from bson.objectid import ObjectId if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) now = datetime.datetime.utcnow() print(type(now), now) # epmongo = EPMongo() epmongo = EPMongo( uri= "mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001", db_name='epdb-prod') with open('organizationIds.txt') as f: organizations = [line.strip() for line in f.readlines()] for i, organization_id in enumerate(organizations, 1): logging.debug((i, organization_id)) logging.debug( epmongo.update_one("organizations", {'_id': ObjectId(organization_id)}, {"$set": { 'verifyStatus': 1 }})) # epmongo.update_one("organizations", {'_id': ObjectId(organization_id)}, {"$set": {"dateDelete": now}}))
""" import logging from bson.objectid import ObjectId from openpyxl import load_workbook from epMongo import EPMongo if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') # epmongo = EPMongo() epmongo = EPMongo( uri= "mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001", db_name='epdb-prod') wb = load_workbook('ports.xlsx') ws = wb.active j = 1 for i in range(1, ws.max_row + 1): port_id = ObjectId(ws.cell(row=i + 1, column=2).value) country = ws.cell(row=i + 1, column=5).value geo = ws.cell(row=i + 1, column=6).value if country == 'China': logging.debug((j, port_id, country, geo)) j = j + 1 logging.info( epmongo.update_one("ports", {'_id': port_id}, {"$set": { 'geo': geo }}))
# coding=utf-8 """ Created on 2017-12-11 @Filename: update_username_status @Author: Gui """ import logging import datetime from epMongo import EPMongo if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) epmongo = EPMongo( uri= "mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001", db_name='epdb-prod') with open('mailers.txt') as f: users = [line.strip() for line in f.readlines()] now = datetime.datetime.utcnow() for i, username in enumerate(users, 1): logging.debug((i, username)) logging.info( epmongo.update_one("users", {'username': username}, {"$set": { 'status': "normal" }})) # logging.debug(epmongo.update_one("users", {'username': username}, {"$set": {'dateDelete': now}}))
""" Created on 2017-12-28 @Filename: update_organization_status @Author: Gui """ import logging import datetime from epMongo import EPMongo from bson.objectid import ObjectId if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) now = datetime.datetime.utcnow() print(type(now), now) epmongo = EPMongo() # epmongo = EPMongo( # uri="mongodb://*****:*****@172.16.100.1:30001,172.16.100.11:30001,172.16.120.30:30001", # db_name='epdb-prod') with open('shipIds.txt') as f: ships = [line.strip() for line in f.readlines()] for i, ship_id in enumerate(ships, 1): logging.debug((i, ship_id)) logging.debug( epmongo.update_one("ships", {'_id': ObjectId(ship_id)}, {"$set": { "dateDelete": now }}))