Browse Source

code cleanups

master
Hussar 5 years ago
parent
commit
983b66b20d
2 changed files with 2 additions and 35 deletions
  1. BIN
      .update.py.swp
  2. +2
    -35
      update.py

BIN
.update.py.swp View File


+ 2
- 35
update.py View File

@@ -10,7 +10,7 @@ from PySide2.QtWidgets import (QApplication, QLabel,
from PySide2.QtCore import (Qt, QThread, Signal, QDir, QProcess, from PySide2.QtCore import (Qt, QThread, Signal, QDir, QProcess,
QCoreApplication) QCoreApplication)
from PySide2.QtGui import (QIcon, QMovie) from PySide2.QtGui import (QIcon, QMovie)
import sys, subprocess, trio, io import sys, subprocess, trio


class UpdatePrompt(QDialog): class UpdatePrompt(QDialog):


@@ -68,26 +68,16 @@ class UpdatePrompt(QDialog):
return return


async def upProc(self, password, cmd, finishedState): async def upProc(self, password, cmd, finishedState):
# proc = subprocess.Popen(['sudo', '-S', 'apt-get', cmd, '-y'],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT,
# stdin=subprocess.PIPE)

proc = await trio.open_process(['sudo', '-S', 'apt-get', cmd, '-y'], proc = await trio.open_process(['sudo', '-S', 'apt-get', cmd, '-y'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
await proc.stdin.send_all((password + '\n').encode()) await proc.stdin.send_all((password + '\n').encode())


result = ''
while (proc.poll() == None): while (proc.poll() == None):
QCoreApplication.processEvents() QCoreApplication.processEvents()
await trio.sleep(0.1) await trio.sleep(0.1)
#a = await proc.stdout.receive_some()
#a = a.decode()
#print(a)
#result = result + a


#stdout = result.stdout.decode() result = ''
result = await self.pullOutput(proc) result = await self.pullOutput(proc)
self.appendToOutput(result) self.appendToOutput(result)
proc.terminate() proc.terminate()
@@ -95,11 +85,6 @@ class UpdatePrompt(QDialog):
if (cmd == 'update'): if (cmd == 'update'):
await self.upProc(password, 'upgrade', finishedState) await self.upProc(password, 'upgrade', finishedState)
finishedState.set() finishedState.set()

return

async def pseudoSleep(self, intervals):
i = 0
return return


async def pullOutput(self, proc): async def pullOutput(self, proc):
@@ -138,24 +123,6 @@ class UpdatePrompt(QDialog):
self.passError('The password field cannot be empty') self.passError('The password field cannot be empty')
return return



# password = password.encode()
# result = subprocess.run(['sudo', '-S', 'apt-get', 'update'],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT, input=password)
# result = subprocess.run(['sudo', '-S', 'apt-get', 'upgrade', '-y'],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT, input=password)
# stdout = result.stdout.decode()
# currentText = self.outputBox.toPlainText()
# self.outputBox.setText(currentText + '\nRunning upgrades\n' + stdout)
# result = subprocess.run(['sudo', 'apt', 'upgrade', '-y'],
# stdout=subprocess.PIPE,
# stderr=subprocess.STDOUT, input=password)
# currentText = self.outputBox.toPlainText()
# self.outputBox.setText(currentText + '\n' + stdout)

#self.refreshIcon.stop()
trio.run(self.asetup, password) trio.run(self.asetup, password)
self.centStack.setCurrentIndex(1) self.centStack.setCurrentIndex(1)
self.refreshIcon.stop() self.refreshIcon.stop()


||||||
x
 
000:0
Loading…
Cancel
Save