Skip to content

Commit

Permalink
Gui - fix: import url added
Browse files Browse the repository at this point in the history
  • Loading branch information
regeciovad committed Mar 9, 2016
1 parent c8a5572 commit 5035702
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions rpg/gui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rpg.command import Command
import subprocess
import platform
import urllib.request
from threading import Thread
from rpg.gui.thread import ThreadWrapper

Expand Down Expand Up @@ -202,12 +203,7 @@ def __init__(self, Wizard, parent=None):
self.setLayout(mainLayout)

def checkPath(self):
''' Checks, if path to import is correct while typing'''
path = Path(self.importEdit.text())
if(path.exists()):
self.importEdit.setStyleSheet("")
else:
self.importEdit.setStyleSheet(self.redQLineEdit)
self.importEdit.setStyleSheet("")

def importPath(self):
''' Returns path selected file or archive'''
Expand All @@ -230,21 +226,26 @@ def validatePage(self):
###### Setting up RPG class references ###### '''

# Verifying path
QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
path = Path(self.importEdit.text())
if(path.exists()):
self.base.target_arch = self.ArchEdit.currentText()
self.base.target_distro = self.DistroEdit.currentText()
self.base.load_project_from_url(self.importEdit.text().strip())
self.base.run_extracted_source_analysis()
self.new_thread = Thread(
target=self.base.fetch_repos, args=(self.base.target_distro,
self.base.target_arch))
self.new_thread.start()
self.importEdit.setStyleSheet("")
return True
else:
self.importEdit.setStyleSheet(self.redQLineEdit)
return False
if not (path.exists()):
urlpath = self.importEdit.text()
try:
urllib.request.urlopen(urlpath)
except:
self.importEdit.setStyleSheet(self.redQLineEdit)
QApplication.restoreOverrideCursor()
return False
self.base.target_arch = self.ArchEdit.currentText()
self.base.target_distro = self.DistroEdit.currentText()
self.base.load_project_from_url(self.importEdit.text().strip())
self.base.run_extracted_source_analysis()
self.new_thread = Thread(
target=self.base.fetch_repos, args=(self.base.target_distro,
self.base.target_arch))
self.new_thread.start()
self.importEdit.setStyleSheet("")
return True

def cleanupPage(self):
""" Stops the thread (there are no official way to stop thread.
Expand All @@ -271,6 +272,7 @@ def initializePage(self):
self.releaseEdit.setText("1")
self.licenseEdit.setText(str(self.base.spec.License))
self.URLEdit.setText(str(self.base.spec.URL))
QApplication.restoreOverrideCursor()

def __init__(self, Wizard, parent=None):
super(MandatoryPage, self).__init__(parent)
Expand Down

0 comments on commit 5035702

Please sign in to comment.