MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / ftp_menu

Method ftp_menu

script/btcli.py:1585–1650  ·  view source on GitHub ↗

FTP管理菜单

(self)

Source from the content-addressed store, hash-verified

1583 print(Colors.error("无效的选择"))
1584
1585 def ftp_menu(self):
1586 """FTP管理菜单"""
1587 while True:
1588 print("\n" + "-"*50)
1589 print(Colors.info(" FTP管理"))
1590 print("-"*50)
1591 print(" 1. 显示FTP列表")
1592 print(" 2. 添加FTP账户")
1593 print(" 3. 删除FTP账户")
1594 print(" 0. 返回上级")
1595 print("-"*50)
1596
1597 choice = input("\n请选择操作 [0-3]: ").strip()
1598
1599 if choice == '1':
1600 self.ftp_mgr.list_ftp()
1601 elif choice == '2':
1602 ftp_status = self.ftp_mgr.get_ftp_status()
1603 if not ftp_status:
1604 print(Colors.error("FTP服务未启动,请先登录面板开启FTP服务后再执行操作"))
1605 print(Colors.error("或手动执行 /etc/init.d/pure-ftpd start 启动后再尝试"))
1606 continue
1607
1608 print(Colors.info("\n=== 添加FTP账户 ==="))
1609 username = input("FTP用户名 (必填): ").strip()
1610 if not username:
1611 print(Colors.error("FTP用户名不能为空"))
1612 continue
1613
1614 password = input("FTP密码 (必填): ").strip()
1615 if not password:
1616 print(Colors.error("FTP密码不能为空"))
1617 continue
1618
1619 if len(password) < 6:
1620 print(Colors.error("FTP密码长度不能少于6位"))
1621 continue
1622
1623 path = input(f"FTP根目录 (回车使用默认:/www/wwwroot/{username}): ").strip() or f"/www/wwwroot/{username}"
1624 # if not path:
1625 # print(Colors.error("FTP根目录不能为空"))
1626 # continue
1627
1628 ps = input("备注 (默认: 用户名): ").strip() or username
1629
1630 # 构造参数
1631 kwargs = {'ps': ps}
1632
1633 self.ftp_mgr.add_ftp(username, password, path, **kwargs)
1634
1635 elif choice == '3':
1636 ftp_status = self.ftp_mgr.get_ftp_status()
1637 if not ftp_status:
1638 print(Colors.error("FTP服务未启动,请先登录面板开启FTP服务后再执行操作"))
1639 print(Colors.error("或手动执行 /etc/init.d/pure-ftpd start 启动后再尝试"))
1640 continue
1641 ftp_user = input("请输入FTP用户名或ID: ").strip()
1642 if ftp_user:

Callers 1

show_main_menuMethod · 0.95

Calls 6

list_ftpMethod · 0.80
get_ftp_statusMethod · 0.80
add_ftpMethod · 0.80
delete_ftpMethod · 0.80
infoMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected