编写界面
This commit is contained in:
parent
2520bf558b
commit
46f336a5c6
1 changed files with 66 additions and 7 deletions
73
manage.py
73
manage.py
|
@ -2,11 +2,10 @@ from configparser import ConfigParser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from json import dump
|
from json import dump
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from tkinter import *
|
||||||
|
from tkinter.ttk import *
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
|
|
||||||
conf = config.read("config.ini")
|
|
||||||
|
|
||||||
options = {"ftp": ["host", "user", "pass", "lftp"], "file": ["local", "remote"]}
|
options = {"ftp": ["host", "user", "pass", "lftp"], "file": ["local", "remote"]}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@ def check_config_valid(config: ConfigParser, options: dict[str, list[str]]) -> b
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def default_config(config: ConfigParser, options: dict[str, list[str]]) -> None:
|
def set_default_config(config: ConfigParser, options: dict[str, list[str]]) -> None:
|
||||||
config.clear()
|
config.clear()
|
||||||
for sec in options:
|
for sec in options:
|
||||||
config.add_section(sec)
|
config.add_section(sec)
|
||||||
|
@ -30,8 +29,9 @@ def default_config(config: ConfigParser, options: dict[str, list[str]]) -> None:
|
||||||
config.write(f)
|
config.write(f)
|
||||||
|
|
||||||
|
|
||||||
|
config.read("config.ini")
|
||||||
if not check_config_valid(config, options):
|
if not check_config_valid(config, options):
|
||||||
default_config(config, options)
|
set_default_config(config, options)
|
||||||
|
|
||||||
|
|
||||||
def generate_db(config: ConfigParser) -> None:
|
def generate_db(config: ConfigParser) -> None:
|
||||||
|
@ -49,7 +49,7 @@ def generate_db(config: ConfigParser) -> None:
|
||||||
dump(output, f)
|
dump(output, f)
|
||||||
|
|
||||||
|
|
||||||
generate_db(config)
|
# generate_db(config)
|
||||||
|
|
||||||
sync_all_command = [
|
sync_all_command = [
|
||||||
config["ftp"]["lftp"],
|
config["ftp"]["lftp"],
|
||||||
|
@ -67,4 +67,63 @@ sync_files_command = [
|
||||||
config["ftp"]["host"],
|
config["ftp"]["host"],
|
||||||
]
|
]
|
||||||
|
|
||||||
print(subprocess.run(sync_files_command))
|
|
||||||
|
def tfunc(txt: str) -> None:
|
||||||
|
print(txt)
|
||||||
|
|
||||||
|
|
||||||
|
# print(subprocess.run(sync_files_command))
|
||||||
|
|
||||||
|
root = Tk()
|
||||||
|
|
||||||
|
ftp_header_frm = Frame(root)
|
||||||
|
ftp_header_frm.grid(row=0, column=0)
|
||||||
|
|
||||||
|
Label(ftp_header_frm, text="FTP Settings").grid(row=0, column=0, padx=5, pady=5)
|
||||||
|
|
||||||
|
ftp_settings_frm = Frame(root)
|
||||||
|
ftp_settings_frm.grid(row=1, column=0)
|
||||||
|
|
||||||
|
Label(ftp_settings_frm, text="Host").grid(row=0, column=0, padx=5, pady=5)
|
||||||
|
host_entry = Entry(ftp_settings_frm)
|
||||||
|
host_entry.insert(0, config["ftp"]["host"])
|
||||||
|
host_entry.grid(row=0, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
Label(ftp_settings_frm, text="Username").grid(row=1, column=0, padx=5, pady=5)
|
||||||
|
user_entry = Entry(ftp_settings_frm)
|
||||||
|
user_entry.insert(0, config["ftp"]["user"])
|
||||||
|
user_entry.grid(row=1, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
Label(ftp_settings_frm, text="Password").grid(row=2, column=0, padx=5, pady=5)
|
||||||
|
pass_entry = Entry(ftp_settings_frm)
|
||||||
|
pass_entry.insert(0, config["ftp"]["pass"])
|
||||||
|
pass_entry.grid(row=2, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
Label(ftp_settings_frm, text="lftp Path").grid(row=3, column=0, padx=5, pady=5)
|
||||||
|
lftp_entry = Entry(ftp_settings_frm)
|
||||||
|
lftp_entry.insert(0, config["ftp"]["lftp"])
|
||||||
|
lftp_entry.grid(row=3, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
file_header_frm = Frame(root)
|
||||||
|
file_header_frm.grid(row=2, column=0)
|
||||||
|
|
||||||
|
Label(file_header_frm, text="File Path Settings").grid(
|
||||||
|
row=0, column=0, columnspan=2, padx=5, pady=5
|
||||||
|
)
|
||||||
|
|
||||||
|
file_settings_frm = Frame(root)
|
||||||
|
file_settings_frm.grid(row=3, column=0)
|
||||||
|
|
||||||
|
Label(file_settings_frm, text="Local Path").grid(row=0, column=0, padx=5, pady=5)
|
||||||
|
local_entry = Entry(file_settings_frm)
|
||||||
|
local_entry.insert(0, config["file"]["local"])
|
||||||
|
local_entry.grid(row=0, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
Label(file_settings_frm, text="Remote Path").grid(row=1, column=0, padx=5, pady=5)
|
||||||
|
remote_entry = Entry(file_settings_frm)
|
||||||
|
remote_entry.insert(0, config["file"]["remote"])
|
||||||
|
remote_entry.grid(row=1, column=1, padx=5, pady=5)
|
||||||
|
|
||||||
|
|
||||||
|
# Button(ftp_settings_frm, text="Save Config").grid(row=5, column=0, columnspan=2, padx=5, pady=5)
|
||||||
|
root.mainloop()
|
||||||
|
|
Loading…
Reference in a new issue