Skip to content

Commit

Permalink
user_passwd函数重写
Browse files Browse the repository at this point in the history
user_passwd函数由json文件变更为ini文件
  • Loading branch information
gnaiq committed Dec 18, 2021
1 parent 689a33e commit 08c9cf3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ssh_auto_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
import json
import re

import configparser
from loguru import logger
from netmiko import ConnectHandler, NetmikoAuthenticationException, NetmikoTimeoutException

Expand Down Expand Up @@ -65,11 +65,11 @@ def user_passwd() -> list:
:return: 账号密码
"""
try:
with open("user_pass.json", "r") as us_pa:
user_pass = json.load(us_pa)
user = user_pass["user"]
passwd = user_pass["password"]
return [user, passwd]
users_file = configparser.ConfigParser()
users_file.read("user_pass.ini")
user = users_file.get("users", "user")
passwd = users_file.get("users", "password")
return [user, passwd]
except Exception as f:
logger.error(f)

Expand Down

0 comments on commit 08c9cf3

Please sign in to comment.