adding LFS detection in get_os_info
This commit is contained in:
parent
1278e57ee4
commit
08f7c21fe8
3 changed files with 37 additions and 31 deletions
|
@ -35,37 +35,39 @@ STATUS_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd', \
|
||||||
'invisible']
|
'invisible']
|
||||||
|
|
||||||
distro_info = {
|
distro_info = {
|
||||||
'Arch Linux': '/etc/arch-release',\
|
'Arch Linux': '/etc/arch-release',
|
||||||
'Aurox Linux': '/etc/aurox-release',\
|
'Aurox Linux': '/etc/aurox-release',
|
||||||
'Conectiva Linux': '/etc/conectiva-release',\
|
'Conectiva Linux': '/etc/conectiva-release',
|
||||||
'Debian GNU/Linux': '/etc/debian_release',\
|
'Debian GNU/Linux': '/etc/debian_release',
|
||||||
'Debian GNU/Linux': '/etc/debian_version',\
|
'Debian GNU/Linux': '/etc/debian_version',
|
||||||
'Fedora Linux': '/etc/fedora-release',\
|
'Fedora Linux': '/etc/fedora-release',
|
||||||
'Gentoo Linux': '/etc/gentoo-release',\
|
'Gentoo Linux': '/etc/gentoo-release',
|
||||||
'Mandrake Linux': '/etc/mandrake-release',\
|
'Linux from Scratch': '/etc/lfs-release',
|
||||||
'Slackware Linux': '/etc/slackware-release',\
|
'Mandrake Linux': '/etc/mandrake-release',
|
||||||
'Slackware Linux': '/etc/slackware-version',\
|
'Slackware Linux': '/etc/slackware-release',
|
||||||
'Solaris/Sparc': '/etc/release',\
|
'Slackware Linux': '/etc/slackware-version',
|
||||||
'Sun JDS': '/etc/sun-release',\
|
'Solaris/Sparc': '/etc/release',
|
||||||
'Novell SUSE Linux': '/etc/SuSE-release',\
|
'Sun JDS': '/etc/sun-release',
|
||||||
'PLD Linux': '/etc/pld-release',\
|
'Novell SUSE Linux': '/etc/SuSE-release',
|
||||||
'SUSE Linux': '/etc/SuSE-release',\
|
'PLD Linux': '/etc/pld-release',
|
||||||
'Yellow Dog Linux': '/etc/yellowdog-release',\
|
'SUSE Linux': '/etc/SuSE-release',
|
||||||
|
'Yellow Dog Linux': '/etc/yellowdog-release',
|
||||||
# many distros use the /etc/redhat-release for compatibility
|
# many distros use the /etc/redhat-release for compatibility
|
||||||
# so Redhat is the last
|
# so Redhat is the last
|
||||||
'Redhat Linux': '/etc/redhat-release'\
|
'Redhat Linux': '/etc/redhat-release'
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_os_info():
|
def get_os_info():
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
win_version = {(1, 4, 0): '95',\
|
win_version = {
|
||||||
(1, 4, 10): '98',\
|
(1, 4, 0): '95',
|
||||||
(1, 4, 90): 'ME',\
|
(1, 4, 10): '98',
|
||||||
(2, 4, 0): 'NT',\
|
(1, 4, 90): 'ME',
|
||||||
(2, 5, 0): '2000',\
|
(2, 4, 0): 'NT',
|
||||||
|
(2, 5, 0): '2000',
|
||||||
(2, 5, 1): 'XP'
|
(2, 5, 1): 'XP'
|
||||||
}[ os.sys.getwindowsversion()[3],\
|
}[ os.sys.getwindowsversion()[3],
|
||||||
os.sys.getwindowsversion()[0],\
|
os.sys.getwindowsversion()[0],
|
||||||
os.sys.getwindowsversion()[1] ]
|
os.sys.getwindowsversion()[1] ]
|
||||||
return 'Windows' + ' ' + win_version
|
return 'Windows' + ' ' + win_version
|
||||||
elif os.name =='posix':
|
elif os.name =='posix':
|
||||||
|
@ -81,19 +83,23 @@ def get_os_info():
|
||||||
child_stdin.close()
|
child_stdin.close()
|
||||||
return output
|
return output
|
||||||
# lsb_release executable not available, so parse files
|
# lsb_release executable not available, so parse files
|
||||||
for distro in distro_info:
|
for distro_name in distro_info:
|
||||||
path_to_file = distro_info[distro]
|
path_to_file = distro_info[distro_name]
|
||||||
if os.path.exists(path_to_file):
|
if os.path.exists(path_to_file):
|
||||||
fd = open(path_to_file)
|
fd = open(path_to_file)
|
||||||
text = fd.read().strip()
|
text = fd.read().strip()
|
||||||
fd.close()
|
fd.close()
|
||||||
if path_to_file.endswith('version'):
|
if path_to_file.endswith('version'):
|
||||||
text = distro + ' ' + text
|
text = distro_name + ' ' + text
|
||||||
|
elif path_to_file.endswith('aurox-release'): # file doesn't have version
|
||||||
|
text = distro_name
|
||||||
|
elif path_to_file.endswith('lfs-release'): # file just has version
|
||||||
|
text = distro_name + ' ' + text
|
||||||
return text
|
return text
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
class connection:
|
class Connection:
|
||||||
"""connection"""
|
"""Connection class"""
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
# dict of function to be calledfor each event
|
# dict of function to be calledfor each event
|
||||||
self.handlers = {'ROSTER': [], 'WARNING': [], 'ERROR': [], 'STATUS': [], \
|
self.handlers = {'ROSTER': [], 'WARNING': [], 'ERROR': [], 'STATUS': [], \
|
||||||
|
|
|
@ -125,7 +125,7 @@ class OptionsParser:
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if not self.tab.has_key(account):
|
if not self.tab.has_key(account):
|
||||||
continue
|
continue
|
||||||
gajim.connections[account] = connection.connection(account)
|
gajim.connections[account] = connection.Connection(account)
|
||||||
gajim.config.add_per('accounts', account)
|
gajim.config.add_per('accounts', account)
|
||||||
for key in self.tab[account]:
|
for key in self.tab[account]:
|
||||||
gajim.config.set_per('accounts', account, key, \
|
gajim.config.set_per('accounts', account, key, \
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ class Account_modification_window:
|
||||||
dialogs.Error_dialog(_('An account already has this name'))
|
dialogs.Error_dialog(_('An account already has this name'))
|
||||||
return
|
return
|
||||||
gajim.config.add_per('accounts', name)
|
gajim.config.add_per('accounts', name)
|
||||||
gajim.connections[name] = connection.connection(name)
|
gajim.connections[name] = connection.Connection(name)
|
||||||
self.plugin.register_handlers(gajim.connections[name])
|
self.plugin.register_handlers(gajim.connections[name])
|
||||||
#if we neeed to register a new account
|
#if we neeed to register a new account
|
||||||
if new_account_checkbutton.get_active():
|
if new_account_checkbutton.get_active():
|
||||||
|
|
Loading…
Add table
Reference in a new issue