first commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[quen]
|
||||
name =
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[hardware]
|
||||
gpu = GPU1,GPU2,GPU3,GPU4
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import configparser
|
||||
import time
|
||||
|
||||
|
||||
def config_read():
|
||||
# 读取
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
mesg = config['video_path']['rtmp']
|
||||
data = mesg.split(',')
|
||||
def test1_1():
|
||||
# 读取
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
num1 = config['que']['num']
|
||||
name = config['que']['name']
|
||||
# test_n = int(num)
|
||||
print(type(int(num1)))
|
||||
num2 = int(num1)
|
||||
if num2 == 0:
|
||||
print("ok")
|
||||
config.set('que', 'num1', "1")
|
||||
config.write(open("config.ini", "w"))
|
||||
time.sleep(10)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
num = config['que']['num']
|
||||
name = config['que']['name']
|
||||
print(num)
|
||||
data = name.split(',')
|
||||
print(len(data))
|
||||
|
||||
if __name__ == "__main__":
|
||||
# config_read()
|
||||
while 1:
|
||||
test1_1()
|
||||
time.sleep(1000)
|
||||
@@ -0,0 +1,71 @@
|
||||
import configparser
|
||||
import time
|
||||
|
||||
# 创建配置对象
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
# 读取配置文件
|
||||
config.read('config.ini')
|
||||
|
||||
def read_config():
|
||||
name = config['quen']['name']
|
||||
print(name)
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
return
|
||||
data = name.split(',')
|
||||
# print(data[0])
|
||||
return data
|
||||
|
||||
def write_config(add_name):
|
||||
name = config['quen']['name']
|
||||
if len(name) == 0:
|
||||
print("ok")
|
||||
data = []
|
||||
data.append(add_name)
|
||||
new_name = ''.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
return
|
||||
|
||||
data = name.split(',')
|
||||
if add_name in data:
|
||||
data.remove(add_name)
|
||||
data.append(add_name)
|
||||
new_name = ','.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
def del_name():
|
||||
name = config['quen']['name']
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
return
|
||||
data = name.split(',')
|
||||
print(len(data))
|
||||
data.pop(0)
|
||||
new_name = ','.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
||||
def read_gpu_config():
|
||||
gpu = config['quen']['gpu']
|
||||
# if len(name) == 0:
|
||||
# print("list is empty!")
|
||||
# return
|
||||
# data = name.split(',')
|
||||
# print(data[0])
|
||||
return gpu
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
while 1:
|
||||
write_config("guoan")
|
||||
time.sleep(1000)
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import configparser
|
||||
|
||||
# 创建配置对象
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
# 读取配置文件
|
||||
config.read('config.ini')
|
||||
|
||||
|
||||
def read_config():
|
||||
name = config['quen']['name']
|
||||
print(name)
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
return
|
||||
data = name.split(',')
|
||||
print(data)
|
||||
|
||||
return data
|
||||
|
||||
def write_config(add_name):
|
||||
name = config['quen']['name']
|
||||
if len(name) == 0:
|
||||
print("ok")
|
||||
data = []
|
||||
data.append(add_name)
|
||||
new_name = ''.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
configfile.close()
|
||||
return
|
||||
|
||||
data = name.split(',')
|
||||
if add_name in data:
|
||||
data.remove(add_name)
|
||||
data.append(add_name)
|
||||
new_name = ','.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
def del_name():
|
||||
name = config['quen']['name']
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
return
|
||||
data = name.split(',')
|
||||
print(len(data))
|
||||
data.pop(0)
|
||||
new_name = ','.join(data)
|
||||
config.set('quen', 'name', new_name)
|
||||
# 写入配置文件
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
||||
def read_gpu_config():
|
||||
gpu = config['quen']['gpu']
|
||||
# if len(name) == 0:
|
||||
# print("list is empty!")
|
||||
# return
|
||||
# data = name.split(',')
|
||||
# print(data[0])
|
||||
return gpu
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
del_name()
|
||||
read_config()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import configparser
|
||||
import time
|
||||
|
||||
|
||||
def config_read():
|
||||
# 读取
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
mesg = config['video_path']['rtmp']
|
||||
data = mesg.split(',')
|
||||
def test1_1():
|
||||
# 读取
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
num1 = config['que']['num']
|
||||
name = config['que']['name']
|
||||
# test_n = int(num)
|
||||
print(type(int(num1)))
|
||||
num2 = int(num1)
|
||||
if num2 == 0:
|
||||
print("ok")
|
||||
config.set('que', 'num1', "1")
|
||||
config.write(open("config.ini", "w"))
|
||||
time.sleep(10)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
num = config['que']['num']
|
||||
name = config['que']['name']
|
||||
print(num)
|
||||
data = name.split(',')
|
||||
print(len(data))
|
||||
|
||||
if __name__ == "__main__":
|
||||
# config_read()
|
||||
config_read()
|
||||
@@ -0,0 +1,62 @@
|
||||
import configparser
|
||||
# 创建配置对象
|
||||
config = configparser.ConfigParser()
|
||||
# 读取配置文件
|
||||
config.read('config_gpu.ini')
|
||||
|
||||
def read_config_gpu():
|
||||
name = config['hardware']['gpu']
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
data = []
|
||||
return data
|
||||
data = name.split(',')
|
||||
return data
|
||||
|
||||
def write_config_gpu(add_name):
|
||||
name = config['hardware']['gpu']
|
||||
if len(name) == 0:
|
||||
print("ok")
|
||||
data = []
|
||||
data.append(add_name)
|
||||
new_name = ''.join(data)
|
||||
config.set('hardware', 'gpu', new_name)
|
||||
# 写入配置文件
|
||||
with open('config_gpu.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
return
|
||||
|
||||
data = name.split(',')
|
||||
if add_name in data:
|
||||
data.remove(add_name)
|
||||
data.append(add_name)
|
||||
new_name = ','.join(data)
|
||||
config.set('hardware', 'gpu', new_name)
|
||||
# 写入配置文件
|
||||
with open('config_gpu.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
def del_name_gpu():
|
||||
name = config['hardware']['gpu']
|
||||
if len(name) == 0:
|
||||
print("list is empty!")
|
||||
return
|
||||
data = name.split(',')
|
||||
print(len(data))
|
||||
data.pop(0)
|
||||
new_name = ','.join(data)
|
||||
config.set('hardware', 'gpu', new_name)
|
||||
# 写入配置文件
|
||||
with open('config_gpu.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
gpus = read_config_gpu()
|
||||
# 检查每个 GPU 是否都在列表中
|
||||
for gpu_id in range(1, 5): # 假设我们只有到 GPU4
|
||||
gpu_str = f"GPU{gpu_id}"
|
||||
if gpu_str not in gpus:
|
||||
print(f"{gpu_str} is go")
|
||||
write_config_gpu(f"GPU{gpu_id}")
|
||||
break
|
||||
else:
|
||||
print(f"{gpu_str} is available")
|
||||
Reference in New Issue
Block a user