Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
misc improvements, fixed #13
Browse files Browse the repository at this point in the history
  • Loading branch information
gaining committed May 5, 2017
1 parent d10a088 commit d77feaa
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 100 deletions.
6 changes: 3 additions & 3 deletions Resetter/DEBIAN/control → Resetter/control/control
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: resetter
Version: 0.2.5-rc2
Installed-Size: 1224
Version: 0.2.6-rc3
Installed-Size: 1220
Maintainer: gaining <gaining7@outlook.com>
Section: python
Homepage: https://github.com/gaining/resetter
Architecture: all
Priority: optional
Depends: python-qt4 (>=4.10), python-apt (>=0.9.3), coreutils (>=7.0), python-evdev (>=0.4), python-mechanize (>=1:0.2.5), python-bs4 (>=4.2), add-apt-key (>=1.0)
Depends: python-qt4 (>=4.10), python-apt (>=0.9.3), coreutils (>=7.0), python-mechanize (>=1:0.2.5), python-bs4 (>=4.2), add-apt-key (>=1.0)
Pre-Depends: python (>=2.7.5), policykit-1 (>=0.105)
Description: Resets Ubuntu/Linux-Mint to stock
Resetter is an easy way to reset your debian based linux back to stock. It also has other useful tools such as a ppa manager, an installer and a way to install ppa's straight from launchpad.net.
Expand Down
1 change: 1 addition & 0 deletions Resetter/control/debian-binary
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0
File renamed without changes.
7 changes: 2 additions & 5 deletions Resetter/usr/bin/resetter
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/bin/bash
LANG=en_US.UTF-8

if [[ $EUID -ne 0 ]]; then
pkexec /usr/lib/resetter/Resetter.py
else
/usr/lib/resetter/Resetter.py
fi
python /usr/lib/resetter/Resetter.py



9 changes: 3 additions & 6 deletions Resetter/usr/lib/resetter/AboutPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def __init__(self, parent=None):
pixmap2 = pixmap.scaled(300, 91)
about_font = QtGui.QFont()
about_font.setBold(True)
title_font = QtGui.QFont()
title_font.setBold(True)
title_font.setPointSize(20)
about_label = QtGui.QLabel(self)
desc_label = QtGui.QLabel(self)
desc_label.setAlignment(QtCore.Qt.AlignCenter)
Expand All @@ -35,13 +32,13 @@ def __init__(self, parent=None):
about_label.setAlignment(QtCore.Qt.AlignCenter)
cr_text = "Copyright (c) 2017 all rights reserved"
desc_text = "Built With PyQt\n\n " \
"This is a great utility software that will help you reset your linux installation its stock state"
version_text = "Version: 0.2.5-rc2"
"This is a great utility software that will help you reset your linux installation its stock state" \
"among other things."
version_text = "Version: 0.2.6-rc3"
donate_text = 'If you liked my project, please ' \
'<a href="https://github.com/gaining/Resetter/blob/master/DONATE.md">Donate </a>'
more_text = 'To find out more about this project, please visit my github:' \
' <a href="https://github.com/gaining/resetter"> Resetter</a>'

about_label.setPixmap(pixmap2)
desc_label.setText(desc_text)
cr_label.setText(cr_text)
Expand Down
18 changes: 11 additions & 7 deletions Resetter/usr/lib/resetter/AptProgress.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import apt_pkg
from PyQt4 import QtGui
from apt.progress.base import InstallProgress, OpProgress, AcquireProgress
from evdev import uinput, ecodes as e

apt_pkg.init_config()
apt_pkg.config.set("DPkg::Options::", "--force-confnew")
apt_pkg.config.set('APT::Get::Assume-Yes', 'true')
apt_pkg.config.set('APT::Get::force-yes', 'true')
os.putenv("DEBIAN_FRONTEND", "gnome")


class UIOpProgress(OpProgress):
Expand Down Expand Up @@ -71,6 +78,8 @@ def __init__(self, pbar, status_label):
self.pbar = pbar
self.status_label = status_label
self.last = 0.0
os.putenv("DEBIAN_FRONTEND", "gnome")


def status_change(self, pkg, percent, status):
if self.last >= percent:
Expand All @@ -91,12 +100,7 @@ def processing(self, pkg, stage):
print "starting {} stage for {}".format(stage, pkg)

def conffile(self, current, new):
#keeps current conf file by pressing enter key
print "WARNING: conffile prompt: {} {}".format(current, new)
with uinput.UInput() as ui:
ui.write(e.EV_KEY, e.KEY_ENTER, 1)
ui.write(e.EV_KEY, e.KEY_ENTER, 0)
ui.syn()
print "new config file automatically accepted"

def error(self, errorstr):
print "ERROR: {}".format(errorstr)
35 changes: 12 additions & 23 deletions Resetter/usr/lib/resetter/EasyInstall.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from InstallMissingDialog import Install
import os
import sys
import apt
import os
import textwrap
from PyQt4 import QtCore, QtGui

from InstallMissingDialog import Install


class EasyInstaller(QtGui.QDialog):
def __init__(self):
super(EasyInstaller, self).__init__()
def __init__(self, parent=None):
super(EasyInstaller, self).__init__(parent)
self.setWindowTitle("Easy install")
self.list_view = QtGui.QListView()
self.list_view = QtGui.QListView(self)
self.list_view.setFixedWidth(380)
self.EditText = QtGui.QLineEdit()
self.EditText.setPlaceholderText("Search for applications")
Expand Down Expand Up @@ -64,7 +65,6 @@ def __init__(self):
verticalLayout.addWidget(self.list_view)
verticalLayout.addLayout(horizontalLayout2)
self.cache = apt.Cache()
self.unavailable = []
self.isWritten = False


Expand Down Expand Up @@ -137,15 +137,11 @@ def openBackup(self):
self.list_view.setModel(self.model)
self.EditText.clear()
except KeyError:
self.unavailable.append(line)
continue
except IOError:
pass

def installPackages(self):
if len(self.unavailable) > 0:
self.keptBack(self.unavailable)

model = self.model
for index in xrange(model.rowCount()):
item = model.item(index)
Expand All @@ -163,7 +159,7 @@ def installPackages(self):
self.install.show()
self.install.exec_()
self.removeItems()
print "Done"
print "Finished installing"

def closeview(self):
self.cache.close()
Expand All @@ -179,9 +175,12 @@ def alreadyInstalled(self, package):
def showMessage(self, package):
self.comboBox.clear()
self.comboBox.addItem("Did you mean?")
i = 0
for p in self.cache:
if p.shortname.startswith(package):
if p.shortname.startswith(package) and len(package) > 0 and i < 12:
i += 1
self.comboBox.addItem(p.shortname)

if self.comboBox.count() > 1:
self.comboBox.setVisible(True)
msg = QtGui.QMessageBox(self)
Expand All @@ -192,13 +191,3 @@ def showMessage(self, package):
"please use [EasyPPA - refresh sources] feature, "
"then try adding the package again.")
msg.exec_()

def keptBack(self, una):
msg = QtGui.QMessageBox(self)
msg.setWindowTitle("Packages kept back")
msg.setIcon(QtGui.QMessageBox.Information)
msg.setText("These packages are not available in the cache so they won't be installed")
msg.setDetailedText("You may find them by using the Easy PPA function")
text = "\n".join(una)
msg.setInformativeText(text)
msg.exec_()
9 changes: 4 additions & 5 deletions Resetter/usr/lib/resetter/EasyRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def __init__(self, parent=None):
self.ppa = []
self.table_data = []



def configureTable(self, table):
table.setColumnCount(4)
table.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Description"))
Expand Down Expand Up @@ -171,9 +169,8 @@ def isThereInternet(self):
except mechanize.URLError as e:
print "There is no internet {}".format(e)

self.error_msg.setText("No internet")
self.error_msg.setDetailedText("If this keeps happening, it means easy repo stumbled upon a "
"forbidden link. You might need to change your search string")
self.error_msg.setText("You are not connected to the internet")
self.error_msg.setDetailedText("This feature will not work without an internet connection. ")
self.error_msg.exec_()
return False

Expand Down Expand Up @@ -241,6 +238,7 @@ def getTableData(self, sauce):
self.table_data.append(pasta)

def showPackages(self, sauce):
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
button = QtGui.qApp.focusWidget()
index = self.table.indexAt(button.pos())
if index.isValid():
Expand All @@ -249,6 +247,7 @@ def showPackages(self, sauce):
if len(sauce) >= index.row():
available.showView(sauce[index.row()], "PPA Packages", text, False)
available.show()
QtGui.QApplication.restoreOverrideCursor()

def showMessage(self):
msg = QtGui.QMessageBox(self)
Expand Down
7 changes: 4 additions & 3 deletions Resetter/usr/lib/resetter/PackageView.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ def showView(self, data, title, tip, start):
list_view.show()

else:
word = 'deb'
for x in data:
m = (str(x))
if m.startswith('deb') or m.startswith('#'):
if m.startswith(word) or m.startswith('#') \
and m[2:].split(' ')[0][:3] == word:
item = QtGui.QStandardItem(m)
item.setCheckable(False)
item.setEditable(False)
item.setCheckState(QtCore.Qt.PartiallyChecked)
item.setCheckState(QtCore.Qt.Checked)
model.appendRow(item)
data.save()
list_view.setModel(model)
list_view.show()

Expand Down
66 changes: 30 additions & 36 deletions Resetter/usr/lib/resetter/Resetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,27 @@ def __init__(self, parent=None):
font = QtGui.QFont()
font.setPointSize(25)
button_style = ("""
QPushButton {
border: 2px solid #555;
border-radius: 30px;
padding: 5px;
background: qradialgradient(cx: 0.5, cy: -0.6,
fx: -0.5, fy: 0.6,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
}
QPushButton:hover {
background: qradialgradient(cx: 0.5, cy: 0.3,
fx: 0.5, fy: 0.3,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
min-width: 80px;
}
QPushButton:pressed {
background: qradialgradient(cx: 0.7, cy: -0.7,
fx: 0.7, fy: -0.7,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
}
""")
QPushButton {
border: 2px solid #555;
border-radius: 30px;
padding: 5px;
background: qradialgradient(cx: 0.5, cy: -0.6,
fx: -0.5, fy: 0.6,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
}
QPushButton:hover {
background: qradialgradient(cx: 0.5, cy: 0.3,
fx: 0.5, fy: 0.3,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
min-width: 80px;
}
QPushButton:pressed {
background: qradialgradient(cx: 0.7, cy: -0.7,
fx: 0.7, fy: -0.7,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
}""")
self.btnReset = QtGui.QPushButton(self)
self.btnReset.setText("Automatic Reset", )
self.btnReset.setFixedHeight(100)
Expand Down Expand Up @@ -313,7 +311,7 @@ def getMissingPackages(self):
word = "vivid"
else:
word = None
black_list = ['linux-image', 'linux-headers', "openjdk-7-jre"]
black_list = ['linux-image', 'linux-headers', 'openjdk-7-jre', 'grub']
with open("apps-to-install", "w") as output, open("installed", "r") as installed, \
open(self.manifest, "r") as man:
diff = set(man).difference(installed)
Expand Down Expand Up @@ -343,6 +341,8 @@ def save(self):

def detectOS(self):
self.logger.info("OS is {}".format(self.os_info['DESCRIPTION']))
#compat_oses = (['LinuxMint', 'Ubuntu', 'elementary', 'Deepin'])
#compat_releases = (['17.3', '18.1', '18', '14.04','16.04', '16.10', '0.4','15.4'])
if self.os_info['ID'] == ('LinuxMint'):
if self.os_info['RELEASE'] == '17.3':
self.setWindowTitle(self.os_info['ID'] + " Resetter")
Expand Down Expand Up @@ -474,20 +474,15 @@ def warningPrompt(self):
def getInstalledList(self):
try:
self.logger.info("getting installed list...")
self.setCursor(QtCore.Qt.BusyCursor)
p1 = subprocess.Popen(['dpkg', '--get-selections'], stdout=subprocess.PIPE, bufsize=1)
self.unsetCursor()
result = p1.stdout
i = 0
tab = '\t'
with open("installed", "w") as output:
for line in result:
i += 1
for i, line in enumerate(result):
line = line.split(tab, 1)[0]
output.write(line + '\n')
self.logger.debug("installed list was generated with {} apps installed".format(i))
except (subprocess.CalledProcessError) as e:
self.unsetCursor()
except subprocess.CalledProcessError as e:
self.logger.error("Error: {}".format(e.ouput), exc_info=True)
self.error_msg.setText("Installed list failed to generate or may not be complete: {}".format(e))
self.error_msg.exec_()
Expand All @@ -509,7 +504,6 @@ def processManifest(self):
self.logger.info("manifest processing complete")
self.compareFiles()
except Exception as e:
self.unsetCursor()
self.logger.error("Manifest processing failed [{}]".format(e))
self.error_msg.setText("Manifest processing failed")
self.error_msg.setDetailedText("{}".format(e))
Expand All @@ -525,10 +519,12 @@ def lineCount(self, f_in):

def compareFiles(self):
try:
black_list = ['linux-image', 'linux-headers', 'ca-certificates', 'pyqt4-dev-tools',
black_list = (['linux-image', 'linux-headers', 'ca-certificates', 'pyqt4-dev-tools',
'python-apt', 'python-aptdaemon', 'python-qt4', 'python-qt4-doc', 'libqt',
'pyqt4-dev-tools', 'openjdk', 'python-sip', 'gksu', 'resetter',
'python-evdev', 'python-bs4', 'python-mechanize']
'python-evdev', 'python-bs4', 'python-mechanize', 'add-apt-key', 'python-html5lib',
'python-pkg-resources', 'python-webencodings', 'python-chardet', 'python-lxml',
'python-six', 'grub'])
with open("apps-to-remove", "w") as output, open("installed", "r") as installed, \
open(self.manifest, "r") as pman:
diff = set(installed).difference(pman)
Expand All @@ -550,7 +546,6 @@ def showInstalled(self):
viewInstalled.show()
QtGui.QApplication.restoreOverrideCursor()


def getLocalUserList(self):
try:
self.logger.info("getting local users...")
Expand Down Expand Up @@ -591,7 +586,6 @@ def center(self):
frameGm.moveCenter(centerPoint)
self.move(frameGm.topLeft())


if __name__ == '__main__':
key = 'Resetter'
app = SingleApplication(sys.argv, key)
Expand Down
Loading

0 comments on commit d77feaa

Please sign in to comment.