experiments

merge-requests/65/head
fhdk 2018-09-08 19:04:21 +02:00
parent 7e92950a1f
commit a62e7fc280
4 changed files with 12 additions and 128 deletions

View File

@ -1,118 +0,0 @@
#!/bin/bash
# MIT License
#
# Copyright (c) 2018 Fredes Computer Service
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#set -x
if [[ -n ${APP_UTILITY} ]]; then
echo "This script is part of Manjaro Application Utility\nIt is not meant to be run from command line\n exit()"
fi
# files
IN_PKG_FILE="/tmp/.install-packages.txt"
RM_PKG_FILE="/tmp/.remove-packages.txt"
PM_STATUS_FILE="/tmp/.pm-status.txt"
PM_LOCK_FILE="/var/lib/pacman/db.lck"
echo ${IN_PKG_FILE}
echo ${RM_PKG_FILE}
# messages
TITLE="Manjaro Application Utility"
UPD_DB_MSG="Updating Package Database..."
DB_LOCKED_MSG="Another package manager is running.\n
If you are updating the system\n
you MUST finish before continuing.\n
If you are not, it is safe to kill the other process.\n
What would you like to do?"
KILL_PROCESS="Kill other process and continue"
WAIT_PROCESS="Wait to finish updating"
IN_WORKING_MSG="Installing Packages..."
RM_WORKING_MSG="Uninstalling Packages..."
DONE="Your System has Been Successfully Updated"
if [[ -f ${IN_PKG_FILE} ]]; then
IN_PKG=` cat ${IN_PKG_FILE} `
echo ${IN_PKG}
fi
if [[ -f ${RM_PKG_FILE} ]]; then
RM_PKG=` cat ${RM_PKG_FILE} `
echo ${RM_PKG}
fi
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "Superuser required ..." 1>&2
exit 1
fi
# updating databases and writing results to a file
pacman -Syy | tee ${PM_STATUS_FILE} | zenity --progress --title="${TITLE}" --no-cancel --pulsate --text "${UPD_DB_MSG}" --width=500 --auto-close
PM_STATUS=` cat ${PM_STATUS_FILE} `
# checking for other running package managers
if [[ $(cat ${PM_STATUS_FILE} | grep -i 'core.db') = "" ]]
then # giving choice to user to kill other process or wait
ans=$(zenity --list --title="${TITLE}" --radiolist --text "${DB_LOCKED_MSG}" --column Select --column Choice TRUE "${KILL_PROCESS}" FALSE "${WAIT_PROCESS}" --width=500 --height=300)
# killing pamac and unlocking db
if [ "$ans" = "${KILL_PROCESS}" ]
then
killall pamac-updater
killall pamac-manager
rm ${PM_LOCK_FILE}
pacman -Syy | zenity --progress --title="${TITLE}" --no-cancel --pulsate --text "${UPD_DB_MSG}" --width=500 --auto-close
else # exiting according to user choice
exit
fi
fi
# Installing packages
if [[ -n ${IN_PKG} ]]; then
pacman -Syu --noconfirm ${IN_PKG} | zenity --progress --title="${TITLE}" --no-cancel --pulsate --text "${IN_WORKING_MSG}" --width=500 --auto-close
fi
# Uninstalling packages
if [[ -n ${RM_PKG} ]]; then
pacman -R --noconfirm ${RM_PKG} | zenity --progress --title="${TITLE}" --no-cancel --pulsate --text "${RM_WORKING_MSG}" --width=500 --auto-close
fi
# Letting user know that packages have been installed
zenity --info --text="${DONE}" --width=500 --height=300
# removing files no longer needed
if [[ -f ${IN_PKG_FILE} ]]; then
rm ${IN_PKG_FILE}
fi
if [[ -f ${RM_PKG_FILE} ]]; then
rm ${RM_PKG_FILE}
fi
if [[ -f ${PM_STATUS_FILE} ]]; then
rm ${PM_STATUS_FILE}
fi
if [[ -f ${PM_LOCK_FILE} ]]; then
rm ${PM_LOCK_FILE}
fi

View File

@ -279,6 +279,8 @@ class Browser(Gtk.Box):
# self.title_box = None
def set_title_box(self, html: str, color: Gtk.MessageType = Gtk.MessageType.INFO):
while len(html) < 200:
html = html + " "
if isinstance(self.config, HelloConfig):
self.title_box.set_message_type(color)
self.title_label.set_markup("<big>Manjaro Application Maintenance</big> " + html)

View File

@ -3,11 +3,11 @@ import os
import shutil
import urllib.request
from .data import AppData
from .data import ApplicationData
from .browser_base_config import BrowserBaseConfig
class BrowserConfig(BrowserBaseConfig, AppData):
class BrowserConfig(BrowserBaseConfig, ApplicationData):
"""Configuration with datas"""
def load(self):
@ -15,7 +15,7 @@ class BrowserConfig(BrowserBaseConfig, AppData):
def __init__(self, application: str):
BrowserBaseConfig.__init__(self, application)
AppData.__init__(self)
ApplicationData.__init__(self)
self.load()
self.merge_jsons()
@ -26,7 +26,7 @@ class BrowserConfig(BrowserBaseConfig, AppData):
and use only self._JSONMERGED ?
Always save .json in self._JSONMERGED ?
"""
# writed temp
# write temp
if self.url["main"]:
src = "/tmp/{self.application}-download.json"
urllib.request.urlretrieve(self.url["main"], src)

View File

@ -11,7 +11,7 @@ gi.require_version('Pamac', '1.0')
from gi.repository import Pamac
class AppData:
class ApplicationData:
def __init__(self):
self.filename = ""
self._json = []
@ -53,6 +53,7 @@ class AppData:
if self.filter not in group["filter"]:
logging.debug(f"filter group : {group['name']} {group['filter']} < {self.filter}")
continue
except KeyError:
# not in json file
pass
@ -65,7 +66,7 @@ class AppData:
try:
if self.filter not in app["filter"]:
logging.debug(f"\tfilter app: {app['name']} {app['filter']} < {self.filter}")
continue
# continue
except KeyError:
pass
@ -79,15 +80,14 @@ class AppData:
if keys:
if f"!{self.desktop}" in keys:
logging.debug(f"\tfilter desktop(not for): {app['name']} {app['desktop']} < {self.desktop}")
else:
logging.debug(f"\tfilter desktop(for): {app['name']} {app['desktop']} < {self.desktop}")
# continue
keys = [x for x in keys if not x.startswith("!")]
if keys:
if self.desktop != "?" and self.desktop not in keys:
logging.debug(f"\tfilter desktop(for): {app['name']} {app['desktop']} < {self.desktop}")
else:
logging.debug(f"\tfilter desktop(not for): {app['name']} {app['desktop']} < {self.desktop}")
# continue
ret[-1]["apps"].append(app)
return ret