Adding notice on snap permissions (#790)

This commit is contained in:
Raivis Dejus 2024-06-09 13:54:59 +03:00 committed by GitHub
commit 3bb9dd8044
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 92 additions and 8 deletions

View file

@ -42,4 +42,8 @@ Download and run the `.exe` file in the [releases page](https://github.com/chidi
```shell
sudo apt-get install libportaudio2
sudo snap install buzz
sudo snap connect buzz:audio-record
sudo snap connect buzz:password-manager-service
sudo snap connect buzz:pulseaudio
sudo snap connect buzz:removable-media
```

View file

@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-07 21:05+0300\n"
"PO-Revision-Date: 2024-06-07 21:06+0300\n"
"POT-Creation-Date: 2024-06-09 13:25+0300\n"
"PO-Revision-Date: 2024-06-09 13:27+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: lv_LV\n"
@ -43,7 +43,7 @@ msgid "View Transcript Timestamps"
msgstr "Aplūkot atpazīšanas laikus"
#: buzz/settings/shortcut.py:25 buzz/widgets/main_window_toolbar.py:60
#: buzz/widgets/main_window.py:200
#: buzz/widgets/main_window.py:214
msgid "Clear History"
msgstr "Notīrīt vēsturi"
@ -148,6 +148,26 @@ msgstr ""
"Lūdzu pārbaudiet savas audio ierīces vai pārbaudiet lietotnes ziņojumu "
"žurnālus, lai iegūtu papildu informāciju."
#: buzz/widgets/snap_notice.py:9
msgid "Snap permission notice"
msgstr "Snap atļauju piezīme"
#: buzz/widgets/snap_notice.py:13
msgid ""
"No input devices found, please check that snap permissions have been granted"
msgstr ""
"Nav atrasta neviena skaņas ievades ierīce, iespējams nav piešķirtas "
"nepieciešamās snap atļaujas"
#: buzz/widgets/snap_notice.py:16
msgid ""
"To enable necessary permissions run the following commands in the terminal"
msgstr "Lai piešķirtu nepieciešamās atļaujas izpildiet šīs komandas"
#: buzz/widgets/snap_notice.py:30
msgid "Close"
msgstr "Aizvērt"
#: buzz/widgets/menu_bar.py:38
msgid "Import File..."
msgstr "Importēt failu..."
@ -168,7 +188,7 @@ msgstr "Fails"
msgid "Help"
msgstr "Palīdzība"
#: buzz/widgets/main_window.py:202
#: buzz/widgets/main_window.py:216
msgid ""
"Are you sure you want to delete the selected transcription(s)? This action "
"cannot be undone."
@ -176,16 +196,16 @@ msgstr ""
"Vai tiešām vēlaties dzēst izvēlētos transkriptus? Šī ir neatgriezeniska "
"darbība."
#: buzz/widgets/main_window.py:222
#: buzz/widgets/main_window.py:236
msgid "Select audio file"
msgstr "Izvēlieties audio failu"
#: buzz/widgets/main_window.py:256
#: buzz/widgets/main_window.py:270
#: buzz/widgets/preferences_dialog/models_preferences_widget.py:191
msgid "Error"
msgstr "Kļūda"
#: buzz/widgets/main_window.py:256
#: buzz/widgets/main_window.py:270
msgid "Unable to save OpenAI API key to keyring"
msgstr "Neizdevās saglabāt OpenAI API atslēgu atslēgu saišķī"
@ -342,7 +362,7 @@ msgstr ""
"Jūsu API atslēga ir derīga. Buzz izmantos to runas atpazīšanai ar Whisper "
"API."
#: buzz/widgets/preferences_dialog/general_preferences_widget.py:157
#: buzz/widgets/preferences_dialog/general_preferences_widget.py:156
msgid "Select Export Folder"
msgstr "Izvēlieties mapi kurā eksportēt"

View file

@ -1,4 +1,6 @@
import os
import logging
import sounddevice
from typing import Tuple, List, Optional
from PyQt6 import QtGui
@ -32,6 +34,7 @@ from buzz.widgets.icon import BUZZ_ICON_PATH
from buzz.widgets.import_url_dialog import ImportURLDialog
from buzz.widgets.main_window_toolbar import MainWindowToolbar
from buzz.widgets.menu_bar import MenuBar
from buzz.widgets.snap_notice import SnapNotice
from buzz.widgets.preferences_dialog.models.preferences import Preferences
from buzz.widgets.transcriber.file_transcriber_widget import FileTranscriberWidget
from buzz.widgets.transcription_task_folder_watcher import (
@ -137,6 +140,17 @@ class MainWindow(QMainWindow):
self.folder_watcher.task_found.connect(self.add_task)
self.folder_watcher.find_tasks()
if os.environ.get('SNAP_NAME', '') == 'buzz':
self.check_linux_permissions()
def check_linux_permissions(self):
devices = sounddevice.query_devices()
input_devices = [device for device in devices if device['max_input_channels'] > 0]
if len(input_devices) == 0:
snap_notice = SnapNotice(self)
snap_notice.show()
def on_preferences_changed(self, preferences: Preferences):
self.preferences = preferences
self.save_preferences(preferences)

View file

@ -0,0 +1,32 @@
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QTextEdit, QLabel, QPushButton
from buzz.locale import _
class SnapNotice(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle(_("Snap permission notice"))
self.layout = QVBoxLayout(self)
self.notice_label = QLabel(_("No input devices found, please check that snap permissions have been granted"))
self.layout.addWidget(self.notice_label)
self.instruction_label = QLabel(_("To enable necessary permissions run the following commands in the terminal"))
self.layout.addWidget(self.instruction_label)
self.text_edit = QTextEdit(self)
self.text_edit.setPlainText(
"sudo snap connect buzz:audio-record\n"
"sudo snap connect buzz:password-manager-service\n"
"sudo snap connect buzz:pulseaudio\n"
"sudo snap connect buzz:removable-media"
)
self.text_edit.setReadOnly(True)
self.text_edit.setFixedHeight(80)
self.layout.addWidget(self.text_edit)
self.button = QPushButton(_("Close"), self)
self.button.clicked.connect(self.close)
self.layout.addWidget(self.button)

View file

@ -30,6 +30,10 @@ Download and run the `Buzz-x.y.z.exe` file.
```shell
sudo apt-get install libportaudio2
sudo snap install buzz
sudo snap connect buzz:audio-record
sudo snap connect buzz:password-manager-service
sudo snap connect buzz:pulseaudio
sudo snap connect buzz:removable-media
```
[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/buzz)

View file

@ -18,6 +18,7 @@ from buzz.locale import _
from buzz.db.entity.transcription import Transcription
from buzz.db.service.transcription_service import TranscriptionService
from buzz.widgets.main_window import MainWindow
from buzz.widgets.snap_notice import SnapNotice
from buzz.widgets.transcriber.file_transcriber_widget import FileTranscriberWidget
from buzz.widgets.transcription_viewer.transcription_viewer_widget import (
TranscriptionViewerWidget,
@ -284,3 +285,12 @@ class TestMainWindow:
def _get_toolbar_action(window: MainWindow, text: str):
toolbar: QToolBar = window.findChild(QToolBar)
return [action for action in toolbar.actions() if action.text() == text][0]
def test_snap_notice_dialog(self, qtbot: QtBot):
snap_notice = SnapNotice()
snap_notice.show()
qtbot.wait_until(lambda: snap_notice.isVisible(), timeout=1000)
snap_notice.close()
assert not snap_notice.isVisible()