コード例 #1
0
#!/usr/bin/env python
from __future__ import print_function
import sys
from os.path import dirname, abspath

cmsbot_dir=None
if __file__: cmsbot_dir=dirname(dirname(abspath(__file__)))
else: cmsbot_dir=dirname(dirname(abspath(sys.argv[0])))
sys.path.insert(0,cmsbot_dir)

from es_utils import get_indexes, open_index, find_indexes
from time import time
cur_week=int(((time()/86400)+4)/7)

for i in sys.argv[1:]:
  idxs = find_indexes(i)
  if not 'close' in idxs: continue
  for ix in sorted(idxs['close']):
    print("Opening ", ix)
    open_index(ix)
    print(get_indexes(ix))

コード例 #2
0
ファイル: es_close_indexes.py プロジェクト: gartung/cms-bot
      ixs = find_indexes(ix)
      if not "open" in ixs: continue
      for i in ixs["open"]: idxs.append(i)
except:
  types = {"close":{}, "open":{}}
  rest  = {"close":{}, "open":{}}
  ixs = find_indexes('cmssdt-*')
  for k in ixs:
    for idx in ixs[k]:
      m = re.match("^(.+)[_-]([\d]+)$",idx)
      if m:
        ix = m.group(1)
        wk = m.group(2)
        if not k in types: types[k]={}
        if not ix in types[k]:types[k][ix]=[]
        types[k][ix].append(wk)
        if (k == "open") and ((cur_week-int(wk))>4): idxs.append(idx)
      else:
        if not k in rest: rest[k]=[]
        rest[k].append(idx)
  for k in rest:
    print "REST:",k,":",sorted(rest[k])
  for k in types:
    for ix in sorted(types[k].keys()):
      print "WEEK:",k,":",ix,sorted(types[k][ix])

for idx in sorted(idxs):
  print "Closing ",idx
  close_index(idx)
  print "  ",get_indexes(idx).strip()
コード例 #3
0
ファイル: es_close_indexes.py プロジェクト: zghiche/cms-bot
            for i in ixs["open"]:
                idxs.append(i)
except:
    types = {"close": {}, "open": {}}
    rest = {"close": {}, "open": {}}
    ixs = find_indexes('cmssdt-*')
    for k in ixs:
        for idx in ixs[k]:
            m = re.match("^(.+)[_-]([\d]+)$", idx)
            if m:
                ix = m.group(1)
                wk = m.group(2)
                if not k in types: types[k] = {}
                if not ix in types[k]: types[k][ix] = []
                types[k][ix].append(wk)
                if (k == "open") and ((cur_week - int(wk)) > 4):
                    idxs.append(idx)
            else:
                if not k in rest: rest[k] = []
                rest[k].append(idx)
    for k in rest:
        print "REST:", k, ":", sorted(rest[k])
    for k in types:
        for ix in sorted(types[k].keys()):
            print "WEEK:", k, ":", ix, sorted(types[k][ix])

for idx in sorted(idxs):
    print "Closing ", idx
    close_index(idx)
    print "  ", get_indexes(idx).strip()
コード例 #4
0
#!/usr/bin/python
from os.path import dirname, basename, abspath, join
import sys

cmsbot_dir=None
if __file__: cmsbot_dir=dirname(dirname(abspath(__file__)))
else: cmsbot_dir=dirname(dirname(abspath(argv[0])))
sys.path.insert(0,cmsbot_dir)

from es_utils import get_indexes, open_index, find_indexes
from time import time
cur_week=int(((time()/86400)+4)/7)

for i in sys.argv[1:]:
  idxs = find_indexes(i)
  if not 'close' in idxs: continue
  for ix in sorted(idxs['close']):
    print "Opening ",ix
    open_index(ix)
    print get_indexes(ix)

コード例 #5
0
ファイル: es_close_indexes.py プロジェクト: tulamor/cms-bot
            m = re.match("^(.+)[_-]([\d]+)$", idx)
            if m:
                ix = m.group(1)
                wk = m.group(2)
                if not k in types: types[k] = {}
                if not ix in types[k]: types[k][ix] = []
                types[k][ix].append(wk)
                if ix in ignore_index: continue
                if (k == "open") and ((cur_week - int(wk)) > weeks):
                    idxs.append(idx)
                if (k == "close") and ((cur_week - int(wk)) <= weeks):
                    odxs.append(idx)
            else:
                if not k in rest: rest[k] = []
                rest[k].append(idx)
    for k in rest:
        print("REST:", k, ":", sorted(rest[k]))
    for k in types:
        for ix in sorted(types[k].keys()):
            print("WEEK:", k, ":", ix, sorted(types[k][ix]))

for idx in sorted(idxs):
    print("Closing ", idx)
    close_index(idx)
    print("  ", get_indexes(idx).strip())

for idx in sorted(odxs):
    print("Opening ", idx)
    open_index(idx)
    print("  ", get_indexes(idx).strip())
コード例 #6
0
#!/usr/bin/env python
from __future__ import print_function
from es_utils import get_indexes, open_index, close_index, delete_index, send_request
import sys
import json
from time import sleep

if __name__ == "__main__":

    pattern = sys.argv[1]
    indexes = get_indexes('cmssdt-' + pattern + '*').splitlines()
    indexes_name_only = []
    opened_idxs_list = []
    closed_idxs_list = []

    for i in indexes:
        idx_list = opened_idxs_list
        if 'open' not in i and 'green' not in i:
            idx_list = closed_idxs_list
        list_of_recs = i.split()
        print(list_of_recs)
        for j in list_of_recs:
            if 'cmssdt-' in j:
                indexes_name_only.append(j)
                idx_list.append(j)

    print('list with open idxs', opened_idxs_list)
    print('list with closed idx', closed_idxs_list)

    print('indexes names only')
    print(indexes_name_only)