Skip to content

Commit c2db658

Browse files
committed
Added parental settings to kano-settings-cli
1 parent 2fec673 commit c2db658

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

bin/kano-settings-cli

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# kano-settings-cli
44
#
5-
# Copyright (C) 2014-2017 Kano Computing Ltd.
5+
# Copyright (C) 2014-2019 Kano Computing Ltd.
66
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
77

88
"""
@@ -18,6 +18,7 @@ Usage:
1818
kano-settings-cli [options] set gfx_driver (enable | disable)
1919
kano-settings-cli [options] get overscan
2020
kano-settings-cli [options] set overscan <top> <left> <bottom> <right>
21+
kano-settings-cli [options] set parental --level=<level> <password>
2122
kano-settings-cli [options] dump-edid
2223
kano-settings-cli -h | --help
2324
@@ -40,6 +41,15 @@ Values:
4041
verbose Verbose mode
4142
enable enable gfx_driver driver
4243
disable disable gfx_driver driver
44+
level The level of Parental Controls (-1: disabled, 0: low,
45+
1: medium, 2: high, 3: ultimate)
46+
47+
Examples:
48+
kano-settings-cli set parental --level=3 "kano"
49+
Sets parental controls for the user executing the command to Ultimate
50+
with "kano" as the parental password to change the setting.
51+
kano-settings-cli set parental --level=-1 "kano"
52+
Disables parental controls for the user executing the command.
4353
"""
4454

4555

@@ -62,6 +72,8 @@ kano_i18n.init.install('kano-settings', LOCALE_PATH)
6272
from kano_settings.system.keyboard_config import set_saved_keyboard, set_keyboard
6373
from kano_settings.system.display import get_gfx_driver, set_gfx_driver, \
6474
read_overscan_values, write_overscan_values, dump_raw_edid
75+
from kano_settings.system.advanced import set_parental_enabled, \
76+
set_parental_level
6577
from kano_settings.config_file import get_setting
6678

6779
from kano_settings.return_codes import RC_SUCCESS, RC_UNEXPECTED_ERROR, \
@@ -94,7 +106,7 @@ def main(args):
94106
setting = 'default'
95107
hdmi_enabled = False
96108

97-
print_v(_("setting audio to {}").format(_(setting)))
109+
print_v(_("setting audio to {}").format(_(setting))) # noqa
98110

99111
# only import on use, because this is slow
100112
from kano_settings.system.audio import set_to_HDMI
@@ -103,7 +115,7 @@ def main(args):
103115
elif args['keyboard']:
104116
if args['--load']:
105117
set_saved_keyboard()
106-
print_v(_("Setting keyboard to value loaded from settings"))
118+
print_v(_("Setting keyboard to value loaded from settings")) # noqa
107119
elif args['--layout']:
108120
layout_code = args['<layout_code>']
109121
layout_code_list = layout_code.split(' ')
@@ -119,7 +131,7 @@ def main(args):
119131
variant = 'generic'
120132

121133
set_keyboard(locale, variant, save=True)
122-
print_v(_("Setting keyboard to {} {}").format(_(locale), _(variant)))
134+
print_v(_("Setting keyboard to {} {}").format(_(locale), _(variant))) # noqa
123135

124136
elif args['gfx_driver']:
125137
if args['enable']:
@@ -136,17 +148,30 @@ def main(args):
136148
}
137149
write_overscan_values(overscan_values)
138150

151+
elif args['parental']:
152+
if int(args['--level']) == -1:
153+
print_v(
154+
_("Disabling parental controls: {}").format( # noqa
155+
set_parental_enabled(False, args['<password>']))
156+
)
157+
else:
158+
print_v(
159+
_("Enabling parental controls: {}").format( # noqa
160+
set_parental_enabled(True, args['<password>']))
161+
)
162+
set_parental_level(int(args['--level']))
163+
139164
elif args['get']:
140165
if args['audio']:
141166
print_v(
142-
_("Audio settings:\n\n"
167+
_("Audio settings:\n\n" # noqa
143168
"Audio mode: {}").format(
144169
get_setting('Audio')
145170
)
146171
)
147172
elif args['network']:
148173
print_v(
149-
_("Network settings:\n\n"
174+
_("Network settings:\n\n" # noqa
150175
"WiFi: {}, WiFi Connection Attempted: {},\n"
151176
"Proxy port : {}, Proxy IP: {}, "
152177
"Proxy username : {}, Proxy type : {}").format(
@@ -160,7 +185,7 @@ def main(args):
160185
)
161186
elif args['keyboard']:
162187
print_v(
163-
_("Keyboard settings:\n\n"
188+
_("Keyboard settings:\n\n" # noqa
164189
"Continent: {}, Country: {}, Variant: {}\n"
165190
"(indicies - Continent: {}, Country: {}, Variant: {})").format(
166191
get_setting('Keyboard-continent-human'),
@@ -183,15 +208,15 @@ def main(args):
183208
edid_path = dump_raw_edid()
184209

185210
if not edid_path:
186-
print_v(_('Could not perform operation.'))
211+
print_v(_('Could not perform operation.')) # noqa
187212
return RC_UNEXPECTED_ERROR
188213
else:
189-
print_v(_('Generated {}').format(edid_path))
214+
print_v(_('Generated {}').format(edid_path)) # noqa
190215

191216

192217
if __name__ == "__main__":
193218
if os.getuid() != 0:
194-
print _('Program must be run as root.')
219+
print _('Program must be run as root.') # noqa
195220
sys.exit(RC_WRONG_PERMISSIONS)
196221

197222
try:

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
kano-settings (4.3.2-0) unstable; urgency=low
2+
3+
* Added parental settings to kano-settings-cli
4+
5+
-- Team Kano <[email protected]> Fri, 30 Aug 2019 13:15:00 +0100
6+
17
kano-settings (4.2.1-0) unstable; urgency=low
28

39
* Fixed race condition at boot preventing Wi-Fi from reconnecting to existing network

kano_settings/set_advanced.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
2-
# set_advance.py
2+
# set_advanced.py
33
#
4-
# Copyright (C) 2014-2018 Kano Computing Ltd.
4+
# Copyright (C) 2014-2019 Kano Computing Ltd.
55
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
66
#
77

0 commit comments

Comments
 (0)