Открыть боковую панель
cgfrosty
school-ringer
Коммиты
47a947a4
Коммит
47a947a4
создал
Дек 25, 2023
по автору
Леляев Петр Алексеевич
Просмотр файлов
Bug fix: авторизация запрашивается только при запуске программы и необходимости
владелец
72479c7e
Изменения
3
Скрыть пробелы
Построчно
Рядом
app.py
Просмотр файла @
47a947a4
...
...
@@ -2,14 +2,13 @@
import
logging
import
os
import
subprocess
import
sys
from
PyQt5.QtGui
import
QIcon
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
,
QMessageBox
from
school_ringer_modules.config
import
config_path
,
icon_file
,
debug
from
school_ringer_modules.system
import
user
,
run_command
,
authority_check
from
school_ringer_modules.config
import
config_path
,
icon_file
from
school_ringer_modules.system
import
run_command
,
authority_check
,
get_current_user_on_x
# Директория приложения
basedir
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -18,19 +17,20 @@ if __name__ == '__main__':
app
=
QApplication
(
sys
.
argv
)
app
.
setWindowIcon
(
QIcon
(
os
.
path
.
join
(
basedir
,
icon_file
)))
try
:
# if not debug:
# if user != 'root':
# err_window = QWidget()
# error_box = QMessageBox.critical(err_window, "Ошибка", f'Попытка запуска без root')
# sys.exit(0)
from
school_ringer_modules.settings
import
CallsSettings
# Создание папки с конфигом, если её нет
run_command
(
f
'mkdir -p
{
config_path
}
'
)
if
not
run_command
(
f
'file
{
config_path
}
'
).
strip
().
endswith
(
': directory'
):
run_command
(
f
'pkexec mkdir -p
{
config_path
}
'
)
# Настройка логирования
for
handler
in
logging
.
root
.
handlers
[:]:
logging
.
root
.
removeHandler
(
handler
)
current_user_on_x
=
get_current_user_on_x
()
if
current_user_on_x
:
filename
=
f
"/home/
{
current_user_on_x
}
/.config/school-ringer/log.txt"
else
:
filename
=
f
"/tmp/school-ringer/log.txt"
logging
.
basicConfig
(
filename
=
f
"/home/user/.config/school-ringer/log.txt"
,
format
=
u
'%(asctime)s %(filename)s [LINE:%(lineno)d] [%(funcName)s()] #%(levelname)-15s %(message)s'
,
...
...
school_ringer_modules/config.py
Просмотр файла @
47a947a4
...
...
@@ -2,8 +2,8 @@ from school_ringer_modules.system import get_current_user_on_x
debug
=
False
config_path
=
f
'/
etc/ring_daemon
/config'
if
not
debug
else
'./debug_config'
sound_path
=
f
'/
etc/ring-daemon
/sound'
if
not
debug
else
'./debug_config'
config_path
=
f
'/
usr/share/school-ringer
/config'
if
not
debug
else
'./debug_config'
sound_path
=
f
'/
usr/share/school-ringer
/sound'
if
not
debug
else
'./debug_config'
icon_file
=
'school-ringer.svg'
version
=
'1.05'
school_ringer_modules/sound.py
Просмотр файла @
47a947a4
...
...
@@ -20,7 +20,8 @@ def default_sound() -> str:
try
:
sound_files
=
os
.
listdir
(
f
'
{
sound_path
}
'
)
except
Exception
:
run_command
(
f
'mkdir -p
{
sound_path
}
'
)
if
not
run_command
(
f
'file
{
config_path
}
'
).
strip
().
endswith
(
': directory'
):
run_command
(
f
'pkexec mkdir -p
{
sound_path
}
'
)
sound_files
=
[]
if
'ring01.mp3'
not
in
sound_files
and
debug
is
True
:
shutil
.
copyfile
(
'ring01.mp3'
,
f
'
{
sound_path
}
/ring01.mp3'
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать