def NTP_set(self):
#if (config.plugins.SetClock.NTPName01.value == "" and config.plugins.SetClock.NTPName02.value == "" and config.plugins.SetClock.NTPName03.value == "" and config.plugins.SetClock.NTPName04.value == "" and config.plugins.SetClock.NTPName05.value == "" and config.plugins.SetClock.NTPName06.value == "" and config.plugins.SetClock.NTPName07.value == "" and config.plugins.SetClock.NTPName08.value == "" and config.plugins.SetClock.NTPName09.value == ""):
#self.session.open(MessageBox, _("no timeserver configured!"), MessageBox.TYPE_INFO)
#else:
log_file = open('/usr/lib/enigma2/python/Plugins/Extensions/SetClock/log.txt', 'a')
def execute_cmd(cmd):
log_file.write("Начинаю выполнять команду: %s" % cmd)
fo = popen(cmd)
output = fo.read()
exit_code = fo.close()
log_file.write("Результат выполнения команды: %s; вывод: `%s`; код-завершения: %i" % (cmd, output, 0 if exit_code is None else exit_code))
return output
if os.path.exists(os.path.join(plugin_path, "ntpdate")):
log_file.write("Программа существует по указанному пути")
#Lite_OutPut_In_Console_1_stroke
#cmd = '/usr/bin/ntpdate -b -t %s %s && echo "\n"' % (config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName.value)
#cmd = '%s%s %s %s && echo "\n"' % (plugin_path, "/ntpdate -b -t ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value)
#cmd = '%s%s %s %s %s %s %s %s %s %s %s %s && echo "\n"' % (plugin_path, "/ntpdate -b -t ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value, config.plugins.SetClock.NTPName02.value, config.plugins.SetClock.NTPName03.value, config.plugins.SetClock.NTPName04.value, config.plugins.SetClock.NTPName05.value, config.plugins.SetClock.NTPName06.value, config.plugins.SetClock.NTPName07.value, config.plugins.SetClock.NTPName08.value, config.plugins.SetClock.NTPName09.value)
#Extended_OutPut_In_Console_2_stroke
#cmd = '/usr/bin/ntpdate -v -u %s %s && echo "\n"' % (config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName.value)
cmd = '%s%s %s %s && echo "\n"' % (plugin_path, "/ntpdate -v -u ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value)
#cmd = '%s%s %s %s %s %s %s %s %s %s %s %s && echo "\n"' % (plugin_path, "/ntpdate -v -u ", config.plugins.SetClock.timeout.value, config.plugins.SetClock.NTPName01.value, config.plugins.SetClock.NTPName02.value, config.plugins.SetClock.NTPName03.value, config.plugins.SetClock.NTPName04.value, config.plugins.SetClock.NTPName05.value, config.plugins.SetClock.NTPName06.value, config.plugins.SetClock.NTPName07.value, config.plugins.SetClock.NTPName08.value, config.plugins.SetClock.NTPName09.value)
pipe = popen(cmd)
res = pipe.read()
exit_code = pipe.close()
if exit_code == 256:
self.session.open(MessageBox, _("ntpdate problem: Internet connection ok? Time server ok?"), MessageBox.TYPE_INFO)
elif res == "":
cmd = "ls -l %s%s" % (plugin_path, "/ntpdate")
res = execute_cmd(cmd)
if res[3]!="x":
cmd = "chmod 755 %s%s" % (plugin_path, "/ntpdate")
res = execute_cmd(cmd)
self.session.open(MessageBox, _("ntpdate problem: attributes for 'ntpdate' have not been correct! Fixed now! Try again!\n%s" % res), MessageBox.TYPE_INFO)
else:
self.session.open(MessageBox, _("ntpdate problem: Internet connection ok? Time server ok?"), MessageBox.TYPE_INFO)
else:
self.session.open(MyConsole, _("Системное время с NTP ..."), [cmd])
self.close()
self.close()
else:
log_file.write("Программа не существует по указанному пути")
self.session.open(MessageBox, _("'ntpdate' не установлен !"), MessageBox.TYPE_ERROR)
log_file.close()