Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions code/Spike713/001/gm_explain.py
Original file line number Diff line number Diff line change
@@ -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)
36 changes: 36 additions & 0 deletions code/Spike713/002/svn_cmd.py
Original file line number Diff line number Diff line change
@@ -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('命令输入错误')
33 changes: 33 additions & 0 deletions code/Spike713/003/install_apk.py
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 22 additions & 0 deletions code/Spike713/004/adb_screenshot.py
Original file line number Diff line number Diff line change
@@ -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")
135 changes: 135 additions & 0 deletions code/Spike713/005/adb_cpu.py
Original file line number Diff line number Diff line change
@@ -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)
49 changes: 49 additions & 0 deletions code/Spike713/007/generate_config.py
Original file line number Diff line number Diff line change
@@ -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()
Loading