today = date.today() # today = datetime.strptime('05/02/2020', "%d/%m/%Y").date() day = today.day month = today.month year = today.year fileName = "Lawsuit report.xlsx" sep = ';' logDbName = "LO_Input_result_" + str(year) + str(month) if day == 1: mongodb.create_db(DB_NAME=logDbName) mongodbresult = Mongodb(logDbName, WFF_ENV=wff_env) else: mongodbresult = Mongodb(logDbName, WFF_ENV=wff_env) ftpLocalUrl = common.getDownloadFolder() + fileName try: sys.argv[1] importLogId = str(sys.argv[1]) importLogInfo = mongodb.getOne(MONGO_COLLECTION=common.getSubUser( subUserType, 'Import'), WHERE={'_id': ObjectId(sys.argv[1])}) except Exception as SysArgvError: if not os.path.isfile(ftpLocalUrl): sys.exit() importLogInfo = { 'collection': collection, 'begin_import': time.time(), 'file_name': fileName,
now = datetime.now() # log.write(now.strftime("%d/%m/%Y, %H:%M:%S") + ': Start Import' + '\n') try: try: sys.argv[1] importLogId = str(sys.argv[1]) importLogInfo = mongodb.getOne(MONGO_COLLECTION=common.getSubUser( subUserType, 'Import'), WHERE={'_id': ObjectId(importLogId)}) except Exception as SysArgvError: ftpInfo = mongodb.getOne(MONGO_COLLECTION=common.getSubUser( subUserType, 'ftp_config'), WHERE={'collection': collection}) ftpConfig = config.ftp_config() ftpLocalUrl = common.getDownloadFolder() + ftpInfo['filename'] if path.exists(ftpLocalUrl) == False: sys.exit() importLogInfo = { 'collection': 'Telesalelist', 'begin_import': time.time(), 'file_name': ftpInfo['filename'], 'file_path': ftpLocalUrl, 'source': 'ftp', 'status': 2, 'command': '/usr/local/bin/python3.6 ' + base_url + "cronjob/python/Telesales/importTelesale.py > /dev/null &", 'created_by': 'system' }