image.png

#!/usr/bin/env python
#coding=utf-8
import json,datetime,requests,os,time
from xlwt import  *
import threading,math
# from tkinter import *
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
# from aliyunsdkcore.acs_exception.exceptions import ClientException
# from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkram.request.v20150501.ListUsersRequest import ListUsersRequest
from aliyunsdkram.request.v20150501.ListPoliciesForUserRequest import ListPoliciesForUserRequest #权限策略
from aliyunsdkram.request.v20150501.ListGroupsForUserRequest import ListGroupsForUserRequest   #加入的权限组
from aliyunsdkcms.request.v20190101.DescribeMetricLastRequest import DescribeMetricLastRequest  #监控数据
from aliyunsdkecs.request.v20140526.TagResourcesRequest import TagResourcesRequest  #打标签
# from aliyunsdkecs.request.v20140526.DescribeRegionsRequest import DescribeRegionsRequest  #获取地域ID

import tkinter as tk
from tkinter import  ttk
import tkinter.messagebox
from tkinter.filedialog import askopenfilename
# import pickle
currentversion='1.3'
startTime=(datetime.datetime.now() + datetime.timedelta(days=-7)).strftime("%Y-%m-%d")
startTime='{} 00:00:00'.format(startTime)
endTime=(datetime.datetime.now()).strftime("%Y-%m-%d")
endTime='{} 23:59:59'.format(endTime)
# 窗口
window = tk.Tk()
window.title('云产品导出工具   --当前版本{}'.format(currentversion))
# window.geometry('360x360')
# 设置窗口居中
width = 380
height = 380
screenwidth = window.winfo_screenwidth()
screenheight = window.winfo_screenheight()
alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth-width)/2, (screenheight-height)/2)
window.geometry(alignstr)
# # 画布放置图片
# canvas = tk.Canvas(window, height=300, width=500)
# imagefile = tk.PhotoImage(file='qm.png')
# image = canvas.create_image(0, 0, anchor='nw', image=imagefile)
# canvas.pack(side='top')
# tk.Label(window,font=("宋体", 12),text='例子: abcefg 123456 ').place(x=50, y=15)
# 标签 用户名密码
tk.Label(window, text='Access  KeyId:').place(x=50, y=10)
tk.Label(window, text='Access  Secret:').place(x=50, y=40)
tk.Label(window, text='RegionId(可选项):').place(x=50, y=70)
tk.Label(window, text='请选择功能(必选项):').place(x=50, y=100)
tk.Label(window, text='RAM查询数(默认100):').place(x=50, y=130)
tk.Label(window, text='标签键(打标签时必填):').place(x=50, y=160)
tk.Label(window, text='标签值(打标签时必填):').place(x=50, y=190)
tk.Label(window, text='开始时间(默认前7天):').place(x=50, y=220)
tk.Label(window, text='结束时间(默认当前):').place(x=50, y=250)

# 用户名输入框
var_usr_name = tk.StringVar()
entry_usr_name = tk.Entry(window, textvariable=var_usr_name)
entry_usr_name.place(x=180, y=10)
# 密码输入框
var_usr_pwd = tk.StringVar()
entry_usr_pwd = tk.Entry(window, textvariable=var_usr_pwd)
entry_usr_pwd.place(x=180, y=40)
#地域下拉框
var_RegionId=tk.StringVar()
entry_RegionId = ttk.Combobox(window,state="readonly", textvariable=var_RegionId,width=18)
entry_RegionId.place(x=180, y=70)      #将下拉菜单绑定到窗体
entry_RegionId["value"] = ("cn-hangzhou","cn-shenzhen","cn-beijing","cn-shanghai","cn-guangzhou","cn-hongkong")  # #给下拉菜单设定值
entry_RegionId.current(0)
#功能下拉框
var_usr_pm=tk.StringVar()
entry_usr_name = ttk.Combobox(window,state="readonly",textvariable=var_usr_pm,width=18)
entry_usr_name.place(x=180, y=100)
options=["空", "权限明细","CPU明细","内存明细","磁盘明细","快照明细","批量打标签","RDS版本","Redis版本","MongoDB版本","K8S组件版本","ARMS告警明细"]
entry_usr_name["values"] = options
# entry_usr_name["value"] = ('空','权限明细','CPU明细','内存明细','磁盘明细','批量打标签')
entry_usr_name.current(0)
# 查询用户数
var_usr_id = tk.StringVar()
entry_usr_id = tk.Entry(window, textvariable=var_usr_id)
entry_usr_id.place(x=180, y=130)
# entry_usr_id.insert(0, u'权限功能时,输入有效')
# 标签键输入框
var_tag_name = tk.StringVar()
entry_tag_name = tk.Entry(window, textvariable=var_tag_name)
entry_tag_name.place(x=180, y=160)
# entry_tag_name.insert(0, u'标签功能时,输入有效')
# 标签值输入框
var_tag_value = tk.StringVar()
entry_tag_value = tk.Entry(window, textvariable=var_tag_value)
entry_tag_value.place(x=180, y=190)
# entry_tag_value.insert(0, u'标签功能时,输入有效')
# 开始时间输入框
var_startTime = tk.StringVar()
entry_startTime = tk.Entry(window, textvariable=var_startTime)
entry_startTime.place(x=180, y=220)
entry_startTime.insert(0, u'{}'.format(startTime))
# 结束时间输入框
var_endTime = tk.StringVar()
entry_endTime = tk.Entry(window, textvariable=var_endTime)
entry_endTime.place(x=180, y=250)
entry_endTime.insert(0, u'{}'.format(endTime))
#文件路径
v1 = tk.StringVar()
filepath = tk.Entry(window,state="readonly",textvariable=v1)  #.pack(fill=X, side=LEFT)  # x方向填充,靠左
v1.set('实例ID逐行排列无须符号')
filepath.place(x=180, y=280)
# filepath.insert(0, u'实例ID须逐行排列')

def xiancheng(vlaue):
    T = threading.Thread(target=vlaue)
    # T.setDaemon(True)
    T.start()
该部分仅登录用户可见
最后修改:2023 年 08 月 31 日
如果觉得我的文章对您有用,请随意赞赏!