def main(): publisher = Publisher() with open(TRIPDATA_PATH, "r") as trip_data: reader = csv.DictReader(trip_data) for line in reader: publisher.publish(json.dumps(line), '/queue/source') publisher.publish(str('exit'), '/queue/source') publisher.disconnect()
chapter.add_context({"table": app_info}) chapter.add_picture('image', os.path.join(doc_path, image), width=240) document.add_chapter(chapter, title="应用统计", level=3) document.add_context({ 'head_title': head_title, 'doc_date': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') }) document.render() document.save(os.path.join(doc_path, '%s云主机使用情况.docx' % (add_head))) file_name = '%s云主机使用情况.docx' % (add_head) local = os.path.join( '/home/aihc/bhc/robot-node/.toolkit/doc_1_20190807', file_name) # 远程下载文件主机目录配置 remote = os.path.join('/home/maintain/mongoapp/aihc', file_name) upload_file(sftp_ip, sftp_port, sftp_username, sftp_password, local, remote) finally: db_connect.close() pub.disconnect()