00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 import gettext
00029 import os
00030 import sys
00031 import optparse
00032
00033 import Debug
00034 from Settings import *
00035 from Koo import Rpc
00036
00037 from PyQt4.QtCore import QDir, QUrl
00038
00039 def homeDirectory():
00040 return unicode(QDir.toNativeSeparators(QDir.homePath()))
00041
00042 def parseArguments(args):
00043 parser = optparse.OptionParser()
00044 parser.add_option("-d", "--database", dest="database", help=_("specify database"))
00045 parser.add_option("-c", "--config", dest="config", help=_("specify alternate config file"))
00046 parser.add_option("-u", "--url", dest="url", help=_("specify the server (ie. http://admin@localhost:8069)"))
00047 parser.add_option("", "--stylesheet", dest="stylesheet", default=None, help=_("specify stylesheet to apply"))
00048 parser.add_option("", "--pos-mode", action="store_true", default=None, dest="pos_mode", help=_("use POS (Point of Sales) mode"))
00049 parser.add_option("", "--enter-as-tab", action="store_true", default=None, dest="enter_as_tab", help=_("replace enter/return keys with tab hits"))
00050 parser.add_option("", "--disable-kde", action="store_true", default=None, dest="disable_kde", help=_("disable usage of KDE libraries if they are available"))
00051 parser.add_option("", "--debug", action="store_true", default=None, dest="debug", help=_("enable debug mode. Will show the crash dialog in all exceptions"))
00052
00053
00054 (opt, args) = parser.parse_args(args)
00055
00056 Settings.rcFile = opt.config or os.environ.get('TERPRC') or os.path.join(homeDirectory(), '.koorc')
00057 Settings.loadFromFile()
00058 Settings.loadFromRegistry()
00059
00060
00061 if opt.url:
00062 Settings.setValue( 'login.url', opt.url )
00063 if Settings.value( 'login.url' ):
00064 url = QUrl( Settings.value('login.url' ) )
00065 if not opt.stylesheet is None:
00066 Settings.setValue( 'koo.stylesheet', opt.stylesheet )
00067 if not opt.pos_mode is None:
00068 Settings.setValue( 'koo.pos_mode', opt.pos_mode )
00069 if not opt.enter_as_tab is None:
00070 Settings.setValue( 'koo.enter_as_tab', opt.enter_as_tab )
00071 if not opt.debug is None:
00072 Settings.setValue( 'client.debug', opt.debug )
00073 if not opt.disable_kde is None:
00074 Settings.setValue( 'kde.enabled', False )
00075 if not opt.database is None:
00076 Settings.setValue( 'login.db', opt.database )
00077 return args
00078