diff --git a/rpg/__init__.py b/rpg/__init__.py index 9d3e2bb..c6fe7c9 100644 --- a/rpg/__init__.py +++ b/rpg/__init__.py @@ -222,15 +222,16 @@ def write_spec(self): def build_srpm(self, path=None): """ Builds srpm into base directory. """ + print('Building SRPM...') if not self.spec.Source or not self.archive_path.exists(): self.create_archive() self.write_spec() + print('Spec file created.') 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, path=None): """ Build rpm from srpm. If srpm does not exists, @@ -282,6 +283,23 @@ def build_project(self): self.compiled_dir, self.spec.build) + def copr_create_and_build(self, name, chroots, desc, intro, url): + print("Creating new project...") + try: + self.copr_create_project(name, chroots, desc, intro) + except: + print("Error in creating project! Please check your login.") + return + print("Creating new project - DONE") + print("Build proccess started...") + print("It takes a while, but it may be safely interrupted.") + try: + self.copr_build(name, url) + except: + print("Error in building project! Please check your url.") + return + print("Building new project - DONE") + def copr_set_config(self, username, login, token): """ Logs into copr with username, login and token. This has to be called before copr_create_project and copr_build diff --git a/rpg/gui/thread.py b/rpg/gui/thread.py index c30b5ad..5f09fce 100644 --- a/rpg/gui/thread.py +++ b/rpg/gui/thread.py @@ -60,3 +60,4 @@ def writer(self): """ Appends output from function to the GUI widget. """ while self._process.is_alive(): self._widget.appendPlainText(self._queue.get()) + self._widget.repaint() diff --git a/rpg/gui/wizard.py b/rpg/gui/wizard.py index 077159c..bebafb4 100644 --- a/rpg/gui/wizard.py +++ b/rpg/gui/wizard.py @@ -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.PageCoprLogin) class IntroPage(QtWidgets.QWizardPage): @@ -1049,7 +1049,6 @@ def buildSrpm(self): self.srpm_dialog.setWindowTitle('Building SRPM') self.srpm_progress = QPlainTextEdit() self.srpm_progress.setReadOnly(True) - self.srpm_progress.insertPlainText('Building SRPM...') self.cancelButton = QPushButton('Cancel') self.cancelButton.setMinimumHeight(45) self.cancelButton.setMaximumHeight(45) @@ -1057,9 +1056,9 @@ def buildSrpm(self): self.cancelButton.setMaximumWidth(115) self.cancelButton.clicked.connect(self.CancelSRPM) mainLayout = QVBoxLayout() - mainLayout.addSpacing(50) + mainLayout.addSpacing(40) mainLayout.addWidget(self.srpm_progress) - mainLayout.addSpacing(50) + mainLayout.addSpacing(40) grid = QGridLayout() grid.addWidget(self.cancelButton) mainLayout.addLayout(grid) @@ -1095,9 +1094,9 @@ def buildRpm(self): self.cancelButton.setMaximumWidth(115) self.cancelButton.clicked.connect(self.CancelRPM) mainLayout = QVBoxLayout() - mainLayout.addSpacing(50) + mainLayout.addSpacing(40) mainLayout.addWidget(self.rpm_progress) - mainLayout.addSpacing(50) + mainLayout.addSpacing(40) grid = QGridLayout() grid.addWidget(self.cancelButton) mainLayout.addLayout(grid) @@ -1381,8 +1380,6 @@ def __init__(self, Wizard, parent=None): self.setTitle(self.tr(" Copr build page")) self.setSubTitle(self.tr("Copr additional information")) - self.textBuildLabel = QLabel() - self.packageDescLabel = QLabel("Description ") self.packageDescEdit = QPlainTextEdit() self.packageDescLabelText = QLabel( @@ -1403,8 +1400,6 @@ def __init__(self, Wizard, parent=None): frameDesc.setFrameShadow(QFrame.Sunken) frameInstuction.setFrameShape(QFrame.Panel) frameInstuction.setFrameShadow(QFrame.Sunken) - gridBuildText = QGridLayout() - gridBuildText.addWidget(self.textBuildLabel, 0, 1, 1, 1) gridDesc = QGridLayout() gridInstuction = QGridLayout() @@ -1415,59 +1410,63 @@ def __init__(self, Wizard, parent=None): gridInstuction.addWidget(self.packageInstuctionEdit, 0, 1, 1, 8) gridInstuction.addWidget(self.packageInstuctionLabelText, 1, 0, 1, 8) + self.coprBuildButton = QPushButton('Build package with Copr') + self.coprBuildButton.setMinimumHeight(45) + self.coprBuildButton.setMaximumHeight(45) + self.coprBuildButton.setMinimumWidth(200) + self.coprBuildButton.setMaximumWidth(205) + self.coprBuildButton.clicked.connect(self.buildCopr) + mainLayout.addSpacing(25) frameDesc.setLayout(gridDesc) frameInstuction.setLayout(gridInstuction) - mainLayout.addLayout(gridBuildText) mainLayout.addWidget(frameDesc) mainLayout.addSpacing(15) mainLayout.addWidget(frameInstuction) mainLayout.addSpacing(15) + mainLayout.addWidget(self.coprBuildButton, 0, QtCore.Qt.AlignCenter) self.setLayout(mainLayout) def validatePage(self): - QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) - self.textBuildLabel.setText( - "
" + - "Creating new project..." + - "
") - self.textBuildLabel.repaint() + return True + + def buildCopr(self): + self.copr_dialog = QDialog(self) + self.copr_dialog.resize(600, 400) + self.copr_dialog.setWindowTitle('Building Copr') + self.copr_progress = QPlainTextEdit() + self.copr_progress.setReadOnly(True) + 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.CancelCopr) + mainLayout = QVBoxLayout() + mainLayout.addSpacing(40) + mainLayout.addWidget(self.copr_progress) + mainLayout.addSpacing(40) + grid = QGridLayout() + grid.addWidget(self.cancelButton) + mainLayout.addLayout(grid) + self.copr_dialog.setLayout(mainLayout) + + self.copr_dialog.show() self.base.coprdesc = self.packageDescEdit.toPlainText() self.base.coprintro = self.packageInstuctionEdit.toPlainText() - try: - self.base.copr_create_project(self.base.coprpackageName, + + self.copr_process = ThreadWrapper(self.copr_progress, + self.base.copr_create_and_build, + self.base.coprpackageName, self.base.coprversion, self.base.coprdesc, - self.base.coprintro) - except subprocess.CalledProcessError: - self.textBuildLabel.setText( - "" +
- "Error in creating project!" +
- "
Please check your log in information" +
- "
" +
- "Creating new project - DONE
" +
- "Build proccess started...
" +
- "It takes a while, but it may be safely interrupted."
- "
" +
- "Error in building project!" +
- "
Please check your url information" +
- "