Commit 3c238566 authored by Daniel Schulte's avatar Daniel Schulte Committed by osak buildhauer user

Begin porting linuxparty.py away from subprocess.*

parent 4d5d3a14
......@@ -3,9 +3,34 @@
import sys, os, io, subprocess
import json
from PyQt5 import QtWidgets, QtGui, QtCore
import apt
from PyQt5 import QtWidgets, QtGui, QtCore, QtDBus
from collections import OrderedDict
cache = apt.cache.Cache()
def subprocess_wrap(what):
proc = subprocess.Popen(what, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
status = proc.poll()
if status is not None:
break
output = proc.stdout.readline()
if output == '' and status:
break
if output:
print(output.strip().decode('utf-8'))
rc = proc.poll()
print("Subprocess exited with status", rc)
return rc
def get_mountpoint(dev):
iface = QtDBus.QDBusInterface("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2/block_devices/%s"%(dev,), "org.freedesktop.DBus.Properties", QtDBus.QDBusConnection.systemBus())
msg = iface.call("Get", "org.freedesktop.UDisks2.Filesystem", "MountPoints")
mpoint = msg.arguments()[0][0].data().decode('utf-8')[:-1]
print(mpoint)
return mpoint
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
......@@ -83,6 +108,8 @@ class Main(QtWidgets.QMainWindow):
pass
def installProcess():
global pkglist
window.ui.btnl.hide()
window.ui.btnr.setText("&Finish")
window.ui.progressBar.show()
......@@ -128,29 +155,38 @@ def checkIfRoot():
pass
def installPackages(strlist):
command=["echo", "apt-get", "install","--quiet", "-y", "--force-yes"," ".join(strlist)]
#command=["apt-get", "install","--quiet", "-y", "--force-yes"]
#subprocess.call(command, shell=False)
stdout_installPackages = subprocess.check_output(command, shell=False)
print(stdout_installPackages)
global pkglist
cache.update(sources_list='')
cache.open(None)
for pkg in pkglist:
candidate = cache[pkg]
if not candidate.is_installed:
candidate.mark_install()
try:
cache.commit(apt.progress.text.AcquireProgress(), apt.progress.base.InstallProgress())
except Exception as ex:
print("Error during install",ex)
def mountStick():
command=[basepath+"infuse_offline_repo.sh"]
stdout_mountStick = subprocess.check_output(command, shell=False)
print(stdout_mountStick)
command=[basedir+"/infuse_offline_repo.sh"]
subprocess_wrap(command)
def makeDoku(stringlist):
command=["echo", "./makeDoku.sh", os.path.dirname(basepath), " ".join(stringlist)]
#command=["./makeDoku.sh", os.path.dirname(basepath), " ".join(pkglist)]
stdout_makeDoku = subprocess.check_output(command, shell=False)
print(stdout_makeDoku)
global pkglist
#command=["echo", "./makeDoku.sh", basedir, " ".join(stringlist)]
command=["./makeDoku.sh", basedir+"/", " ".join(pkglist)]
subprocess_wrap(command)
def getPackagelist():
installList = []
model = window.ui.tableView.model()
i = 0
while i < model.rowCount():
item = model.item(i)
item.readOnly(true)
if item.isEnabled:
if item.checkState():
installList.append(item.text())
......@@ -210,12 +246,12 @@ def fillTreeView(inputDataJson, treeView):
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
basepath=os.path.realpath(__file__)
basedir=os.path.dirname(basepath)
checkIfRoot()
#mountStick()
window = Main()
window.setWindowTitle("Linux Install Party Software Installer")
with open('../offline_repo.json', 'r') as inputfile:
#with open('./test.json', 'r') as inputfile:
with open(basedir+'/../offline_repo.json', 'r') as inputfile:
data=json.loads(inputfile.read(), object_pairs_hook=OrderedDict)
fillTreeView(data, window.ui.treeView)
window.ui.btnl.clicked.connect(installProcess)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment