- Uses getopt to handle the command line in a more standard way
- Organized code so the ui can be either qt or curses git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@223 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
c282873c17
commit
f1018b20f8
@ -100,3 +100,5 @@
|
|||||||
- Automatically fills some fields in the survey (Rev 217)
|
- Automatically fills some fields in the survey (Rev 217)
|
||||||
- When a query fails, shows the message of the exception (Rev220)
|
- When a query fails, shows the message of the exception (Rev220)
|
||||||
- Improved tokenizer for select in optimizations, now can accept operators in identifiers (Rev220)
|
- Improved tokenizer for select in optimizations, now can accept operators in identifiers (Rev220)
|
||||||
|
- Uses getopt to handle the command line in a more standard way
|
||||||
|
- Organized code so the ui can be either qt or curses
|
@ -21,50 +21,84 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import sip
|
import getopt
|
||||||
from PyQt4 import QtCore, QtGui
|
|
||||||
from relational_gui import maingui, about
|
|
||||||
from relational import relation, parser
|
from relational import relation, parser
|
||||||
|
|
||||||
version="0.11"
|
version="0.11"
|
||||||
about.version=version
|
|
||||||
|
|
||||||
|
def printver():
|
||||||
|
print "Relational"
|
||||||
|
print "This program comes with ABSOLUTELY NO WARRANTY."
|
||||||
|
print "This is free software, and you are welcome to redistribute it"
|
||||||
|
print "under certain conditions."
|
||||||
|
print "For details see the GPLv3 Licese."
|
||||||
|
print
|
||||||
|
print "Version: %s"%version
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def printhelp(code=0):
|
||||||
|
print "Relational"
|
||||||
|
print
|
||||||
|
print "Usage: %s [options] [files]" % sys.argv[0]
|
||||||
|
print
|
||||||
|
print " -v Print version and exits"
|
||||||
|
print " -h Print this help and exits"
|
||||||
|
print " -q Uses QT user interface (default)"
|
||||||
|
print " -c Uses curses user interface"
|
||||||
|
sys.exit(code)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len (sys.argv) > 1 and sys.argv[1] == "-v":
|
x11=True #Will try to use the x11 interface
|
||||||
|
|
||||||
print "Relational"
|
|
||||||
print "This program comes with ABSOLUTELY NO WARRANTY."
|
|
||||||
print "This is free software, and you are welcome to redistribute it"
|
|
||||||
print "under certain conditions."
|
|
||||||
print "For details see the GPLv3 Licese."
|
|
||||||
print
|
|
||||||
print "Version: %s"%version
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
#Try to run the psyco optimizer
|
||||||
try:
|
try:
|
||||||
import psyco
|
import psyco
|
||||||
psyco.full()
|
psyco.full()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
app = QtGui.QApplication(sys.argv)
|
|
||||||
Form = QtGui.QWidget()
|
|
||||||
|
|
||||||
if os.name=='nt':
|
#Getting command line
|
||||||
Form.setFont(QtGui.QFont("Dejavu Sans Bold"))
|
try:
|
||||||
|
switches,files=getopt.getopt(sys.argv[1:],"vhqc")
|
||||||
|
except:
|
||||||
|
printhelp(1)
|
||||||
|
|
||||||
ui = maingui.Ui_Form()
|
for i in switches:
|
||||||
ui.setupUi(Form)
|
if i[0]=='-v':
|
||||||
|
printver()
|
||||||
for i in range(1,len(sys.argv)):
|
elif i[0]=='-h':
|
||||||
f=sys.argv[i].split('/')
|
printhelp()
|
||||||
defname=f[len(f)-1].lower()
|
elif i[0]=='-q':
|
||||||
if (defname.endswith(".csv") or defname.endswith(".tlb")): #removes the extension
|
x11=True
|
||||||
defname=defname[:-4]
|
elif i[0]=='-c':
|
||||||
print 'Loading file "%s" with name "%s"' % (sys.argv[i],defname)
|
x11=False
|
||||||
ui.loadRelation(sys.argv[i],defname)
|
|
||||||
|
|
||||||
|
|
||||||
Form.show()
|
if x11:
|
||||||
|
import sip
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
from relational_gui import maingui, about
|
||||||
|
about.version=version
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
Form = QtGui.QWidget()
|
||||||
|
|
||||||
|
if os.name=='nt':
|
||||||
|
Form.setFont(QtGui.QFont("Dejavu Sans Bold"))
|
||||||
|
|
||||||
|
ui = maingui.Ui_Form()
|
||||||
|
ui.setupUi(Form)
|
||||||
|
|
||||||
|
for i in range(len(files)):
|
||||||
|
f=files[i].split('/')
|
||||||
|
defname=f[len(f)-1].lower()
|
||||||
|
if (defname.endswith(".csv") or defname.endswith(".tlb")): #removes the extension
|
||||||
|
defname=defname[:-4]
|
||||||
|
print 'Loading file "%s" with name "%s"' % (files[i],defname)
|
||||||
|
ui.loadRelation(files[i],defname)
|
||||||
|
|
||||||
|
Form.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
else: #TODO load with curses interface
|
||||||
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user