Update index.py

This commit is contained in:
dami 2026-02-01 17:37:09 +08:00
parent 6817cafbfa
commit e5797ef6a8
1 changed files with 72 additions and 1 deletions

View File

@ -76,6 +76,16 @@ class classApi:
t = {'name': i}
databases.append(t)
data['databases'] = databases
plugin = []
for i in args['plugin']:
# print('db:', i)
if i == '':
continue
t = {'name': i}
plugin.append(t)
data['plugin'] = plugin
return data
def fock_process(self, args):
@ -753,6 +763,63 @@ class classApi:
except:
self.error(mw.getTracebackInfo())
def print_directory_tree(self, directory, prefix=""):
"""递归打印目录树结构"""
items = sorted(os.listdir(directory))
for i, item in enumerate(items):
item_path = os.path.join(directory, item)
is_last = i == len(items) - 1
if os.path.isdir(item_path):
print(f"{prefix}{'└── ' if is_last else '├── '}{item}/")
extension = " " if is_last else ""
self.print_directory_tree(item_path, prefix + extension)
else:
print(f"{prefix}{'└── ' if is_last else '├── '}{item}")
def upload_dir(self, src, dst):
"""递归打印目录树结构"""
items = sorted(os.listdir(src))
for i, item in enumerate(items):
item_path = os.path.join(src, item)
is_last = i == len(items) - 1
if os.path.isdir(item_path):
# print("dir:",item_path, dst+'/'+item)
self.upload_dir(item_path, dst+'/'+item)
else:
# print("file:",item_path, dst+'/'+item)
self.upload_file(item_path, dst+'/'+item)
def sync_plugin_webssh(self):
name = "webssh"
webssh_dir = mw.getServerDir()+'/'+name
# 递归遍历所有文件和目录并打印
print(f"\n目录树结构: {webssh_dir}")
print("=" * 50)
if os.path.exists(webssh_dir):
# self.print_directory_tree(webssh_dir)
self.upload_dir(webssh_dir, "/www/server/"+name)
else:
print(f"目录不存在: {webssh_dir}")
print("=" * 50)
def sync_plugin(self):
data = getCfgData()
plugin = self._SYNC_INFO['plugin']
for x in plugin:
if x['name'] == 'webssh':
self.sync_plugin_webssh()
def run(self):
# 开始迁移
# self.upload_file("/tmp/mysql-boost-5.7.39.tar.gz", "/tmp/mysql-boost-5.7.39.tar.gz")
@ -761,6 +828,7 @@ class classApi:
self.sync_site()
self.sync_database()
# self.sync_path()
self.sync_plugin()
self.write_speed('action', 'True')
write_log('|-所有项目迁移完成!')
@ -952,9 +1020,12 @@ def get_src_info(args):
my_db_pos = mw.getServerDir() + '/mysql'
conn = mw.M('databases').dbPos(my_db_pos, 'mysql')
data['databases'] = conn.field('id,name,ps').order("id desc").select()
data['plugin'] = []
webssh_dir = mw.getServerDir() + '/webssh'
if os.path.exists(webssh_dir):
data['plugin'].append(webssh_dir)
data['plugin'] = ["webssh"]
return data