diff --git a/CHANGELOG b/CHANGELOG index e67b3bd..08b45d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ - Forces relations to have correct names for attributes - Colored output in readline mode - Can send email in survery +- Can check for new version online 1.0 - Adds history in the GUI diff --git a/relational/maintenance.py b/relational/maintenance.py new file mode 100644 index 0000000..dc6ed20 --- /dev/null +++ b/relational/maintenance.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Relational +# Copyright (C) 2008 Salvo "LtWorf" Tomaselli +# +# Relation is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# author Salvo "LtWorf" Tomaselli +# +# Stuff non-related to relational algebra, but used for maintenance. + +import httplib +import urllib + +def send_survey(data): + '''Sends the survey. Data must be a dictionary. + returns the http response''' + + post='' + for i in data.keys(): + post+='%s: %s\n' %(i,data[i]) + + #sends the string + params = urllib.urlencode({'survey':post}) + headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} + connection = httplib.HTTPConnection('galileo.dmi.unict.it') + connection.request("POST","/~ltworf/survey.php",params,headers) + return connection.getresponse() + + +def check_latest_version(): + '''Returns the latest version available. + Heavely dependent on server and server configurations + not granted to work forever.''' + connection = httplib.HTTPConnection('galileo.dmi.unict.it') + connection.request("GET","/svn/relational/tags/") + r=connection.getresponse() + + #html + s=r.read() + + l= s[s.find('')].split('\n') + l.sort() + a=l[len(l)-1] + + s=a.find('"')+1 + return a[s:a.find('"',s)-1] \ No newline at end of file diff --git a/relational_gui.py b/relational_gui.py index 5afe929..a0fb921 100755 --- a/relational_gui.py +++ b/relational_gui.py @@ -91,6 +91,7 @@ if __name__ == "__main__": about.version=version surveyForm.version=version + guihandler.version=version app = QtGui.QApplication(sys.argv) @@ -122,5 +123,6 @@ if __name__ == "__main__": except: print >> sys.stderr, "Module relational_readline is missing.\nPlease install relational-cli package." sys.exit(3) + relational_readline.linegui.version=version relational_readline.linegui.main(files) diff --git a/relational_gui/guihandler.py b/relational_gui/guihandler.py index 4debaa4..ffa0b78 100644 --- a/relational_gui/guihandler.py +++ b/relational_gui/guihandler.py @@ -37,6 +37,19 @@ class relForm(QtGui.QMainWindow): self.selectedRelation=None self.ui=ui self.qcounter=1 #Query counter + def checkVersion(self): + from relational import maintenance + online=maintenance.check_latest_version() + + if online>version: + r=QtGui.QApplication.translate("Form", "New version available online: %s." % online) + elif online==version: + r=QtGui.QApplication.translate("Form", "Latest version installed.") + else: + r=QtGui.QApplication.translate("Form", "You are using an unstable version.") + + QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Version"),r) + def load_query(self,*index): self.ui.txtQuery.setText(self.savedQ.itemData(index[0]).toString()) diff --git a/relational_gui/maingui.py b/relational_gui/maingui.py index a6e5e8a..7b3a537 100644 --- a/relational_gui/maingui.py +++ b/relational_gui/maingui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'maingui.ui' # -# Created: Mon Mar 21 00:21:36 2011 +# Created: Tue Jun 14 18:13:03 2011 # by: PyQt4 UI code generator 4.8.3 # # WARNING! All changes made in this file will be lost! @@ -227,11 +227,14 @@ class Ui_MainWindow(object): self.action_Quit = QtGui.QAction(MainWindow) self.action_Quit.setMenuRole(QtGui.QAction.QuitRole) self.action_Quit.setObjectName(_fromUtf8("action_Quit")) + self.actionCheck_for_new_versions = QtGui.QAction(MainWindow) + self.actionCheck_for_new_versions.setObjectName(_fromUtf8("actionCheck_for_new_versions")) self.menuFile.addAction(self.action_Load_relation) self.menuFile.addAction(self.action_Save_relation) self.menuFile.addSeparator() self.menuFile.addAction(self.action_Quit) self.menuAbout.addAction(self.actionAbout) + self.menuAbout.addAction(self.actionCheck_for_new_versions) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuAbout.menuAction()) self.label.setBuddy(self.txtQuery) @@ -272,6 +275,7 @@ class Ui_MainWindow(object): QtCore.QObject.connect(self.action_Load_relation, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.loadRelation) QtCore.QObject.connect(self.action_Save_relation, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.saveRelation) QtCore.QObject.connect(self.action_Quit, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.close) + QtCore.QObject.connect(self.actionCheck_for_new_versions, QtCore.SIGNAL(_fromUtf8("triggered()")), MainWindow.checkVersion) QtCore.QMetaObject.connectSlotsByName(MainWindow) MainWindow.setTabOrder(self.cmdAbout, self.cmdSurvey) MainWindow.setTabOrder(self.cmdSurvey, self.cmdProduct) @@ -347,4 +351,5 @@ class Ui_MainWindow(object): self.action_Save_relation.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+S", None, QtGui.QApplication.UnicodeUTF8)) self.action_Quit.setText(QtGui.QApplication.translate("MainWindow", "&Quit", None, QtGui.QApplication.UnicodeUTF8)) self.action_Quit.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+Q", None, QtGui.QApplication.UnicodeUTF8)) + self.actionCheck_for_new_versions.setText(QtGui.QApplication.translate("MainWindow", "Check for new versions", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/relational_gui/maingui.ui b/relational_gui/maingui.ui index 2f27fe6..b8f26dd 100644 --- a/relational_gui/maingui.ui +++ b/relational_gui/maingui.ui @@ -444,6 +444,7 @@ + @@ -483,6 +484,11 @@ QAction::QuitRole + + + Check for new versions + + cmdAbout @@ -1079,9 +1085,26 @@ + + actionCheck_for_new_versions + triggered() + MainWindow + checkVersion() + + + -1 + -1 + + + 399 + 305 + + + execute() + checkVersion() showAbout() showSurvey() addProduct() diff --git a/relational_gui/surveyForm.py b/relational_gui/surveyForm.py index 119a6ea..4ffd01e 100644 --- a/relational_gui/surveyForm.py +++ b/relational_gui/surveyForm.py @@ -18,8 +18,7 @@ # author Salvo "LtWorf" Tomaselli from PyQt4 import QtCore, QtGui -import httplib -import urllib +from relational import maintenance import platform import locale @@ -53,16 +52,17 @@ class surveyForm (QtGui.QWidget): pass def send(self): '''Sends the data inserted in the form''' - #Creates the string - post="Relational algebra\n" - post+="version: " + version + "\n" - post+="system:" + str(self.ui.txtSystem.text().toUtf8())+ "\n" - post+="country:" + str(self.ui.txtCountry.text().toUtf8())+ "\n" - post+="school:" + str(self.ui.txtSchool.text().toUtf8())+ "\n" - post+="age:" + str(self.ui.txtAge.text().toUtf8())+ "\n" - post+="find:" + str(self.ui.txtFind.text().toUtf8())+ "\n" - post+="email:" + str(self.ui.txtEmail.text().toUtf8())+"\n" - post+="comments:" + str(self.ui.txtComments.toPlainText().toUtf8()) + + post={} + post['software']="Relational algebra" + post["version"]= version + post["system"]= str(self.ui.txtSystem.text().toUtf8()) + post["country"]= str(self.ui.txtCountry.text().toUtf8()) + post["school"]= str(self.ui.txtSchool.text().toUtf8()) + post["age"] = str(self.ui.txtAge.text().toUtf8()) + post["find"] = str(self.ui.txtFind.text().toUtf8()) + post["email"] =str(self.ui.txtEmail.text().toUtf8()) + post["comments"] = str(self.ui.txtComments.toPlainText().toUtf8()) #Clears the form self.ui.txtSystem.clear() @@ -72,13 +72,9 @@ class surveyForm (QtGui.QWidget): self.ui.txtFind.clear() self.ui.txtEmail.clear() self.ui.txtComments.clear() + + response=maintenance.send_survey(post) - #sends the string - params = urllib.urlencode({'survey':post}) - headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} - connection = httplib.HTTPConnection('galileo.dmi.unict.it') - connection.request("POST","/~ltworf/survey.php",params,headers) - response=connection.getresponse() if response.status!=200: QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Unable to send the data!") ) else: diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index 005bb35..5e47231 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -93,7 +93,7 @@ class SimpleCompleter(object): relations={} -completer=SimpleCompleter(['LIST','LOAD ','UNLOAD ','HELP ','QUIT','SAVE ','_PRODUCT ','_UNION ','_INTERSECTION ','_DIFFERENCE ','_JOIN ','_LJOIN ','_RJOIN ','_FJOIN ','_PROJECTION ','_RENAME_TO ','_SELECTION ','_RENAME ','_DIVISION ']) +completer=SimpleCompleter(['SURVEY','LIST','LOAD ','UNLOAD ','HELP ','QUIT','SAVE ','_PRODUCT ','_UNION ','_INTERSECTION ','_DIFFERENCE ','_JOIN ','_LJOIN ','_RJOIN ','_FJOIN ','_PROJECTION ','_RENAME_TO ','_SELECTION ','_RENAME ','_DIVISION ']) def load_relation(filename,defname=None): if not os.path.isfile(filename): @@ -119,6 +119,18 @@ def load_relation(filename,defname=None): print >>sys.stderr,colored(e,'red') return None +def survey(): + '''performs a survey''' + from relational import maintenance + + post= {'software':'Relational algebra (cli)','version':version} + + fields=('System','Country','School','Age','How did you find','email (only if you want a reply)','Comments') + for i in fields: + a=raw_input('%s: '%i) + post[i]=a + maintenance.send_survey(post) + def help(command): '''Prints help on the various functions''' p=command.split(' ',1) @@ -146,6 +158,8 @@ def help(command): print "Saves a relation in a file" elif cmd=='HELP': print "Prints the help on a command" + elif cmd=='SURVEY': + print "Fill and send a survey" else: print "Unknown command: %s" %cmd @@ -163,6 +177,8 @@ def exec_line(command): for i in relations: if not i.startswith('_'): print i + elif command=='SURVEY': + survey() elif command.startswith('LOAD '): #Loads a relation pars=command.split(' ') if len(pars)==1: