Здравствуйте! У меня не выводится в файл информация о процессоре из файла /proc/cpuinfo. Нужно только вывести информацию с индексами 0,1,3,4,8. Это информауция о модели, о производители и т.д. Эта часть кода работает, когда я вывожу на экран. Но в файл не получается. Он пустой. Помогите,пожалуйста!
try:
myFile = open("/proc/cpuinfo", "r")
cpuInfo = myFile.read().splitlines()
except:
print("Cannot read content")
finally:
myFile.close()
print("PROCESSORS:\n")
try:
with open ("CPU_INFO.txt", "a") as writeFile:
#writeFile = open("CPU_INFO.txt", "w")
index = 0
for lines in cpuInfo:
if index == 0 or index == 1 or index == 3 or index == 4 or index == 8:
print(lines)
index +=1
writeFile.write(lines)
writeFile.flush()
except:
print("Cannot write to a file")
finally:
writeFile.close()
try:
myFile = open("/proc/cpuinfo", "r")
cpuInfo = myFile.read().splitlines()
except:
print("Cannot read content")
finally:
myFile.close()
print("PROCESSORS:\n")
try:
with open ("CPU_INFO.txt", "a") as writeFile:
#writeFile = open("CPU_INFO.txt", "w")
index = 0
for lines in cpuInfo:
if index == 0 or index == 1 or index == 3 or index == 4 or index == 8:
print(lines)
index +=1
writeFile.write(lines)
writeFile.flush()
except:
print("Cannot write to a file")
finally:
writeFile.close()