Пример #1
0
def run_backup(runtime='now',exclude_file_name='None'):
	if len(sys.argv) == 4:
		print '--------exclude file mode--------'
		if sys.argv[2] == '-X':
			exclude_file_name = sys.argv[3]
			backup_cmd = "tar -cvzfX %s %s %s " %(backup_to_file,exclude_file_name,source_file)
	else:
		print '--------Normal mode:--------'
		backup_cmd = "tar -cvzf %s  %s  |wc -l" %(backup_to_file,source_file) 
	run_command = os.system(backup_cmd)
	if run_command == 0:
		logger.record_log('Full Backup','Success','N/A','test')
	else:
		logger.record_log('Full Backup','Failure','N/A','test')
Пример #2
0
def run_backup(runtime='now', exclude_file_name='None'):
    if len(sys.argv) == 4:
        print("----------------exclue file mode-----------------")
        if sys.argv[2] == '-X':
            exclude_file_name = sys.argv[3]
            backup_cmd = "tar -zcvfX %s %s %s" % (
                backup_to_file, excludee_file_name, source_file)
    else:
        print('-----------Normal mode-------------')
        backup_cmd = "tar -zcvf %s %s " % (backup_to_file, source_file)
    run_command = os.system(backup_cmd)
    if run_command == 0:
        logger.record_log("Full backup", "Success", "N/A", "test")
    else:
        logger.record_log("Full backup", "Failure", "N/A", "test")
Пример #3
0
def alter_center():
	#py_mysql.W_mysql('insert into test values(1);')
	critical_list = json.loads(redis.r['critical::list'])
	well_list = json.loads(redis.r.get('well::list'))
	#判断是否需要发critical的邮件
	if len(redis.r.get('critical::list')) > 2 :
		for i in list(set(critical_list).difference(set(C_list))):
			#print 'i===',i
			host,service,name= i.split(':')
			logger.record_log(host,service,name,'Critical')
			'''
			#sendemail.s_email(host,service,name,'2')
			'''
			C_list.append(i)
			times = time.strftime("%Y%m%d%H%M%S",time.localtime())
			#cmd = 'insert into web_monitor_critical (hostname,service_name,time) values(' +"'"+host+"',"+"'"+service+"',"+"'"+times+"');"
			service_name = service+':'+name
			num = 'C'
			py_mysql.W_mysql(host,service_name,times,num)
			if i in G_list:
				G_list.remove(i)
	#判断是否需要发well的邮件
	if len(redis.r.get('well::list')) > 2 :
		for i in list(set(well_list).difference(set(G_list))):
			host,service,name= i.split(':')
			logger.record_log(host,service,name,'OK')
			'''
			#sendemail.s_email(host,service,name,'3')
			'''
			G_list.append(i)
			#将critical数据插入mysql的well表中
			times = time.strftime("%Y%m%d%H%M%S",time.localtime())
			service_name = service+':'+name
			num = 'W'
			py_mysql.W_mysql(host,service_name,times,num)
			if i in C_list:
				C_list.remove(i)
	

	
	redis.r['f_critical::list'] = json.dumps(C_list)
	redis.r['f_well::list'] = json.dumps(G_list)
	print '=============================================='
	print 'critical_list===>',critical_list
	print 'well_list===>',well_list
	print 'C_list===>',C_list
	print 'G_list===>',G_list
Пример #4
0
def recon(account,cost_amount,expense_type):
     # re-open the data file with wb mode
     pkl_file = open('account.pkl','wb')
     old_position = account_list[account][2]
     if old_position < cost_amount:
	print 'no enough money !'
	sys.exit()
     else:
	
	global intrest
	intrest = 0
	if expense_type == 'Withdraw':

		intrest = cost_amount * 0.05
		new_position = old_position - cost_amount - intrest 
	else:
		
		new_position = old_position - cost_amount

	account_list[account][2] = new_position
	print new_position
	pickle.dump(account_list,pkl_file) # change the account new amount and dump it into file
	pkl_file.close()

print account_list


recon('8908223631',2000,'Withdraw')
logger.record_log('8908223631',2000,'Withdraw',intrest)
Пример #5
0
    # re-open the data file with wb mode
    pkl_file = open('account.pkl', 'wb')
    old_position = account_list[account][2]
    if old_position < cost_amount:
        print 'no enough money !'
        sys.exit()
    else:

        global intrest
        intrest = 0
        if expense_type == 'Withdraw':

            intrest = cost_amount * 0.05
            new_position = old_position - cost_amount - intrest
        else:

            new_position = old_position - cost_amount

        account_list[account][2] = new_position
        print new_position
        pickle.dump(
            account_list,
            pkl_file)  # change the account new amount and dump it into file
        pkl_file.close()


print account_list

recon('8908223631', 2000, 'Withdraw')
logger.record_log('8908223631', 2000, 'Withdraw', intrest)
Пример #6
0
account_list = json.load(pkl_file)
#print(type(account_list))
pkl_file.close()


def recon(account, cost_amount, expense_type):
    pkl_file = open("account.pkl", 'w')
    old_position = account_list[account][2]
    if old_position < cost_amount:
        print("no enought money!")
        json.dump(account_list, pkl_file)
        pkl_file.close()
        sys.exit()
    global intrest
    intrest = 0
    if expense_type == 'withdraw':
        intrest = cost_amount * 0.05
        new_position = old_position - cost_amount - intrest
    else:
        new_position = old_position - cost_amount
    account_list[account][2] = new_position
    json.dump(account_list, pkl_file)
    pkl_file.close()


print(account_list)
recon("123456", 16000, 'withdraw')
#logger.record_log('123456',500,'phone')#花费
logger.record_log('123456', 16000, 'withdraw', intrest)  #取款
Пример #7
0
	pkl_file = open('account.pkl','wb')
	old_position = account_list[account][2] # 获取账户的可用余额
	global intrest
	intrest = 0	

	if old_position < cost_amount:
		print '余额不足!'
		pickle.dump(account_list,pkl_file) # 将账户新的余额格式化写入pkl文件
	        pkl_file.close()
		return False
	else:
		if expense_type == 'Withdraw':
			intrest = cost_amount * 0.05

		new_position = old_position - cost_amount - intrest # 花掉后的余额
		account_list[account][2] = new_position # 新的余额写入字典
		print new_position # 打印出来看看
		pickle.dump(account_list,pkl_file) # 将账户新的余额格式化写入pkl文件
		pkl_file.close()
		return True

print account_list

# recon('1000000001',500)
# logger.record_log('1000000001',500,'Adidas')

if recon('1000000001',800,'Withdraw'):
	logger.record_log('1000000001',800,'Withdraw',intrest)
else:
	logger.record_log('1000000001',0,'Withdraw failure!!!',0)