예제 #1
0
def outclear():
    taskNameList = []
    manager = CfgManager('Start.cfg')
    value = manager.getValue('task', 'filename')
    if isinstance(value, str):
        taskNameList = list(eval(value))
    taskNum = len(taskNameList)
    if taskNum:
        for i in xrange(taskNum):
            taskName = taskNameList[i]
            currentDir = os.getcwd()
            pwd = '%s/%s.out' % (currentDir, taskName)
            if os.path.exists(pwd):
                cmd = 'rm %s' % pwd
                os.system(cmd)
예제 #2
0
#!/usr/bin/env python
#coding:utf-8
import os
from CfgManager import *
import Schedu
import Email
import SmsAlidayu

first_time = True

global manager
manager = CfgManager('Nginx.cfg')


def observe():
    errorstring = ''
    curTime = manager.getIntValue(sectionHeader='setup', key='curtime')
    global first_time
    try:
        nginx = os.popen('ps -ef|grep nginx|grep -v grep').readlines()
        if len(nginx) < 1:
            errorstring = '无nginx进程'
    except Exception, e:
        errorstring = str(e)
    finally:
        if len(errorstring):
            print errorstring
            curTime += 1
            maxTime = manager.getIntValue(sectionHeader='setup', key='maxtime')
            if curTime >= maxTime:
                curTime = 0
예제 #3
0
# !/usr/bin/dev python
# coding: utf-8
import urllib2
import Schedu
from CfgManager import *
import threading
import Email
import SmsAlidayu
import subprocess

first_time = True

global manager
manager = CfgManager('Elsearch.cfg')


def requestRun(http):
    def removeBlank(s):
        return s and s.strip()

    url = http
    req = urllib2.Request(url)
    try:
        res_data = urllib2.urlopen(req)
        res = res_data.readlines()
        status = False
        for i in range(1, len(res)):
            sublist = filter(removeBlank, res[i].split(' '))
            if "green" in sublist:
                status = True
            else:
예제 #4
0
# !/usr/bin/dev python
# coding:utf-8

import os
from CfgManager import *

global manager
manager = CfgManager('Start.cfg')


def func():
    taskNameList = []
    value = manager.getValue('task', 'filename')
    if isinstance(value, str):
        taskNameList = list(eval(value))
    taskNum = len(taskNameList)
    if taskNum:
        for i in xrange(taskNum):
            taskName = taskNameList[i]
            cmd = 'nohup python %s > %s.out 2>&1 &' % (taskName, taskName)
            os.system(cmd)


if __name__ == '__main__':
    func()
예제 #5
0
def change_settings():
    cfg.change_cfg()
    print('\033[1;31m--Finished--\033[0m')
    main()
예제 #6
0
def show_tree():
    cfg.show_cfgtree()
    print('\033[1;31m--Finished--\033[0m')
    main()
예제 #7
0
import cv2 as cv
import face_recognition
import os
import np
import copy
import webcolors
import CfgManager as cfg
from PIL import Image

# 读取设置
face_path = cfg.read_cfg('face_path')  # 人脸字典路径
camera = int(cfg.read_cfg('camera'))  # 默认启用摄像头

tolerance = float(cfg.read_cfg('tolerance'))  # 契合度阈值
border_color = webcolors.name_to_rgb(cfg.read_cfg('border_color'))  # 人脸边框颜色
border_thickness = int(cfg.read_cfg('border_thickness'))  # 边框厚度
is_performance_mode = cfg.read_cfg('is_performance_mode')  # 是否启用性能模式

# 全局变量
known_face_names = []


def jpeg2jpg(path_in, path_out):
    # jpeg转jpg
    img = Image.open(path_in)
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


def read_directory(directory_name):
    # 读取指定目录中的所有图片并返回图片列表
    array_of_img = []
예제 #8
0
# !/usr/bin/dev python
# coding:utf-8

import redis
from CfgManager import *
from datetime import timedelta, datetime
import Schedu
import Email
import SmsAlidayu

first_time = True

global manager
manager = CfgManager('Redis.cfg')


class RedisObserve:
    def __init__(self, host=None, port=None, password=None):
        self.host = host
        self.r = redis.Redis(host=self.host, port=port, password=password)

    def set(self, key, value, time):
        return self.r.setex(key, value, time)

    def get(self, key):
        return self.r.get(key)


def redisStatus():
    host = manager.getValue(sectionHeader='setup', key='host')
    port = manager.getIntValue(sectionHeader='setup', key='port')
예제 #9
0
# !/usr/bin/dev python
# coding: utf-8
import subprocess
from CfgManager import *
import threading
import Schedu
import Email
import SmsAlidayu

global manager
manager = CfgManager('Tomcat.cfg')


class myThread(threading.Thread):
    def __init__(self, name):
        threading.Thread.__init__(self)
        self.name = name

    def run(self):
        threadLock.acquire()
        net = manager.getValue(sectionHeader=self.name, key='net')
        if isinstance(net, str):
            netlist = list(eval(net))
        status = processRun(netlist[0])
        resultAction(name=self.name, status=status)
        threadLock.release()


threadLock = threading.Lock()