Skip to content

Commit

Permalink
Gui - srpm build process is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
regeciovad committed Oct 26, 2015
1 parent 8ee5c77 commit 9268e11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
6 changes: 5 additions & 1 deletion rpg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,17 @@ def write_spec(self):
with open(str(self.spec_path), 'w') as spec_file:
spec_file.write(str(self.spec))

def build_srpm(self):
def build_srpm(self, path=None):
""" Builds srpm into base directory. """
if not self.spec.Source or not self.archive_path.exists():
self.create_archive()
self.write_spec()
self._package_builder.build_srpm(
self.spec_path, self.archive_path, self.base_dir)
if path:
Command("cp " + path_to_str(self.srpm_path) + " " +
str(path)).execute()
print ('SRPM pakcage was created.')

def build_rpm(self, target_distro, target_arch):
""" Build rpm from srpm. If srpm does not exists,
Expand Down
40 changes: 34 additions & 6 deletions rpg/gui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtWidgets import (QLabel, QVBoxLayout, QLineEdit, QCheckBox,
QGroupBox, QPushButton, QGridLayout,
QTextEdit, QFileDialog,
QTextEdit, QFileDialog, QDialog,
QComboBox, QWizard, QFrame)
from rpg.gui.dialogs import DialogImport
from rpg.utils import path_to_str
from pathlib import Path
from rpg.command import Command
import subprocess
import platform
from threading import Thread
from rpg.gui.thread import ThreadWrapper


class Wizard(QtWidgets.QWizard):
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(self, base, parent=None):
self.setPage(self.PageCoprDistro, CoprDistroPage(self))
self.setPage(self.PageCoprBuild, CoprBuildPage(self))
self.setPage(self.PageCoprFinal, CoprFinalPage(self))
self.setStartId(self.PageIntro)
self.setStartId(self.PageImport)


class IntroPage(QtWidgets.QWizardPage):
Expand Down Expand Up @@ -1022,10 +1022,38 @@ def openBuildPathFileDialog(self):
def buildSrpm(self):
self.textBuildSRPMLabel.setText('Building SRPM...')
self.textBuildSRPMLabel.repaint()
self.base.build_srpm()
Command("cp " + path_to_str(self.base.srpm_path) + " " +
self.buildLocationEdit.text()).execute()
self.base.final_path = self.buildLocationEdit.text()

self.srpm_dialog = QDialog(self)
self.srpm_dialog.resize(600, 400)
self.srpm_dialog.setWindowTitle('Building SRPM')
self.srpm_progress = QTextEdit()
self.srpm_progress.setReadOnly(True)
self.srpm_progress.setText('Building SRPM...')
self.cancelButton = QPushButton('Cancel')
self.cancelButton.setMinimumHeight(45)
self.cancelButton.setMaximumHeight(45)
self.cancelButton.setMinimumWidth(100)
self.cancelButton.setMaximumWidth(115)
self.cancelButton.clicked.connect(self.CancelSRPM)
mainLayout = QVBoxLayout()
mainLayout.addSpacing(50)
mainLayout.addWidget(self.srpm_progress)
mainLayout.addSpacing(50)
grid = QGridLayout()
grid.addWidget(self.cancelButton)
mainLayout.addLayout(grid)
self.srpm_dialog.setLayout(mainLayout)

self.srpm_dialog.show()
self.srpm_process = ThreadWrapper(self.srpm_progress,
self.base.build_srpm,
self.base.final_path)
self.srpm_process.run()

def CancelSRPM(self):
self.srpm_dialog.close()
self.srpm_process.kill()
self.textBuildSRPMLabel.setText('Your source package was build in '
+ self.base.final_path)

Expand Down

0 comments on commit 9268e11

Please sign in to comment.