Last active
February 9, 2016 17:28
-
-
Save tcarrio/c2ee34b45d0a1e1734f4 to your computer and use it in GitHub Desktop.
Revisions
-
tcarrio revised this gist
Feb 9, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,10 +20,10 @@ def release_dict(file_loc,name): def get_delimiter(): if("Red Hat" in name): return "=" elif("Ubuntu" in name): return " " elif("Elementary" in name): return " " else return ":" -
tcarrio revised this gist
Feb 9, 2016 . 1 changed file with 26 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,29 @@ filenames = ['/etc/os-release'] # add any other distro locations for os-release def read_release(): for filename in filenames: if os.path.isfile(filename): with open('/etc/os-release', 'r') as relfile: for line in relfile: if('NAME ' in line): release_dict(line.split(' ')[1]) def release_dict(file_loc,name): ddict = {} delim = get_delimiter() with open(filename,'r') as relfile: for line in relfile: ll = line.strip('\n').replace('\"', '').split(delim) if len(ll) > 1: ddict[ll[0].lower()] = ll[1] return ddict def get_delimiter(): if("Red Hat" in name): delim = "=" elif("Ubuntu" in name): delim = " " elif("Elementary" in name): delim = " " else delim = ":" -
jadams created this gist
Feb 9, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ if os.path.isfile('/etc/os-release'): with open('/etc/os-release', 'r') as relfile: ddict = {} for line in relfile: ll = line.strip('\n').replace('\"', '').split('=') if len(ll) > 1: ddict[ll[0].lower()] = ll[1] return ddict