mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
尝试添加YAML配置文件编辑功能
This commit is contained in:
@@ -33,6 +33,7 @@ urlpatterns = [
|
||||
path(r'show_log_list', views.show_log_list, name='show_log_list'),
|
||||
path(r'get_log_content', views.get_log_content, name='get_log_content'),
|
||||
path(r'download_log_file', views.download_log_file, name='download_log_file'),
|
||||
path(r'get_config_setting', views.get_config_setting, name='get_config_setting'),
|
||||
path(r'remove_log_api', views.remove_log_api, name='remove_log_api'),
|
||||
path(r'get_site_list', views.get_site_list, name='get_site_list'),
|
||||
path(r'edit_my_site', views.edit_my_site, name='edit_my_site'),
|
||||
|
||||
@@ -10,6 +10,7 @@ import docker
|
||||
import git
|
||||
import qbittorrentapi
|
||||
import transmission_rpc
|
||||
import yaml
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import JsonResponse, FileResponse
|
||||
from django.shortcuts import render
|
||||
@@ -1093,3 +1094,25 @@ def get_site_torrents(request):
|
||||
return JsonResponse(data=CommonResponse.success(
|
||||
msg='种子抓取操作成功!'
|
||||
).to_dict(), safe=False)
|
||||
|
||||
|
||||
def get_config_setting(request):
|
||||
file_path = os.path.join(BASE_DIR, 'db/ptools.yaml')
|
||||
if not os.path.exists(file_path):
|
||||
with open(file_path, 'r') as f:
|
||||
f.write()
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
||||
print(data)
|
||||
|
||||
with open(file_path, 'r') as f:
|
||||
logs = f.readlines()
|
||||
logger.info(f'日志行数:{len(logs)}')
|
||||
return render(request, 'auto_pt/settings.html', context={
|
||||
'config': logs
|
||||
})
|
||||
except Exception as e:
|
||||
return render(request, 'auto_pt/settings.html', context={
|
||||
'config': f'{e}'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user