fix changelog date, secure url and other pylint

ubuntu/focal
Hans P Möller 5 years ago
parent ca21971114
commit 4fd6183660

3
debian/changelog vendored

@ -1,5 +1,6 @@
lubuntu-update-notifier (0.1) eoan; urgency=medium lubuntu-update-notifier (0.1) eoan; urgency=medium
[ Hans P Möller ]
* Initial release. LP: #1840829 * Initial release. LP: #1840829
-- Hans P Möller <hmollercl@lubuntu.me> Tue, 28 May 2019 16:42:14 -0400 -- Hans P. Möller <hmoller@gmail.com> Thu, 22 Aug 2019 22:29:36 -0400

2
debian/copyright vendored

@ -1,4 +1,4 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://phab.lubuntu.me/source/lubuntu-update-notifier/ Source: https://phab.lubuntu.me/source/lubuntu-update-notifier/
Files: * Files: *

@ -1,27 +1,50 @@
#!/usr/bin/python3 #!/usr/bin/python3
# coding=utf-8
# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
''' Open Notification Dialog to enable upgrade'''
import sys import sys
import subprocess
from pathlib import Path
# from optparse import OptionParser
from argparse import ArgumentParser
from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QPushButton, from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QPushButton,
QHBoxLayout, QVBoxLayout) QHBoxLayout, QVBoxLayout)
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from optparse import OptionParser
from pathlib import Path
import subprocess
class Dialog(QWidget): class Dialog(QWidget):
''' UI '''
def __init__(self, upgrades, security_upgrades, reboot_required, upg_path): def __init__(self, upgrades, security_upgrades, reboot_required, upg_path):
QWidget.__init__(self) QWidget.__init__(self)
self.upgrades = upgrades self.upgrades = upgrades
self.security_upgrades = security_upgrades self.security_upgrades = security_upgrades
self.upg_path = upg_path self.upg_path = upg_path
self.reboot_required = reboot_required
self.initUI() self.initUI()
self.upgradeBtn.clicked.connect(self.call_upgrade) self.upgradeBtn.clicked.connect(self.call_upgrade)
self.closeBtn.clicked.connect(self.call_reject) self.closeBtn.clicked.connect(self.call_reject)
def initUI(self): def initUI(self):
''' UI initialization '''
self.label = QLabel() self.label = QLabel()
self.label.setAlignment(Qt.AlignHCenter) self.label.setAlignment(Qt.AlignHCenter)
self.upgradeBtn = QPushButton("Upgrade") self.upgradeBtn = QPushButton("Upgrade")
@ -51,7 +74,7 @@ class Dialog(QWidget):
text += " upgrade?\nThis will mean packages could be upgraded," text += " upgrade?\nThis will mean packages could be upgraded,"
text += " installed, or removed." text += " installed, or removed."
if reboot_required: if self.reboot_required:
if text == "": if text == "":
text = "Reboot is needed" text = "Reboot is needed"
self.upgradeBtn.setVisible(False) self.upgradeBtn.setVisible(False)
@ -61,6 +84,7 @@ class Dialog(QWidget):
self.label.setText(text) self.label.setText(text)
def center(self): def center(self):
''' puts UI in center of screen '''
frameGm = self.frameGeometry() frameGm = self.frameGeometry()
screen = QApplication.desktop().screenNumber( screen = QApplication.desktop().screenNumber(
QApplication.desktop().cursor().pos()) QApplication.desktop().cursor().pos())
@ -69,9 +93,11 @@ class Dialog(QWidget):
self.move(frameGm.topLeft()) self.move(frameGm.topLeft())
def call_reject(self): def call_reject(self):
''' when close button is pressed, quit '''
app.quit() app.quit()
def call_upgrade(self): def call_upgrade(self):
''' starts upgrade process '''
self.label.setText("Upgrading...") self.label.setText("Upgrading...")
# TODO maybe open another thread so notifier won't freeze # TODO maybe open another thread so notifier won't freeze
if self.upg_path == "terminal": if self.upg_path == "terminal":
@ -86,10 +112,6 @@ class Dialog(QWidget):
process = subprocess.Popen(cmd) process = subprocess.Popen(cmd)
process.wait() process.wait()
'''options.fullUpgrade = 1
dialogUpg = DialogUpg(optionss, pkg=self.packages)
dialogUpg.show()'''
if self.upg_path == "terminal": if self.upg_path == "terminal":
text = "Upgrade finished" text = "Upgrade finished"
@ -105,6 +127,7 @@ class Dialog(QWidget):
class App(QApplication): class App(QApplication):
'''application'''
def __init__(self, upgrades, security_upgrades, reboot_required, upg_path, def __init__(self, upgrades, security_upgrades, reboot_required, upg_path,
*args): *args):
QApplication.__init__(self, *args) QApplication.__init__(self, *args)
@ -114,6 +137,7 @@ class App(QApplication):
def main(args, upgrades, security_upgrades, reboot_required, upg_path): def main(args, upgrades, security_upgrades, reboot_required, upg_path):
'''main'''
global app global app
app = App(upgrades, security_upgrades, reboot_required, upg_path, args) app = App(upgrades, security_upgrades, reboot_required, upg_path, args)
app.setWindowIcon(QIcon.fromTheme("system-software-update")) app.setWindowIcon(QIcon.fromTheme("system-software-update"))
@ -121,30 +145,27 @@ def main(args, upgrades, security_upgrades, reboot_required, upg_path):
if __name__ == "__main__": if __name__ == "__main__":
parser = OptionParser() parser = ArgumentParser()
parser.add_option("-p", parser.add_argument("-p",
"--upgrader-sw", "--upgrader-sw",
dest="upg_path", dest="upg_path",
help="Define software/app to open for upgrade", help="Define software/app to open for upgrade",
metavar="APP") metavar="APP")
parser.add_option("-u", parser.add_argument("-u",
"--upgrades", "--upgrades",
dest="upgrades", dest="upgrades",
help="How many upgrades are available", help="How many upgrades are available",
metavar="APP") metavar="APP")
parser.add_option("-s", parser.add_argument("-s",
"--security-upg", "--security-upg",
dest="security_upgrades", dest="security_upgrades",
help="How many security upgrades are available", help="How many security upgrades are available",
metavar="APP") metavar="APP")
(options, args) = parser.parse_args() options = parser.parse_args()
reboot_required_path = Path("/var/run/reboot-required") reboot_required_path = Path("/var/run/reboot-required")
if reboot_required_path.exists(): reboot_required = reboot_required_path.exists()
reboot_required = True
else:
reboot_required = False
if int(options.upgrades) > 0 or reboot_required: if int(options.upgrades) > 0 or reboot_required:
main(sys.argv, int(options.upgrades), int(options.security_upgrades), main(sys.argv, int(options.upgrades), int(options.security_upgrades),

@ -1,4 +1,21 @@
#!/bin/sh #!/bin/sh
# coding=utf-8
# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
while true; while true;
do do
OUT=`/usr/lib/update-notifier/apt-check 2>&1` OUT=`/usr/lib/update-notifier/apt-check 2>&1`

@ -1,15 +1,35 @@
#!/usr/bin/python3 #!/usr/bin/python3
# coding=utf-8
# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# deppend on # deppend on
# aptdaemon # aptdaemon
# debconf-kde-helper # debconf-kde-helper
import sys import sys
import os import os
from pathlib import Path
# from optparse import OptionParser
from argparse import ArgumentParser
from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QPushButton, from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QPushButton,
QHBoxLayout, QVBoxLayout, QProgressBar, QHBoxLayout, QVBoxLayout, QProgressBar,
QPlainTextEdit, QMessageBox) QPlainTextEdit, QMessageBox)
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QTextCursor, QPalette from PyQt5.QtGui import QIcon, QTextCursor, QPalette
from optparse import OptionParser
from aptdaemon import client from aptdaemon import client
from aptdaemon.errors import NotAuthorizedError, TransactionFailed from aptdaemon.errors import NotAuthorizedError, TransactionFailed
from aptdaemon.enums import (EXIT_SUCCESS, from aptdaemon.enums import (EXIT_SUCCESS,
@ -18,10 +38,11 @@ from aptdaemon.enums import (EXIT_SUCCESS,
get_error_description_from_enum, get_error_description_from_enum,
get_error_string_from_enum, get_error_string_from_enum,
get_status_string_from_enum) get_status_string_from_enum)
from pathlib import Path
class DialogUpg(QWidget): class DialogUpg(QWidget):
'''UI'''
def __init__(self, options=None): def __init__(self, options=None):
QWidget.__init__(self) QWidget.__init__(self)
@ -57,6 +78,7 @@ class DialogUpg(QWidget):
self.upgrade() self.upgrade()
def initUI(self): def initUI(self):
'''initialize UI'''
self.label = QLabel() self.label = QLabel()
self.label.setAlignment(Qt.AlignHCenter) self.label.setAlignment(Qt.AlignHCenter)
self.closeBtn = QPushButton("Close") self.closeBtn = QPushButton("Close")
@ -87,6 +109,7 @@ class DialogUpg(QWidget):
self.center() self.center()
def center(self): def center(self):
'''centers UI'''
frameGm = self.frameGeometry() frameGm = self.frameGeometry()
screen = QApplication.desktop().screenNumber( screen = QApplication.desktop().screenNumber(
QApplication.desktop().cursor().pos()) QApplication.desktop().cursor().pos())
@ -95,16 +118,19 @@ class DialogUpg(QWidget):
self.move(frameGm.topLeft()) self.move(frameGm.topLeft())
def upgrade_progress(self, transaction, progress): def upgrade_progress(self, transaction, progress):
'''upgrade progressbar during upgrade'''
self.progressBar.setVisible(True) self.progressBar.setVisible(True)
self.progressBar.setValue(progress) self.progressBar.setValue(progress)
def update_progress(self, transaction, progress): def update_progress(self, transaction, progress):
'''upgrade progressbar during update'''
self.progressBar.setVisible(True) self.progressBar.setVisible(True)
self.progressBar.setValue(progress) self.progressBar.setValue(progress)
self.label.setText("Updating cache...") self.label.setText("Updating cache...")
def update_progress_download(self, transaction, uri, status, short_desc, def update_progress_download(self, transaction, uri, status, short_desc,
total_size, current_size, msg): total_size, current_size, msg):
'''print update info'''
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
if self.old_short_desc == short_desc: if self.old_short_desc == short_desc:
# if it's the same file we update the line, don't append new line # if it's the same file we update the line, don't append new line
@ -127,6 +153,7 @@ class DialogUpg(QWidget):
def upgrade_progress_download(self, transaction, uri, status, short_desc, def upgrade_progress_download(self, transaction, uri, status, short_desc,
total_size, current_size, msg): total_size, current_size, msg):
'''print upgrade info'''
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
if self.status == "status-downloading": if self.status == "status-downloading":
# TODO it prints the last line after installation is complete. # TODO it prints the last line after installation is complete.
@ -153,6 +180,7 @@ class DialogUpg(QWidget):
def update_progress_detail(self, transaction, current_items, total_items, def update_progress_detail(self, transaction, current_items, total_items,
current_bytes, total_bytes, current_cps, eta): current_bytes, total_bytes, current_cps, eta):
'''print update detail info'''
if total_items > 0: if total_items > 0:
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
if self.detailText != "Fetching " + str( if self.detailText != "Fetching " + str(
@ -165,6 +193,7 @@ class DialogUpg(QWidget):
def upgrade_progress_detail(self, transaction, current_items, total_items, def upgrade_progress_detail(self, transaction, current_items, total_items,
current_bytes, total_bytes, current_cps, eta): current_bytes, total_bytes, current_cps, eta):
'''print upgrade detail info'''
if total_items > 0: if total_items > 0:
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
if self.detailText != "Downloaded " + str( if self.detailText != "Downloaded " + str(
@ -176,6 +205,7 @@ class DialogUpg(QWidget):
self.label.setText(self.detailText + "\n" + self.downloadText) self.label.setText(self.detailText + "\n" + self.downloadText)
def upgrade_finish(self, transaction, exit_state): def upgrade_finish(self, transaction, exit_state):
'''when upgrade finish'''
if exit_state == EXIT_FAILED: if exit_state == EXIT_FAILED:
error_string = get_error_string_from_enum(transaction.error.code) error_string = get_error_string_from_enum(transaction.error.code)
error_desc = get_error_description_from_enum( error_desc = get_error_description_from_enum(
@ -188,7 +218,7 @@ class DialogUpg(QWidget):
text = text + "\n" + "Restart required" text = text + "\n" + "Restart required"
self.progressBar.setVisible(False) self.progressBar.setVisible(False)
if(len(self.errors) > 0): if len(self.errors) > 0:
text = text + "\n With some Errors" text = text + "\n With some Errors"
self.plainTextEdit.appendPlainText("Error Resume:\n") self.plainTextEdit.appendPlainText("Error Resume:\n")
for error in self.errors: for error in self.errors:
@ -204,18 +234,21 @@ class DialogUpg(QWidget):
self.plainTextEdit.setEnabled(True) self.plainTextEdit.setEnabled(True)
def upgrade_error(self, transaction, error_code, error_details): def upgrade_error(self, transaction, error_code, error_details):
'''if error during upgrade'''
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
self.errors.append("Eror Code: " + str(error_code)) self.errors.append("Eror Code: " + str(error_code))
self.errors.append("Error Detail: " + error_details) self.errors.append("Error Detail: " + error_details)
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
self.closeBtn.setEnabled(True) self.closeBtn.setEnabled(True)
print("ECode: " + str(error_code) + "\n") print "ECode: " + str(error_code) + "\n"
print("EDetail: " + error_details + "\n") print "EDetail: " + error_details + "\n"
def upgrade_cancellable_changed(self, transaction, cancellable): def upgrade_cancellable_changed(self, transaction, cancellable):
'''when upgrade cancellable toogle'''
self.closeBtn.setEnabled(cancellable) self.closeBtn.setEnabled(cancellable)
def update_cache(self): def update_cache(self):
'''runs cache update'''
self.closeBtn.setVisible(False) self.closeBtn.setVisible(False)
try: try:
self.trans1.connect('finished', self.update_finish) self.trans1.connect('finished', self.update_finish)
@ -237,6 +270,7 @@ class DialogUpg(QWidget):
+ "{}".format(e)) + "{}".format(e))
def update_finish(self, transaction, exit_state): def update_finish(self, transaction, exit_state):
'''when update finish'''
self.label.setText("Update Cache Finished") self.label.setText("Update Cache Finished")
if exit_state == EXIT_FAILED: if exit_state == EXIT_FAILED:
error_string = get_error_string_from_enum(transaction.error.code) error_string = get_error_string_from_enum(transaction.error.code)
@ -252,12 +286,14 @@ class DialogUpg(QWidget):
self.upgrade() self.upgrade()
def status_changed(self, transaction, status): def status_changed(self, transaction, status):
'''print info when status changed'''
self.status = status self.status = status
self.label.setText("Status:" + get_status_string_from_enum(status)) self.label.setText("Status:" + get_status_string_from_enum(status))
print("Status:" + get_status_string_from_enum(status) + " " + status print("Status:" + get_status_string_from_enum(status) + " " + status
+ "\n") + "\n")
def status_details_changed(self, transaction, details): def status_details_changed(self, transaction, details):
'''print status detail info'''
self.plainTextEdit.setVisible(True) self.plainTextEdit.setVisible(True)
if self.details != details: if self.details != details:
self.details = details self.details = details
@ -274,9 +310,10 @@ class DialogUpg(QWidget):
self.label.setText(self.detailText + "\n" + details) self.label.setText(self.detailText + "\n" + details)
# if is downloading put the "Downloaded x of y" text # if is downloading put the "Downloaded x of y" text
# print("PTY:" + str(self.slave)) # print("PTY:" + str(self.slave))
print("Status Details:" + details) print "Status Details:" + details
def upgrade(self): def upgrade(self):
'''runs upgrade'''
try: try:
self.trans2.connect('progress-changed', self.upgrade_progress) self.trans2.connect('progress-changed', self.upgrade_progress)
self.trans2.connect('cancellable-changed', self.trans2.connect('cancellable-changed',
@ -309,10 +346,12 @@ class DialogUpg(QWidget):
+ "{}".format(e)) + "{}".format(e))
def call_reject(self): def call_reject(self):
'''when close button is pushed, quit'''
app.quit() app.quit()
class App(QApplication): class App(QApplication):
'''app'''
def __init__(self, options, *args): def __init__(self, options, *args):
QApplication.__init__(self, *args) QApplication.__init__(self, *args)
self.dialog = DialogUpg(options) self.dialog = DialogUpg(options)
@ -320,6 +359,7 @@ class App(QApplication):
def main(args, options): def main(args, options):
'''main'''
global app global app
app = App(options, args) app = App(options, args)
app.setWindowIcon(QIcon.fromTheme("system-software-update")) app.setWindowIcon(QIcon.fromTheme("system-software-update"))
@ -337,19 +377,21 @@ def main(args, options):
if __name__ == "__main__": if __name__ == "__main__":
# check arguments # check arguments
parser = OptionParser(usage='%prog [options]', parser = ArgumentParser()
version='0.1',) parser.add_argument("-c",
parser.add_option("-c",
"--cache-update", "--cache-update",
action="store_true", action="store_true",
dest="cacheUpdate", dest="cacheUpdate",
help="Update Cache Before Upgrade") help="Update Cache Before Upgrade")
parser.add_option("-f", parser.add_argument("-f",
"--full-upgrade", "--full-upgrade",
action="store_true", action="store_true",
dest="fullUpgrade", dest="fullUpgrade",
help="Full upgrade same as dist-upgrade") help="Full upgrade same as dist-upgrade")
(options, args) = parser.parse_args() parser.add_argument('--version',
action='version',
version='%(prog)s 0.1')
options = parser.parse_args()
# run it # run it
main(sys.argv, options) main(sys.argv, options)

@ -1,8 +1,22 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# coding=utf-8
# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup from setuptools import setup
# from distutils.core import setup
# from DistUtilsExtra.command import *
setup( setup(
name="lubuntu-update-notifier", name="lubuntu-update-notifier",

Loading…
Cancel
Save