mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
refactoring: LOGS_PATH constant renamed to LOGS_DIR and moved to 'api' module
This commit is contained in:
@@ -3,4 +3,3 @@ __app_name__ = 'bauh'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
LOGS_PATH = '/tmp/{}/logs'.format(__app_name__)
|
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ CONFIG_PATH = '{}/.config/bauh'.format(str(Path.home()))
|
|||||||
USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home()))
|
USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home()))
|
||||||
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home()))
|
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home()))
|
||||||
TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}'
|
TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}'
|
||||||
|
LOGS_DIR = f'{TEMP_DIR}/logs'
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from PyQt5.QtCore import QThread, pyqtSignal, QObject
|
|||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import QWidget
|
from PyQt5.QtWidgets import QWidget
|
||||||
|
|
||||||
from bauh import LOGS_PATH
|
from bauh.api import user
|
||||||
from bauh.api.abstract.cache import MemoryCache
|
from bauh.api.abstract.cache import MemoryCache
|
||||||
from bauh.api.abstract.controller import SoftwareManager, UpgradeRequirement, UpgradeRequirements, SoftwareAction
|
from bauh.api.abstract.controller import SoftwareManager, UpgradeRequirement, UpgradeRequirements, SoftwareAction
|
||||||
from bauh.api.abstract.handler import ProcessWatcher
|
from bauh.api.abstract.handler import ProcessWatcher
|
||||||
@@ -20,7 +20,7 @@ from bauh.api.abstract.model import PackageStatus, SoftwarePackage, CustomSoftwa
|
|||||||
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, TextComponent, \
|
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, TextComponent, \
|
||||||
FormComponent, ViewComponent
|
FormComponent, ViewComponent
|
||||||
from bauh.api.exception import NoInternetException
|
from bauh.api.exception import NoInternetException
|
||||||
from bauh.api import user
|
from bauh.api.paths import LOGS_DIR
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.commons.internet import InternetChecker
|
from bauh.commons.internet import InternetChecker
|
||||||
from bauh.commons.system import get_human_size_str, ProcessHandler, SimpleProcess
|
from bauh.commons.system import get_human_size_str, ProcessHandler, SimpleProcess
|
||||||
@@ -200,8 +200,8 @@ class AsyncAction(QThread, ProcessWatcher):
|
|||||||
|
|
||||||
class UpgradeSelected(AsyncAction):
|
class UpgradeSelected(AsyncAction):
|
||||||
|
|
||||||
LOGS_DIR = '{}/upgrade'.format(LOGS_PATH)
|
UPGRADE_LOGS_DIR = f'{LOGS_DIR}/upgrade'
|
||||||
SUMMARY_FILE = LOGS_DIR + '/{}_summary.txt'
|
SUMMARY_FILE = UPGRADE_LOGS_DIR + '/{}_summary.txt'
|
||||||
|
|
||||||
def __init__(self, manager: SoftwareManager, internet_checker: InternetChecker, i18n: I18n, pkgs: List[PackageView] = None):
|
def __init__(self, manager: SoftwareManager, internet_checker: InternetChecker, i18n: I18n, pkgs: List[PackageView] = None):
|
||||||
super(UpgradeSelected, self).__init__()
|
super(UpgradeSelected, self).__init__()
|
||||||
@@ -330,7 +330,7 @@ class UpgradeSelected(AsyncAction):
|
|||||||
|
|
||||||
def _write_summary_log(self, upgrade_id: str, requirements: UpgradeRequirements):
|
def _write_summary_log(self, upgrade_id: str, requirements: UpgradeRequirements):
|
||||||
try:
|
try:
|
||||||
Path(self.LOGS_DIR).mkdir(parents=True, exist_ok=True)
|
Path(self.UPGRADE_LOGS_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
summary_text = StringIO()
|
summary_text = StringIO()
|
||||||
summary_text.write('Upgrade summary ( id: {} )'.format(upgrade_id))
|
summary_text.write('Upgrade summary ( id: {} )'.format(upgrade_id))
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QCheckBox, QHeaderView, QToolB
|
|||||||
QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \
|
QLabel, QPlainTextEdit, QProgressBar, QPushButton, QComboBox, QApplication, QListView, QSizePolicy, \
|
||||||
QMenu, QHBoxLayout
|
QMenu, QHBoxLayout
|
||||||
|
|
||||||
from bauh import LOGS_PATH
|
from bauh.api import user
|
||||||
from bauh.api.abstract.cache import MemoryCache
|
from bauh.api.abstract.cache import MemoryCache
|
||||||
from bauh.api.abstract.context import ApplicationContext
|
from bauh.api.abstract.context import ApplicationContext
|
||||||
from bauh.api.abstract.controller import SoftwareManager, SoftwareAction
|
from bauh.api.abstract.controller import SoftwareManager, SoftwareAction
|
||||||
from bauh.api.abstract.model import SoftwarePackage
|
from bauh.api.abstract.model import SoftwarePackage
|
||||||
from bauh.api.abstract.view import MessageType
|
from bauh.api.abstract.view import MessageType
|
||||||
from bauh.api.http import HttpClient
|
from bauh.api.http import HttpClient
|
||||||
from bauh.api import user
|
from bauh.api.paths import LOGS_DIR
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
from bauh.context import set_theme
|
from bauh.context import set_theme
|
||||||
from bauh.stylesheet import read_all_themes_metadata, ThemeMetadata
|
from bauh.stylesheet import read_all_themes_metadata, ThemeMetadata
|
||||||
@@ -1106,8 +1106,8 @@ class ManageWindow(QWidget):
|
|||||||
|
|
||||||
if output:
|
if output:
|
||||||
try:
|
try:
|
||||||
Path(UpgradeSelected.LOGS_DIR).mkdir(parents=True, exist_ok=True)
|
Path(UpgradeSelected.UPGRADE_LOGS_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
logs_path = '{}/{}.log'.format(UpgradeSelected.LOGS_DIR, res['id'])
|
logs_path = '{}/{}.log'.format(UpgradeSelected.UPGRADE_LOGS_DIR, res['id'])
|
||||||
with open(logs_path, 'w+') as f:
|
with open(logs_path, 'w+') as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
|
||||||
@@ -1339,11 +1339,12 @@ class ManageWindow(QWidget):
|
|||||||
console_output = self.textarea_details.toPlainText()
|
console_output = self.textarea_details.toPlainText()
|
||||||
|
|
||||||
if console_output:
|
if console_output:
|
||||||
log_path = '{}/install/{}/{}'.format(LOGS_PATH, res['pkg'].model.get_type(), res['pkg'].model.name)
|
log_path = f"{LOGS_DIR}/install/{res['pkg'].model.get_type()}/{res['pkg'].model.name}"
|
||||||
try:
|
try:
|
||||||
Path(log_path).mkdir(parents=True, exist_ok=True)
|
Path(log_path).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
log_file = log_path + '/{}.log'.format(int(time.time()))
|
log_file = f'{log_path}/{int(time.time())}.log'
|
||||||
|
|
||||||
with open(log_file, 'w+') as f:
|
with open(log_file, 'w+') as f:
|
||||||
f.write(console_output)
|
f.write(console_output)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user