update
This commit is contained in:
1 parent
83db094f02
commit
a4885963d8
3 files changed
+30
-4
No files matched your search
+26
-1
@@ -32,6 +32,27 @@ def network_error_light():
|
||||
break
|
||||
close_app()
|
||||
|
||||
def edit_line_in_file(file_path, search_string, replacement_string):
|
||||
try:
|
||||
# 读取文件内容
|
||||
with open(file_path, 'r') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
# 替换包含特定内容的行
|
||||
with open(file_path, 'r+') as file:
|
||||
file.seek(0) # 移动到文件开头
|
||||
file.truncate() # 清空文件内容
|
||||
for line in lines:
|
||||
if search_string in line:
|
||||
file.write(replacement_string + '\n')
|
||||
else:
|
||||
file.write(line)
|
||||
|
||||
print("The line has been edited.")
|
||||
except FileNotFoundError:
|
||||
print(f"The file {file_path} does not exist.")
|
||||
except IOError as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -93,6 +114,11 @@ def check_wifi_connection():
|
||||
orangepi.set_led_off('blue')
|
||||
return True, wifi_ssid
|
||||
elif len(columns) >= 4 and columns[0] == "wlan0" and columns[2] == "unmanaged":
|
||||
# 使用函数
|
||||
file_path = '/etc/NetworkManager/NetworkManager.conf'
|
||||
search_string = 'unmanaged-devices=interface-name:'
|
||||
replacement_string = '' # 如果不需要替换为其他内容,可以设置为空字符串
|
||||
edit_line_in_file(file_path, search_string, replacement_string)
|
||||
'''
|
||||
# 从 /etc/NetworkManager/NetworkManager.conf 文件中移除或注释掉 [keyfile] 部分的 unmanaged-devices 条目,因为它可能阻止了 NetworkManager 管理 wlan0 接口。编辑文件如下:
|
||||
```
|
||||
@@ -101,7 +127,6 @@ def check_wifi_connection():
|
||||
```
|
||||
sudo systemctl restart NetworkManager
|
||||
'''
|
||||
print()
|
||||
network_error_light()
|
||||
return False, None
|
||||
|
||||
|
||||
Reference in new issue
Block a user