#!/usr/bin/python
# -*- coding: utf-8 -*-
from rabbitmq.utils import *
import os
import yaml
import sys
import json
import time
import datetime
Local_dir = os.path.join(os.path.dirname(__file__),'../..')
YAML_PATH = Local_dir + '/yaml/'
UPDATE_PATH = Local_dir + '/jenkins/'
LOCATION = 'sh'
FAIL_HISTORY_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/fail/'
CONTENT_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/message_cache/'
MSG_HISTORY_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/history/'
argvs_params = []
argvs_params = sys.argv[1:]
if len(argvs_params) > 0:
param = argvs_params[0]
else:
param = 'you_have_not_given_the_jenkins_url'
def record_fail_history(fail_message,fail_content):
if not os.path.exists(FAIL_HISTORY_PATH):
os.makedirs(FAIL_HISTORY_PATH)
print '--history:', FAIL_HISTORY_PATH
f = file(FAIL_HISTORY_PATH + 'fail.txt','a')
fail_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
f.write('-----------------------------------------------------' + '\n')
f.write('[message-fail]:' + fail_message + ' ' + fail_time + '\n')
f.write('[message-jekins_url]:' + param + '\n')
f.write('[message-content]:' + fail_content + '\n')
f.close()
def put_in_record(path_dir,content):
if not os.path.exists(CONTENT_PATH):
os.makedirs(CONTENT_PATH)
if os.path.isfile(path_dir):
os.remove(path_dir)
f = file(path_dir,'a')
f.write(content)
f.close()
def record_msg_history(content):
if not os.path.exists(MSG_HISTORY_PATH):
os.makedirs(MSG_HISTORY_PATH)
print '--history:', MSG_HISTORY_PATH
f = file(MSG_HISTORY_PATH + 'history.txt','a')
msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
f.write('-----------------------------------------------------' + '\n')
f.write('[message]:' + msg_time + '\n')
f.write('[message-jekins_url]:' + param + '\n')
f.write('[message-content]:' + content + '\n')
f.close()
# -*- coding: utf-8 -*-
from rabbitmq.utils import *
import os
import yaml
import sys
import json
import time
import datetime
Local_dir = os.path.join(os.path.dirname(__file__),'../..')
YAML_PATH = Local_dir + '/yaml/'
UPDATE_PATH = Local_dir + '/jenkins/'
LOCATION = 'sh'
FAIL_HISTORY_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/fail/'
CONTENT_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/message_cache/'
MSG_HISTORY_PATH = os.path.join(os.path.dirname(__file__),'../../..') + '/history/'
argvs_params = []
argvs_params = sys.argv[1:]
if len(argvs_params) > 0:
param = argvs_params[0]
else:
param = 'you_have_not_given_the_jenkins_url'
def record_fail_history(fail_message,fail_content):
if not os.path.exists(FAIL_HISTORY_PATH):
os.makedirs(FAIL_HISTORY_PATH)
print '--history:', FAIL_HISTORY_PATH
f = file(FAIL_HISTORY_PATH + 'fail.txt','a')
fail_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
f.write('-----------------------------------------------------' + '\n')
f.write('[message-fail]:' + fail_message + ' ' + fail_time + '\n')
f.write('[message-jekins_url]:' + param + '\n')
f.write('[message-content]:' + fail_content + '\n')
f.close()
def put_in_record(path_dir,content):
if not os.path.exists(CONTENT_PATH):
os.makedirs(CONTENT_PATH)
if os.path.isfile(path_dir):
os.remove(path_dir)
f = file(path_dir,'a')
f.write(content)
f.close()
def record_msg_history(content):
if not os.path.exists(MSG_HISTORY_PATH):
os.makedirs(MSG_HISTORY_PATH)
print '--history:', MSG_HISTORY_PATH
f = file(MSG_HISTORY_PATH + 'history.txt','a')
msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
f.write('-----------------------------------------------------' + '\n')
f.write('[message]:' + msg_time + '\n')
f.write('[message-jekins_url]:' + param + '\n')
f.write('[message-content]:' + content + '\n')
f.close()