- Can perform survey from command line interface too
- Module to send survey directly - Can check the latest version from the svn repository git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@311 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
d6a3309014
commit
fb7e9d2b6f
@ -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
|
||||
|
57
relational/maintenance.py
Normal file
57
relational/maintenance.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
||||
#
|
||||
# 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('<ul>')+4:s.find('</ul>')].split('\n')
|
||||
l.sort()
|
||||
a=l[len(l)-1]
|
||||
|
||||
s=a.find('"')+1
|
||||
return a[s:a.find('"',s)-1]
|
@ -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)
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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))
|
||||
|
||||
|
@ -444,6 +444,7 @@
|
||||
</property>
|
||||
<action name=""/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionCheck_for_new_versions"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuAbout"/>
|
||||
@ -483,6 +484,11 @@
|
||||
<enum>QAction::QuitRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCheck_for_new_versions">
|
||||
<property name="text">
|
||||
<string>Check for new versions</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>cmdAbout</tabstop>
|
||||
@ -1079,9 +1085,26 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionCheck_for_new_versions</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>checkVersion()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>305</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>execute()</slot>
|
||||
<slot>checkVersion()</slot>
|
||||
<slot>showAbout()</slot>
|
||||
<slot>showSurvey()</slot>
|
||||
<slot>addProduct()</slot>
|
||||
|
@ -18,8 +18,7 @@
|
||||
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
||||
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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user