Пример #1
0
def process_args(args):
    # Read options from the command line. Return an instance object with the
    # instance variables:
    #	display		name of the X-display or None
    #	geometry	geometry of the main window or None
    #	args		rest of the arguments after the last option
    #
    # To behave more like other X-programs, sketch should accept the options
    # -display and -geometry with a single hyphen and no `='...

    # recognize a standard X geometry specification... (hack)
    if '-geometry' in args:
        try:
            idx = args.index('-geometry')
            geo = args[idx:idx + 2]
            if len(geo) == 2:
                del args[idx:idx + 2]
                geo[0] = '-g'
                args[0:0] = geo
        except:
            pass

    opts, args = getopt.getopt(
        args, 'd:g:hi',
        ['display=', 'geometry=', 'help', 'run-script=', 'version'])
    # the option -i is a hack to allow sketch to be used as a `python
    # interpreter' in the python shell in python-mode.el

    options = util.Empty(args=args,
                         display=None,
                         geometry=None,
                         run_script=None)

    for optchar, value in opts:
        if optchar == '-d' or optchar == '--display':
            options.display = value
        elif optchar == '-g' or optchar == '--geometry':
            options.geometry = value
        elif optchar == '--run-script':
            options.run_script = value
        elif optchar == '-h' or optchar == '--help':
            print Sketch._(usage)
            sys.exit(0)
        elif optchar == '--version':
            print Sketch._(version) % Sketch.SketchVersion
            sys.exit(0)

    return options
Пример #2
0
def main():
    global application

    try:
        options = process_args(sys.argv[1:])
    except getopt.error:
        sys.stderr.write(Sketch._(usage))
        sys.exit(1)

    if options.args:
        filename = options.args[0]
    else:
        filename = ''

    Sketch.init_ui()

    from Sketch.UI.skapp import SketchApplication

    application = SketchApplication(filename,
                                    options.display,
                                    options.geometry,
                                    run_script=options.run_script)

    setattr(Sketch.main, 'application', application)

    Sketch.Issue(None, Sketch.const.APP_INITIALIZED, application)
    application.Run()
    application.SavePreferences()
Пример #3
0
def main():
    global application

    try:
	options = process_args(sys.argv[1:])
    except getopt.error:
	sys.stderr.write(Sketch._(usage))
	sys.exit(1)

    if options.args:
	filename = options.args[0]
    else:
	filename = ''

    Sketch.init_ui()

    from Sketch.UI.skapp import SketchApplication
    application = SketchApplication(filename, options.display, options.geometry, options.participant, options.f1, options.f2, options.f3,options.f4,run_script = options.run_script)
    Sketch.Issue(None, Sketch.const.APP_INITIALIZED, application)
    application.Run()
    application.SavePreferences()
Пример #4
0
def process_args(args):
    # Read options from the command line. Return an instance object with the
    # instance variables:
    #	display		name of the X-display or None
    #	geometry	geometry of the main window or None
    #	args		rest of the arguments after the last option
    #
    # To behave more like other X-programs, sketch should accept the options
    # -display and -geometry with a single hyphen and no `='...

    # recognize a standard X geometry specification... (hack)
    if '-geometry' in args:
	try:
	    idx = args.index('-geometry')
	    geo = args[idx:idx + 2]
	    if len(geo) == 2:
		del args[idx:idx + 2]
		geo[0] = '-g'
		args[0:0] = geo
	except:
	    pass

    opts, args = getopt.getopt(args, 'd:g:hi',
			       ['display=', 'geometry=', 'help', 'run-script=',
                                'version', 'participant=','f1=','f2=','f3=','f4='])
    # the option -i is a hack to allow sketch to be used as a `python
    # interpreter' in the python shell in python-mode.el

    options = util.Empty(args = args,
			 display = None,
			 geometry = None, participant = None, f1 = None, f2 = None, f3 = None, f4 = None,#changed by shumon June , 2009
                         run_script = None)


    for optchar, value in opts:
        #print "opts=", opts, "optchar=", optchar,"value=",value
    	if optchar == '-d' or optchar == '--display':
    	    options.display = value
    	elif optchar == '-g' or optchar == '--geometry':
    	    options.geometry = value
        elif optchar == '--run-script':
                options.run_script = value
    	elif optchar == '-h' or optchar == '--help':
    	    print Sketch._(usage)
    	    sys.exit(0)
    	elif optchar == '--version':
    	    print Sketch._(version) % Sketch.SketchVersion
    	    sys.exit(0)
        elif optchar == '--participant':
            print "participant=", value
            options.participant = value
        elif optchar == '--f1':
            print "f1=",value
            options.f1 = value
        elif optchar == '--f2':
            print "f2=",value
            options.f2 = value
        elif optchar == '--f3':
            print "f3=",value
            options.f3 = value
        elif optchar == '--f4':
            print "f4=",value
            options.f4 = value

    return options