def pushButtonOkClicked(self):
     date = self.ui.lineEditYear.text()
     isNumber = self.ui.lineEditYear.isEnabled()
     try:
         if isNumber and (int(date) < INITIAL_YEAR or int(date) > FINAL_YEAR):
             util.showErrorMessage(self, 'The year must be a number between ' + str(INITIAL_YEAR) + ' and ' + str(FINAL_YEAR))
         else:
             self.hide()  
     except ValueError:
         util.showErrorMessage(self, 'The year must be a number')
예제 #2
0
 def run(self):
     try:
         req = urllib2.Request(self.url, headers={'User-Agent' : "Magic Browser"}) 
         response = urllib2.urlopen(req)
         self.html = response.read().decode('ascii','ignore')
         self.emit(QtCore.SIGNAL("htmlRead(QString)"), self.html)
     except urllib2.URLError as e:
         print e.reason   
         util.showErrorMessage(self.parent(), 'Incorrect URL or not Internet connection')
     except urllib2.HTTPError as e:
         print e.code
         print e.read()
         util.showErrorMessage(self.parent(), 'Connection error: ' + e.code + ' ' + e.read())   
예제 #3
0
 def addGame(self):
     if self.ui.radioButtonUrl.isChecked():
         self.add_by_url = True
         # Search by URL
         self.url = str(self.ui.lineEditSearch.text()).strip()
         if not re.match(r'^[a-zA-Z]+://', self.url):
             self.url = 'http://' + self.url
         if not self.url.startswith(GAMEFAQS_URL):
             print self.url
             print(GAMEFAQS_URL)
             util.showErrorMessage(self.parent(), 'The URL is not a valid GameFAQs one')
         else:
             # Download the content of the page
              self.launchAddGameWorker()           
     else:
         self.add_by_url = False
         # Search by name
         self.url = SEARCH_URL + str(self.ui.lineEditSearch.text()).replace(' ','+')
         # Download the content of the page
         self.launchAddGameWorker()