Modify submit_try to work on windows
Review URL: https://codereview.appspot.com/7199053

git-svn-id: http://skia.googlecode.com/svn/trunk@7379 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/submit_try b/tools/submit_try
index d62c9fb..2d18fc6 100755
--- a/tools/submit_try
+++ b/tools/submit_try
@@ -52,7 +52,7 @@
   proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
   if proc.wait() != 0:
     raise Exception('Couldn\'t find depot_tools in PATH!')
-  gcl = proc.communicate()[0]
+  gcl = proc.communicate()[0].split('\n')[0].rstrip()
   depot_tools_dir = os.path.dirname(gcl)
   return depot_tools_dir
 
@@ -64,7 +64,8 @@
       a git checkout.
   """
   if is_svn:
-    cmd = ['svn', 'info']
+    svn_cmd = 'svn.bat' if os.name == 'nt' else 'svn'
+    cmd = [svn_cmd, 'info']
     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT)
     if proc.wait() != 0:
@@ -165,18 +166,24 @@
       - revision: optional, int; the revision number from which to run the try. 
   is_svn: boolean; are we in an SVN repo?
   """
-  # First, find depot_tools. This is needed for the imports below.
-  sys.path.append(FindDepotTools())
-
   botlist = ','.join(['%s%s' % (bot, TRYBOT_SUFFIX) for bot in args.bot])
   if is_svn:
-    import gcl
-    try_args = [args.changelist, '--root', GetCheckoutRoot(is_svn),
+    gcl_cmd = 'gcl.bat' if os.name == 'nt' else 'gcl'
+    try_args = [gcl_cmd, 'try', args.changelist,
+                '--root', GetCheckoutRoot(is_svn),
                 '--bot', botlist]
     if args.revision:
       try_args.extend(['-r', args.revision])
-    gcl.CMDtry(try_args)
+    print ' '.join(try_args)
+    proc = subprocess.Popen(try_args, stdout=subprocess.PIPE,
+                            stderr=subprocess.STDOUT)
+    if proc.wait() != 0:
+      raise Exception('Failed to submit try request: %s' % (
+          proc.communicate()[0]))
+    print proc.communicate()[0]
   else:
+    # First, find depot_tools. This is needed to import trychange.
+    sys.path.append(FindDepotTools())
     import trychange
     try_args = ['--use_svn',
                 '--svn_repo', GetTryRepo(),