Открыть боковую панель
cgfrosty
school-ringer
Коммиты
411b4678
Коммит
411b4678
создал
Дек 25, 2023
по автору
Леляев Петр Алексеевич
Просмотр файлов
Bug fix: pkexec для настройки конфигов вызывается один раз
владелец
47a947a4
Изменения
3
Скрыть пробелы
Построчно
Рядом
school-ringer.conf
0 → 100644
Просмотр файла @
411b4678
[
Main
]
is_breaks_music_on
=
false
music_folder
=/
home
music_shuffle
=
false
school_ringer_modules/settings.py
Просмотр файла @
411b4678
...
...
@@ -197,15 +197,14 @@ class CallsSettings(QWidget):
Включение и выключение фоновой службы, запускающей звонки
"""
if
self
.
btn_switch_service
.
text
()
==
'Выключить сервис'
:
run_command
(
'systemctl stop school-ringer.service'
)
run_command
(
'systemctl disable school-ringer.service'
)
run_command
(
'pkexec sh -c "systemctl stop school-ringer.service ; disable school-ringer.service"'
)
self
.
btn_switch_service
.
setText
(
'Включить сервис'
)
logging
.
info
(
f
'Сервис выключен'
)
# self.real_next_call_label.setText('Сервис выключен')
else
:
self
.
btn_switch_service
.
setText
(
'Выключить сервис'
)
run_command
(
'systemctl restart school-ringer.service'
)
run_command
(
'systemctl enable school-ringer.service'
)
run_command
(
'
pkexec sh -c "
systemctl restart school-ringer.service
;
'
'systemctl enable school-ringer.service
"
'
)
logging
.
info
(
f
'Сервис включён'
)
def
update_active_schedules
(
self
,
string_of_schedules
)
->
None
:
...
...
@@ -226,10 +225,8 @@ class CallsSettings(QWidget):
self
.
real_service_status_label
.
setText
(
text_status
)
if
message
==
'active'
:
self
.
btn_switch_service
.
setText
(
'Выключить сервис'
)
# logging.info('Статус сервиса обновлён на Работает')
else
:
self
.
btn_switch_service
.
setText
(
'Включить сервис'
)
# logging.info('Статус сервиса обновлён на Остановлен')
def
set_next_lesson_label
(
self
,
next_call_text
):
if
self
.
real_next_call_label
.
text
()
!=
next_call_text
:
...
...
@@ -266,16 +263,19 @@ class CallsSettings(QWidget):
self
.
music_playing_thread
.
start
()
self
.
play_music_on_breaks_btn
.
setText
(
'Не играть музыку'
)
self
.
is_breaks_music_on
=
True
run_command
(
f
'py-ini-config set
{
config_path
}
/school-ringer.conf Main is_breaks_music_on true'
)
run_command
(
f
'py-ini-config set
{
config_path
}
/school-ringer.conf Main music_folder "
{
dlg
.
music_folder
}
"'
)
run_command
(
f
'py-ini-config set
{
config_path
}
/school-ringer.conf Main music_shuffle '
f
'
{
dlg
.
shuffle_checkbox
.
isChecked
()
}
'
)
run_command
(
f
'pkexec sh -c "py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main is_breaks_music_on true && '
f
'py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main music_folder "
{
dlg
.
music_folder
}
" && '
f
'py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main music_shuffle
{
dlg
.
shuffle_checkbox
.
isChecked
()
}
"'
)
else
:
self
.
music_playing_thread
.
terminate
()
subprocess
.
run
(
'pkill play'
,
shell
=
True
)
self
.
play_music_on_breaks_btn
.
setText
(
'Играть музыку на переменах'
)
self
.
is_breaks_music_on
=
False
run_command
(
f
'py-ini-config set
{
config_path
}
/school-ringer.conf Main is_breaks_music_on false'
)
run_command
(
f
'pkexec sh -c '
f
'"py-ini-config set
{
config_path
}
/school-ringer.conf Main is_breaks_music_on false"'
)
def
download_instructions
(
self
):
if
not
authority_check
(
"download_instructions"
):
...
...
@@ -357,8 +357,7 @@ class CallsSettings(QWidget):
self
.
music_playing_thread
=
MusicPlayer
()
self
.
music_playing_thread
.
setTerminationEnabled
(
True
)
self
.
is_breaks_music_on
=
False
run_command
(
f
'touch
{
config_path
}
/school-ringer.conf'
)
run_command
(
f
'py-ini-config set
{
config_path
}
/school-ringer.conf Main is_breaks_music_on false'
)
# TODO добавить в спек копирование конфига
grid
.
setColumnMinimumWidth
(
0
,
50
)
grid
.
setColumnMinimumWidth
(
1
,
200
)
...
...
school_ringer_modules/sound.py
Просмотр файла @
411b4678
...
...
@@ -43,14 +43,16 @@ def ring_the_call(filename: str, play_music=False) -> None:
sound_to_play
=
f
'
{
sound_path
}
/
{
filename
}
'
if
play_music
and
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main '
f
'is_breaks_music_on'
).
strip
()
==
'true'
:
logging
.
info
(
'
play music: true
'
)
logging
.
info
(
'
После этого звонка с урока будет играть музыка
'
)
sound_to_play
+=
f
'
{
get_music_for_breaks
()
}
'
print
(
'***'
,
sound_to_play
)
logging
.
info
(
f
'Will be played:
{
sound_to_play
}
'
)
subprocess
.
run
(
f
'play
{
sound_to_play
}
'
,
shell
=
True
)
except
Exception
as
e
:
print
(
'Программа запущена без прав суперпользователя'
,
e
)
logging
.
info
(
f
'Вызван звонок'
)
print
(
f
'При попытке воспроизведения возникла ошибка:
{
e
}
'
)
logging
.
info
(
f
'При попытке воспроизведения возникла ошибка:
{
e
}
'
)
else
:
logging
.
info
(
f
'Вызван звонок'
)
else
:
logging
.
info
(
'Каникулы. Звонок не воспроизведён.'
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать