zoukankan      html  css  js  c++  java
  • 第一个python脚本

    #脚本用于创建es索引及别名

    #!/usr/bin/python
    import json
    import requests
    import datetime
    import time

    #get tomorrow date
    now = datetime.datetime.now()
    delta = datetime.timedelta(days=1)
    n_days = now + delta


    tomorrowDate2 = int(n_days.strftime('%M'))//10
    str = '%d'%tomorrowDate2
    tomorrowDate = n_days.strftime('%Y-%m-%d-%H')+"-"+str

    #create_indices_function
    def create_index(type):
    index_name = type+"-njyh-"+tomorrowDate
    req = "http://ip:9600/" + index_name + "/"
    stats = requests.put(req).json()
    time.sleep(1)
    return

    #create_alias_function_function
    def create_alias(type,alias_name):
    index_name = type+"-njyh-"+tomorrowDate
    req="http://ip:9600/"+index_name+"/_alias/"+alias_name+"-"+tom0rrowDate
    requests.put(req)
    time.sleep(1)
    return

    list1 = ['index_name1','index_name2']
    for index in range(len(list1)):
    create_index(list1[index])
    create_alias(list1[index],list1[index])

  • 相关阅读:
    http状态码
    闭包
    节流和防抖
    继承方式
    array和object对比
    排序算法
    算法题
    汇编 asm 笔记
    FFMPEG 内部 YUV444P016 -> P010
    FFMPEG 内部 YUV444p16LE-> P016LE
  • 原文地址:https://www.cnblogs.com/zhang-zhao/p/9226208.html
Copyright © 2011-2022 走看看