PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/copy_win_scripts/start-client.py

https://bitbucket.org/lindenlab/viewer-beta/
Python | 92 lines | 66 code | 1 blank | 25 comment | 0 complexity | f04bd26b2193462246891ce0fb28b71a MD5 | raw file
 1#!/usr/bin/env python
 2"""\
 3@file   start-client.py
 4
 5$LicenseInfo:firstyear=2010&license=viewerlgpl$
 6Second Life Viewer Source Code
 7Copyright (C) 2010-2011, Linden Research, Inc.
 8
 9This library is free software; you can redistribute it and/or
10modify it under the terms of the GNU Lesser General Public
11License as published by the Free Software Foundation;
12version 2.1 of the License only.
13
14This library is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public
20License along with this library; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
23Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24$/LicenseInfo$
25"""
26import sys, getopt
27import os
28import llstart
29
30def usage():
31    print """start-client.py
32    
33    --grid <grid>
34    --farm <grid>
35    --region <starting region name>
36    """
37
38def start_client(grid, slurl, build_config, my_args):
39    login_url = "https://login.%s.lindenlab.com/cgi-bin/login.cgi" % (grid)
40
41    viewer_args = { "--grid" : grid,
42                    "--loginuri" : login_url }
43    viewer_args.update(my_args)
44    # *sigh*  We must put --url at the end of the argument list.
45    if viewer_args.has_key("--url"):
46        slurl = viewer_args["--url"]
47        del(viewer_args["--url"])
48    viewer_args = llstart.get_args_from_dict(viewer_args)
49    if slurl is not None:
50        viewer_args += " --url %s" % slurl
51
52    # Figure out path stuff.
53    # The client should run from indra/newview
54    # but the exe is at indra/build-<xxx>/newview/<target>
55    build_path = os.path.dirname(os.getcwd());    
56    f = open("start-client.log", "w")
57    print >>f, "Viewer startup arguments:"
58    llstart.start("viewer", "../../newview", 
59        "%s/newview/%s/secondlife-bin.exe" % (build_path, build_config),
60        viewer_args, f)
61    f.close()
62
63if __name__ == "__main__":
64    grid = llstart.get_config("grid")
65    
66    if grid == None:
67        grid = "aditi"
68        
69    build_config = llstart.get_config("build_config")
70    my_args = llstart.get_config("viewer_args", force_dict = True)
71    opts, args = getopt.getopt(sys.argv[1:], "u:r:f:g:i:h",
72        ["region=", "username=", "farm=", "grid=", "ip=", "help"])
73    region = None
74    for o, a in opts:
75        if o in ("-r", "--region", "-u", "--username"):
76            region = a
77        if o in ("-f", "--farm", "-g", "--grid"):
78            grid = a
79        if o in ("-h", "--help"):
80            usage()
81            sys.exit(0)
82            
83    slurl = llstart.get_config("slurl")            
84    if slurl == None:
85        if region is None:
86            region = llstart.get_user_name()
87        slurl = "//%s/128/128/" % (region)
88    # Ensure the slurl has quotes around it.
89    if slurl is not None:
90        slurl = '"%s"' % (slurl.strip('"\''))
91    
92    start_client(grid, slurl, build_config, my_args)