2015-02-19 05:42:41 +07:00
|
|
|
#!/usr/bin/env python3
|
2008-07-24 10:08:55 +07:00
|
|
|
# Relational
|
|
|
|
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
|
2013-12-26 17:31:43 +07:00
|
|
|
#
|
2010-02-23 18:46:58 +07:00
|
|
|
# Relational is free software: you can redistribute it and/or modify
|
2008-07-24 10:08:55 +07:00
|
|
|
# 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.
|
2013-12-26 17:31:43 +07:00
|
|
|
#
|
2008-07-24 10:08:55 +07:00
|
|
|
# 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.
|
2013-12-26 17:31:43 +07:00
|
|
|
#
|
2008-07-24 10:08:55 +07:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-12-26 17:31:43 +07:00
|
|
|
#
|
2008-07-24 10:08:55 +07:00
|
|
|
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
|
2008-07-23 08:20:49 +07:00
|
|
|
|
|
|
|
import sys
|
2009-07-05 17:26:51 +07:00
|
|
|
import os
|
2010-06-21 07:33:43 +07:00
|
|
|
import os.path
|
2010-03-21 07:55:32 +07:00
|
|
|
import getopt
|
2015-06-02 05:35:47 +07:00
|
|
|
|
2015-09-14 18:58:17 +07:00
|
|
|
version = "2.2"
|
2010-03-21 07:55:32 +07:00
|
|
|
|
|
|
|
|
2010-06-21 16:02:47 +07:00
|
|
|
def printver(exit=True):
|
2015-02-19 05:42:41 +07:00
|
|
|
print ("Relational %s" % version)
|
|
|
|
print ("Copyright (C) 2008 Salvo 'LtWorf' Tomaselli.")
|
|
|
|
print ()
|
|
|
|
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 ("Written by Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>")
|
|
|
|
print ()
|
|
|
|
print ("http://ltworf.github.io/relational/")
|
2010-06-21 16:02:47 +07:00
|
|
|
if exit:
|
|
|
|
sys.exit(0)
|
2010-03-21 07:55:32 +07:00
|
|
|
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2010-03-21 07:55:32 +07:00
|
|
|
def printhelp(code=0):
|
2015-02-19 05:42:41 +07:00
|
|
|
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")
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2011-03-04 06:18:22 +07:00
|
|
|
if sys.argv[0].endswith('relational-cli'):
|
2015-02-19 05:42:41 +07:00
|
|
|
print (" -q Uses QT user interface")
|
|
|
|
print (" -r Uses readline user interface (default)")
|
2011-03-04 06:18:22 +07:00
|
|
|
else:
|
2015-02-19 05:42:41 +07:00
|
|
|
print (" -q Uses QT user interface (default)")
|
|
|
|
print (" -r Uses readline user interface")
|
2010-03-21 07:55:32 +07:00
|
|
|
sys.exit(code)
|
2008-07-24 10:08:55 +07:00
|
|
|
|
2008-07-23 08:20:49 +07:00
|
|
|
if __name__ == "__main__":
|
2011-03-04 06:18:22 +07:00
|
|
|
if sys.argv[0].endswith('relational-cli'):
|
2013-12-26 17:31:43 +07:00
|
|
|
x11 = False
|
2011-03-04 06:18:22 +07:00
|
|
|
else:
|
2013-12-26 17:31:43 +07:00
|
|
|
x11 = True # Will try to use the x11 interface
|
|
|
|
|
|
|
|
# Getting command line
|
2010-03-21 07:55:32 +07:00
|
|
|
try:
|
2013-12-26 17:31:43 +07:00
|
|
|
switches, files = getopt.getopt(sys.argv[1:], "vhqr")
|
2010-03-21 07:55:32 +07:00
|
|
|
except:
|
|
|
|
printhelp(1)
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2010-03-21 07:55:32 +07:00
|
|
|
for i in switches:
|
2013-12-26 17:31:43 +07:00
|
|
|
if i[0] == '-v':
|
2010-03-21 07:55:32 +07:00
|
|
|
printver()
|
2013-12-26 17:31:43 +07:00
|
|
|
elif i[0] == '-h':
|
2010-03-21 07:55:32 +07:00
|
|
|
printhelp()
|
2013-12-26 17:31:43 +07:00
|
|
|
elif i[0] == '-q':
|
|
|
|
x11 = True
|
|
|
|
elif i[0] == '-r':
|
|
|
|
x11 = False
|
|
|
|
|
2010-03-21 07:55:32 +07:00
|
|
|
if x11:
|
2015-10-09 04:33:19 +07:00
|
|
|
import signal
|
|
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
|
|
|
2013-12-26 17:56:57 +07:00
|
|
|
import sip # needed on windows
|
2015-11-11 10:02:50 +07:00
|
|
|
from PyQt5 import QtWidgets
|
2011-03-21 02:43:57 +07:00
|
|
|
try:
|
2015-09-29 05:47:20 +07:00
|
|
|
from relational_gui import guihandler, about, surveyForm
|
2011-03-21 02:43:57 +07:00
|
|
|
except:
|
2015-07-14 04:01:35 +07:00
|
|
|
print (
|
2015-09-29 05:47:20 +07:00
|
|
|
"Module relational_gui is missing.\n"
|
|
|
|
"Please install relational package.",
|
2015-07-14 04:01:35 +07:00
|
|
|
file=sys.stderr
|
|
|
|
)
|
2013-12-26 17:56:57 +07:00
|
|
|
sys.exit(3)
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2015-10-09 04:28:54 +07:00
|
|
|
m = zip(files, map(os.path.isfile, files))
|
|
|
|
invalid = ' '.join(
|
|
|
|
(i[0] for i in (filter(lambda x: not x[1], m)))
|
|
|
|
)
|
|
|
|
if invalid:
|
|
|
|
print ("%s: not a file" % invalid, file=sys.stderr)
|
|
|
|
printhelp(12)
|
|
|
|
|
2013-12-26 17:31:43 +07:00
|
|
|
about.version = version
|
|
|
|
surveyForm.version = version
|
|
|
|
guihandler.version = version
|
2009-08-18 06:52:33 +07:00
|
|
|
|
2015-02-19 07:00:47 +07:00
|
|
|
app = QtWidgets.QApplication(sys.argv)
|
2013-12-26 17:31:43 +07:00
|
|
|
app.setOrganizationName('None')
|
|
|
|
app.setApplicationName('relational')
|
2015-05-31 17:02:32 +07:00
|
|
|
app.setOrganizationDomain("None")
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2015-09-29 05:47:20 +07:00
|
|
|
form = guihandler.relForm()
|
2013-12-26 17:31:43 +07:00
|
|
|
|
2015-06-02 05:35:47 +07:00
|
|
|
if len(files):
|
|
|
|
form.loadRelation(files)
|
2010-03-21 07:55:32 +07:00
|
|
|
|
2015-03-12 04:21:01 +07:00
|
|
|
form.show()
|
2010-03-21 07:55:32 +07:00
|
|
|
sys.exit(app.exec_())
|
2010-06-21 12:05:31 +07:00
|
|
|
else:
|
2011-03-21 02:43:57 +07:00
|
|
|
try:
|
|
|
|
import relational_readline.linegui
|
2015-11-06 09:03:58 +07:00
|
|
|
if relational_readline.linegui.TTY:
|
|
|
|
printver(False)
|
2011-03-21 02:43:57 +07:00
|
|
|
except:
|
2015-07-14 04:01:35 +07:00
|
|
|
print (
|
|
|
|
"Module relational_readline is missing.\nPlease install relational-cli package.",
|
|
|
|
file=sys.stderr
|
|
|
|
)
|
2011-03-21 02:43:57 +07:00
|
|
|
sys.exit(3)
|
2013-12-26 17:31:43 +07:00
|
|
|
relational_readline.linegui.version = version
|
2010-06-21 09:30:27 +07:00
|
|
|
relational_readline.linegui.main(files)
|