I observed that you have written code like class assignments no meaningful names to variables, functions , no sufficient comments in the code
have a look at the small piece of code in file_loc.py file:
import subprocess
import re
import operator
import sys
ljust_val = 40 -------- > what is ljust_val ?
kd = 3 -------- > what does kd mean, same apples for all the below code ?
PostgresPath = sys.argv[1]
def get_disk_list():
d = {}
f = open("os.conf","r")
file = f.readlines()
f.close()
flag = 0
disk_list = []
for line in file:
if "Disks and partitions" in line:
flag = 1
elif flag == 1:
flag =2
elif flag == 2 and "----" not in line and line != "\n":
if "File System information" in line:
break
if "Disk" in line:
disk_list.append(line.split(' ')[0])
return disk_list
Improvement points:
Python is very powerful dynamic programming language when you write a code in it, it should have meaning
while naming functions and variables use following rule:
lowercase with words separated by underscores as necessary to improve readability.
I observed that you have written code like class assignments no meaningful names to variables, functions , no sufficient comments in the code
have a look at the small piece of code in file_loc.py file:
import subprocess import re import operator import sys ljust_val = 40 -------- > what is ljust_val ? kd = 3 -------- > what does kd mean, same apples for all the below code ? PostgresPath = sys.argv[1] def get_disk_list(): d = {} f = open("os.conf","r") file = f.readlines() f.close() flag = 0 disk_list = [] for line in file: if "Disks and partitions" in line: flag = 1 elif flag == 1: flag =2 elif flag == 2 and "----" not in line and line != "\n": if "File System information" in line: break if "Disk" in line: disk_list.append(line.split(' ')[0]) return disk_list
Improvement points: Python is very powerful dynamic programming language when you write a code in it, it should have meaning
while naming functions and variables use following rule: lowercase with words separated by underscores as necessary to improve readability.
Have a look at this link from pythons official site: http://legacy.python.org/dev/peps/pep-0008/