python-rabbitmq

#!/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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值