添加FTP账户 Args: username: FTP用户名 password: 密码 path: FTP根目录 **kwargs: 其他参数
(self, username: str, password: str, path: str, **kwargs)
| 558 | print(Colors.error(f"获取FTP列表失败: {str(e)}")) |
| 559 | |
| 560 | def add_ftp(self, username: str, password: str, path: str, **kwargs): |
| 561 | """ |
| 562 | 添加FTP账户 |
| 563 | |
| 564 | Args: |
| 565 | username: FTP用户名 |
| 566 | password: 密码 |
| 567 | path: FTP根目录 |
| 568 | **kwargs: 其他参数 |
| 569 | """ |
| 570 | try: |
| 571 | # 构造参数 |
| 572 | args = public.dict_obj() |
| 573 | args.ftp_username = username |
| 574 | args.ftp_password = password |
| 575 | args.path = path |
| 576 | args.ps = kwargs.get('ps', username) |
| 577 | |
| 578 | result = self.ftp_obj.AddUser(args) |
| 579 | |
| 580 | if result.get('status'): |
| 581 | print(Colors.success(f"✓ FTP账户创建成功: {username}")) |
| 582 | print(f" 路径: {path}") |
| 583 | else: |
| 584 | print(Colors.error(f"✗ FTP账户创建失败: {result.get('msg', '未知错误')}")) |
| 585 | |
| 586 | except Exception as e: |
| 587 | print(Colors.error(f"添加FTP账户失败: {str(e)}")) |
| 588 | |
| 589 | def delete_ftp(self, ftp_id: int = None, ftp_username: str = None): |
| 590 | """ |