diff --git a/code/Spike713/001/gm_explain.py b/code/Spike713/001/gm_explain.py new file mode 100644 index 0000000..6d5b3dc --- /dev/null +++ b/code/Spike713/001/gm_explain.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : gm_explain.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : + +class gm_explain(): + + + def check_command_is_legal(self, command: str): + ''' + 检查字符串是否符合规定格式 + :param command: + :return: True表示合法 False表示不合法 + ''' + self.command = command + if '{' and '}' not in command: + print('GM命令格式错误,缺少大括号,请重新检查') + return False + if ',' not in command: + print('GM命令格式错误,缺少逗号,请重新检查') + return False + return True + + def add_item_normal(self, command: str): + ''' + 把指定字符串转换成GM命令 + :param command: add_item {{1001 to 1003}},10 这种字符串 + :return: + ''' + self.command = command + if self.check_command_is_legal(self.command): + split = self.command.index(',') + start = self.command.index('{{') + end = self.command.index('}}') + data = self.command[start + 2:end] + number_list = data.split('to') + number_list[0] = int(number_list[0]) + number_list[1] = int(number_list[1]) + if number_list[0] >= number_list[1]: + print('后面的数字需要大于前面的数字') + for i in range(number_list[0], number_list[1]+1): + print('add_item ' + str(i) + self.command[split:]) + + def add_item_by_list(self, command: str): + ''' + 把指定字符串转换成GM命令 + :param command: add_item {{1001,1003,1006}},10 + :return: + ''' + self.command = command + if self.check_command_is_legal(self.command): + split = self.command.index('}},') + start = self.command.index('{{') + end = self.command.index('}}') + data = self.command[start + 2:end] + number_list = data.split(',') + for i in number_list: + print('add_item ' + str(i) + self.command[split + 2:]) + + def add_item_by_list_and_join(self, command: str): + ''' + 把指定字符串转换成GM命令 + :param command:add_item {{1001 to 1005 not 1002,1003}},10 + :return: + ''' + self.command = command + if self.check_command_is_legal(self.command): + split = self.command.index('}},') + start = self.command.index('{{') + end = self.command.index('}}') + data = self.command[start + 2:end] + command_list = data.split('not ') + number_list = command_list[0].split('to') + ban_list = command_list[1].split(',') + number_list[0] = int(number_list[0]) + number_list[1] = int(number_list[1]) + if number_list[0] >= number_list[1]: + print('后面的数字需要大于前面的数字') + for i in range(number_list[0], number_list[1] + 1): + if str(i) not in ban_list: + print('add_item ' + str(i) + self.command[split + 2:]) + + +if __name__ == '__main__': + str1 = 'add_item {{1001 to 1003}},10' + str2 = 'add_item {{1001,1003,1006}},10' + str3 = 'add_item {{1001 to 1005 not 1002,1003}},10' + gm = gm_explain() + gm.add_item_normal(str1) + gm.add_item_by_list(str2) + gm.add_item_by_list_and_join(str3) \ No newline at end of file diff --git a/code/Spike713/002/svn_cmd.py b/code/Spike713/002/svn_cmd.py new file mode 100644 index 0000000..ca8cd82 --- /dev/null +++ b/code/Spike713/002/svn_cmd.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : 2021/9/6 下午 19:30 +# @Author : Spike713 +# @Site : +# @File : svn_cmd.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : +from prettytable import PrettyTable +import os + +x = PrettyTable(["ID", "指令"]) +x.add_row(['1', 'SVN更新主干']) +x.add_row(['2', 'SVN还原主干']) +# x.add_row(['3', '启动游戏客户端']) +x.add_row(['4', '打开主干目录']) +print(x) +print("选择指令"); + +trunk_folder = 'D:/jqdj_v2' +# trunk_client = 'D:/trunk/client.exe' + +command = input(); +if command == '1': + os.system("svn update D:/jqdj_v2") +elif command == '2': + os.system("svn update -r 200 trunk") +# elif command == '3': + # os.startfile("trunk_client") +elif command == '4': + os.startfile(trunk_folder) +else: + print('命令输入错误') \ No newline at end of file diff --git a/code/Spike713/003/install_apk.py b/code/Spike713/003/install_apk.py new file mode 100644 index 0000000..2cab5f6 --- /dev/null +++ b/code/Spike713/003/install_apk.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : install_apk.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : +import os + +apkpath_list: list = [] + +def get_all_apk(file): + + for root, dirs, files in os.walk(file): # 列出所有文件夹或文件名 + for f in files: + filepath = os.path.join(root, f) # os.path.join:将路径与文件或文件夹合在一起 + + if os.path.basename(filepath).endswith('.apk'): # 查找”.apk“结尾的文件 + apkpath_list.append(filepath) # apkpath_list列表里加入上面查找到的文件 +def install_apk(apklist: list): + + for apk in apklist: + os.system('adb install -r ' + apk) + + +if __name__ == '__main__': + get_all_apk('C:\\Users\\Administrator\\Desktop\\UAuto') + print(apkpath_list) + install_apk(apkpath_list) diff --git a/code/Spike713/004/adb_screenshot.py b/code/Spike713/004/adb_screenshot.py new file mode 100644 index 0000000..8ff8f18 --- /dev/null +++ b/code/Spike713/004/adb_screenshot.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : adb_screenshot.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : +import os, time + +def cap_screen_by_adb(folder): + + nowtime = time.localtime() + times = time.strftime("%Y%m%d%H%M%S", nowtime) + os.system("adb shell screencap -p /sdcard/screenshot" + times + ".png") + os.system("adb pull /sdcard/screenshot" + times + ".png " + folder) + +if __name__ == '__main__': + cap_screen_by_adb("D:/bugreport") \ No newline at end of file diff --git a/code/Spike713/005/adb_cpu.py b/code/Spike713/005/adb_cpu.py new file mode 100644 index 0000000..f4e14b4 --- /dev/null +++ b/code/Spike713/005/adb_cpu.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : adb_cpu.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : +import os, re, time +from pyecharts import Line + +""" +配置游戏包名和名字 +""" +package_name = "com.racoondigi.jieqiusanduisan" # 配置测试包名 +game_name = "街球艺术" + + +class Phone(): + def __init__(self): + self.mem = os.popen("adb shell dumpsys meminfo %s" % package_name) + # self.cpu = os.popen("adb shell cat /proc/24863/stat") + for i in self.mem.readlines(): + if "MEMINFO" in i: + self.pid_info = i + break + self.mem.close() + try: + self.pid = int(self.pid_info.split(" ")[4]) + print("pid:", self.pid) + except: + raise IOError("检查adb连接并启动游戏") + + f = os.popen("adb shell cat /proc/stat") + data = f.readlines() + f.close() + count = 0 + for i in data: + if "cpu" in i: + count += 1 + else: + count -= 1 + break + self.count = count + print("进程数:", self.count) + + def cpu_test(self): + """ + 测试cpu数据,总体数据根据乘以核 + :return: + """ + + def cpu_time(): + f = os.popen("adb shell cat /proc/stat") + data = f.readlines() + f.close() + time_list = map(lambda x: int(x), data[0].split(" ")[2:-1]) + return sum(time_list) + + def thread_time(): + z = os.popen("adb shell cat /proc/%s/stat" % self.pid) + data = z.readlines()[0].split(" ") + z.close() + processCPUtime = sum(map(lambda x: int(x), [data[13], data[14], data[15], data[16]])) + return processCPUtime + + cpu_time1, thread_time1 = cpu_time(), thread_time() + cpu_time2, thread_time2 = cpu_time(), thread_time() + + cpu_usage = 100 * (thread_time2 - thread_time1) / (cpu_time2 - cpu_time1) + print(cpu_usage) + return cpu_usage * self.count + + def total_test(self, test_time, duration): + """ + 测试pss和cpu + :param test_time: 测试时间,单位s + :param duration: 测试刷新间隔 + :return: 时间list, psstotal数据, cpu数据的list + """ + i = 0 + time_init = int(time.time()) + time_end = time_init + test_time + current_time = int(time.time()) + psslist, time_list, cpu_list = [], [], [] + while current_time < time_end: + t = os.popen("adb shell dumpsys meminfo %s" % self.pid) + content = t.readlines() + t.close() + for item in content: + if "TOTAL" in item: + pss_info = item + break + cpu_info = float("%.2f" % self.cpu_test()) + pss = float(re.findall("\d+\d|\d", pss_info)[0]) / 1000 + psstotal = float("%.2f" % pss) + current_time = int(time.time()) + # print ("测试倒计时:%s秒"%(current_time-time_init)) + time_test = time.strftime("%H:%M:%S") + # time_test = time.strftime("%Y-%m-%d %H:%M:%S") + print(time_test, "PssTotal=", psstotal, "CPU=", cpu_info) + psslist.append(psstotal) + time_list.append(time_test) + cpu_list.append(cpu_info) + time.sleep(duration) + i += 1 + maxlist = sorted(psslist, reverse=True) + average_pss = sum(psslist) / i + print("平均PssTotal", average_pss) + print("最高PssTotal", maxlist[0]) + print("最低PSSTotal", maxlist[-1]) + return [psslist, time_list, cpu_list] + + def graphic(self, test_time, duration): + """ + 作图,调用测试 + :param test_time:测试时间,单位s + :param duration: 刷新间隔 + :return: + """ + pss_list = self.total_test(test_time=test_time, duration=duration) + attr = pss_list[1] + v1 = pss_list[0] + v2 = pss_list[2] + line = Line(game_name) + line.add("PSS_total(M)", attr, v1, mark_point=["max"]) + line.add("CPU(%)", attr, v2, mark_point=["max"]) + line.render() + + +p = Phone() +p.graphic(20, 1) diff --git a/code/Spike713/007/generate_config.py b/code/Spike713/007/generate_config.py new file mode 100644 index 0000000..8ee9df0 --- /dev/null +++ b/code/Spike713/007/generate_config.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : generate_config.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : + +from openpyxl.reader.excel import load_workbook + +def open_workbook(excel_path:str): + ''' + 打开一个excel文件 + :param excel_path: + :return: + ''' + wb = load_workbook(excel_path) + # 获取workbook中所有的表格 + sheetnames = wb.get_sheet_names() + # 读取表格内容 + ws = wb.get_sheet_by_name(sheetnames[0]) + output = "" + # i:行数 + for i in range(1, ws.max_row): + temp_str = " [" + str(i) + "] = {\n" + v_list = [j.value for j in ws[i+1] if (j.value)] + item_type_list = v_list[::2] + item_count_list = v_list[1::2] + s = "" + for i in range(len(item_type_list)): + s = s + make_one_reward(i+1, item_type_list[i], item_count_list[i]) + '\n' + s = temp_str + s + " },\n" + output = output + s + output = "{\n" + output + "}" + return output + +def make_one_reward(row, item_type, item_count): + s = " [{}] = {{reward_type = REWARD_TYPE_ITEM, item_type = {}, item_count = {},}},".format(row, item_type, item_count) + return s + +s = open_workbook('/Users/Administrator/Desktop/快速生成奖励配置/配置模板.xlsx') +print(s) +f = open(r'/Users/Administrator/Desktop/快速生成奖励配置/reward.lua', 'w') +print(s, file = f) +f.close() \ No newline at end of file diff --git a/code/Spike713/008/csv_cheak.py b/code/Spike713/008/csv_cheak.py new file mode 100644 index 0000000..8dc8b29 --- /dev/null +++ b/code/Spike713/008/csv_cheak.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : csv_check.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : + +from openpyxl.reader.excel import load_workbook +# import lupa + +#class Csvcheck(): + + +def check_lua(excel_path): + ''' + 检查lua数据列,是否存在中文标点符号,是否存在不连续的{} + column_num: lua数据列的列号码 + :return: + ''' + wb = load_workbook(excel_path) + sheetnames = wb.get_sheet_names() + ws = wb.get_sheet_by_name(sheetnames[0]) + + cn_str = [",", "。", ";", ":"] + for i in range(2, ws.max_row + 1): + #for j in range(2, ws.max_column + 1): + lua_str = str(ws.cell(i, 1).value) + for k in cn_str: + if k in lua_str: + print("检查到中文字符!! 行数:{} 列数:{}".format(i, 1)) + if lua_str.count("{") != lua_str.count("}"): + print("{{和}}的个数不相等!! 行数:{} 列数:{}".format(i, 1)) + +if __name__ == '__main__': +# s = Csvcheck('/Users/Administrator/Desktop/快速生成奖励配置/reward.xlsx') +# s.check_id() + check_lua('/Users/Administrator/Desktop/快速生成奖励配置/reward.xlsx') \ No newline at end of file diff --git a/code/Spike713/009/get_xlsx_columns.py b/code/Spike713/009/get_xlsx_columns.py new file mode 100644 index 0000000..e8e934b --- /dev/null +++ b/code/Spike713/009/get_xlsx_columns.py @@ -0,0 +1,55 @@ +import xlrd +import os + +#得到某个表中所有列的数据 +def get_xlsx_columns(path): + work_book = xlrd.open_workbook(path) + sheet_0 = work_book.sheet_by_index(0) + columns=[] + #xlrd会把int 自动转成浮点,所以做了点特殊处理 ,不让它带小数点同时转成str方便后面的搜索 + for i in range(sheet_0.ncols): + column=[] + for j in range(sheet_0.nrows): + cell = sheet_0.cell(j,i) + cell_value = cell.value + if cell.ctype == 2 and cell.value%1 ==0 : + cell_value= str(int(cell_value)) + column.append(cell_value) + columns.append(column) + return columns + + +#得到配置表文件夹下所有的xlsx路径 +def get_xlsx_path_list(file_dir): + L=[] + for root, dirs, files in os.walk(file_dir): + for file in files: + if os.path.splitext(file)[1] == '.xlsx': + L.append(os.path.join(root, file)) + return L + +#从阿拉伯数字的列数转换成 表格中的字母列数 +#比如 0 行显示成A 行 ,26行显示成AA行 +def num_2_column(num): + m =num//26 + r =num%26 + if(m>=1): #超过了Z列 + left = chr(m+64) + right = chr(r+65) + return left+right + else: #没有超过Z列(A~Z) + return chr(num+65) + + +if __name__ == '__main__': + + key = input("请输入要搜索的关键字:") + file_dir = "E:\Common\Config" #配置表所在位置 + #file_dir = "D:\configtest" + xlsx_list = get_xlsx_path_list(file_dir) + + for xlsx in xlsx_list: + for index,column in enumerate(get_xlsx_columns(xlsx)): + #print(column) + if key in column: + print("{0} 第{1}行 第{2}列".format(xlsx,column.index(key)+1,num_2_column(index))) \ No newline at end of file diff --git a/code/Spike713/010/apk_download.py b/code/Spike713/010/apk_download.py new file mode 100644 index 0000000..7db09b9 --- /dev/null +++ b/code/Spike713/010/apk_download.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# @Time : +# @Author : Spike713 +# @Site : +# @File : apk_download.py +# @Purpose : +# @Software : PyCharm +# @Copyright: +# @Licence : + +from flask import Flask, render_template, send_from_directory +import os, socket, qrcode, time, json + +app = Flask(__name__) + +""" +使用方法: +1、配置apk路径、端口(folder) +2、运行app.py +3、打开浏览器 localhost:7777 +""" + +file = "/Users/Administrator/Desktop/apk下载" +port = 7777 + + +def get_host_ip(): + try: + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect(('8.8.8.8', 80)) + ip = s.getsockname()[0] + finally: + s.close() + return ip + + +def get_qrcod(file, port): + img = qrcode.make("http://" + get_host_ip() + ":%s/download/" % port + file) + img.get_image() + name = 'jqdj_1.0.49_55_s.apk.png' + img.save(name) + + +def get_file(): + file_list = "" + for i in os.listdir(file): + file_path = file + "/" + i + create_time = str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.path.getmtime(file)))) + file_size = str(float("%.3f" % (os.path.getsize(file_path) / 1000000))) + "MB" + file_list = file_list + i + "=" + create_time + "=" + file_size + "," + get_qrcod(i, port) + return file_list[:-1] + + +@app.route("/") +def index(): + return render_template("index.html", apks=(get_file())) + + +@app.route("/download/", methods=['GET']) +def download_file(filename): + # 需要知道2个参数, 第1个参数是本地目录的path, 第2个参数是文件名(带扩展名) + return send_from_directory(file, filename, as_attachment=True) + + +if __name__ == '__main__': + app.run(host="0.0.0.0", port=port, debug=True, threaded=True) \ No newline at end of file diff --git a/code/Spike713/010/templates/index.html b/code/Spike713/010/templates/index.html new file mode 100644 index 0000000..6bc54e0 --- /dev/null +++ b/code/Spike713/010/templates/index.html @@ -0,0 +1,33 @@ + + + + + 下载APK + + +

下载apk

+
+ + + \ No newline at end of file