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