Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
New rewriting of the Salix Live Installer using the salix_livetools_l…
Browse files Browse the repository at this point in the history
…ibrary.

For now, only the first tab, the timezone is done.
  • Loading branch information
Cyrille Pontvieux committed Feb 9, 2013
1 parent 40adc78 commit 4885d32
Show file tree
Hide file tree
Showing 20 changed files with 967 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
locale
119 changes: 60 additions & 59 deletions src/salix-live-installer.glade

Large diffs are not rendered by default.

861 changes: 861 additions & 0 deletions src/salix-live-installer.py

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- listTZCities
- getDefaultTimeZone
- setDefaultTimeZone
- isNTPEnabledByDefault
- setNTPDefault
"""
import os
import glob
Expand Down Expand Up @@ -81,6 +83,31 @@ def setDefaultTimeZone(timezone, mountPoint = None):
else:
raise Exception('This timezone ({0}) is incorrect.'.format(timezone))

def isNTPEnabledByDefault(mountPoint = None):
"""
Returns True if the NTP service is enabled by default.
For this, the execute bit of /etc/rc.d/rc.ntpd is checked.
"""
if mountPoint and not os.path.isdir(mountPoint):
raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint))
if mountPoint == None:
mountPoint = ''
return os.access('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), os.X_OK)

def setNTPDefault(enabled, mountPoint = None):
"""
Fix the configuration for default NTP service activated on boot or not.
"""
checkRoot()
if mountPoint and not os.path.isdir(mountPoint):
raise IOError("'{0}' does not exist or is not a directory.".format(mountPoint))
if mountPoint == None:
mountPoint = '/'
if enabled:
os.chmod('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), 0755)
else:
os.chmod('{0}/etc/rc.d/rc.ntpd'.format(mountPoint), 0644)

# Unit test
if __name__ == '__main__':
from assertPlus import *
Expand All @@ -107,3 +134,10 @@ def setDefaultTimeZone(timezone, mountPoint = None):
assertEquals(2, len(tz.split('/')))
assertEquals('Etc/Zulu', tz)
setDefaultTimeZone(deftz)
ntp = isNTPEnabledByDefault()
assertTrue(type(ntp) == bool)
setNTPDefault(True)
assertTrue(isNTPEnabledByDefault())
setNTPDefault(False)
assertFalse(isNTPEnabledByDefault())
setNTPDefault(ntp)
File renamed without changes.
11 changes: 11 additions & 0 deletions src/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
cd $(dirname "$0")
for p in ../po/*.po; do
d=$(basename $p .po)
if [ ! -d locale/$d ]; then
mkdir -p locale/$d/LC_MESSAGES
echo "$p..."
msgfmt $p -o locale/$d/LC_MESSAGES/salix-live-installer.mo
fi
done
./salix-live-installer.py --test

0 comments on commit 4885d32

Please sign in to comment.