From 05cb3947ec8ca906c14db0f6af9d3bd73cff4c02 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 15 May 2012 23:25:27 +0200 Subject: [PATCH] added my first python funciton --- df_check.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/df_check.py b/df_check.py index 85667fb..52183cf 100755 --- a/df_check.py +++ b/df_check.py @@ -4,13 +4,23 @@ import os -#reading needed files -file = open("/proc/partitions", "r") -parts = file.read() -file.close() -file = open("/proc/mounts", "r") -mounts = file.read() -file.close() +# reading a file +def fileparser(path): + file = open(path, "r") + result = file.read() + file.close() + return result + +#file = open("/proc/partitions", "r") +#parts = file.read() +#file.close() +#file = open("/proc/mounts", "r") +#mounts = file.read() +#file.close() + +# reading needed files +parts = fileparser("/proc/partitions") +mounts = fileparser("/proc/mounts") partitions = []