couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [29/50] couchdb commit: updated refs/heads/auth-tests-wip to c34d871
Date Tue, 12 Jul 2016 19:41:12 GMT
factoring out path manipulation into a function


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c5dcb48e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c5dcb48e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c5dcb48e

Branch: refs/heads/auth-tests-wip
Commit: c5dcb48e7973e3157c2ea0acffb2524002b8478f
Parents: a8e250b
Author: Joan Touzet <wohali@apache.org>
Authored: Mon Jun 20 13:29:21 2016 -0400
Committer: Joan Touzet <wohali@apache.org>
Committed: Mon Jun 20 13:29:21 2016 -0400

----------------------------------------------------------------------
 dev/run | 42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/c5dcb48e/dev/run
----------------------------------------------------------------------
diff --git a/dev/run b/dev/run
index 81140c4..233438d 100755
--- a/dev/run
+++ b/dev/run
@@ -19,8 +19,10 @@ import functools
 import glob
 import inspect
 import json
+import ntpath
 import optparse
 import os
+import posixpath
 import re
 import subprocess as sp
 import sys
@@ -42,6 +44,12 @@ except ImportError:
     import http.client as httpclient
 
 
+def toposixpath(path):
+    if os.sep == ntpath.sep:
+        return path.replace(ntpath.sep, posixpath.sep)
+    else:
+        return path
+
 def log(msg):
     def decorator(func):
         @functools.wraps(func)
@@ -162,23 +170,18 @@ def setup_configs(ctx):
     for idx, node in enumerate(ctx['nodes']):
         cluster_port, backend_port = get_ports(idx + ctx['node_number'])
         env = {
-            "prefix": ctx['rootdir'],
+            "prefix": toposixpath(ctx['rootdir']),
             "package_author_name": "The Apache Software Foundation",
-            "data_dir": ensure_dir_exists(ctx['devdir'],
-                                          "lib", node, "data"),
-            "view_index_dir": ensure_dir_exists(ctx['devdir'],
-                                                "lib", node, "data"),
+            "data_dir": toposixpath(ensure_dir_exists(ctx['devdir'],
+                                          "lib", node, "data")),
+            "view_index_dir": toposixpath(ensure_dir_exists(ctx['devdir'],
+                                                "lib", node, "data")),
             "node_name": "-name %s@127.0.0.1" % node,
             "cluster_port": cluster_port,
             "backend_port": backend_port,
             "fauxton_root": "src/fauxton/dist/release",
             "uuid": "fake_uuid_for_dev"
         }
-        if os.sep == '\\':
-            # Erlang always wants UNIX-style paths
-            env["data_dir"] = env["data_dir"].replace("\\", "/")
-            env["view_index_dir"] = env["view_index_dir"].replace("\\", "/")
-            env["prefix"] = env["prefix"].replace("\\", "/")
         write_config(ctx, node, env)
 
 
@@ -236,10 +239,7 @@ def boot_haproxy(ctx):
 
 def hack_default_ini(ctx, node, content):
     # Replace log file
-    logfile = os.path.join(ctx['devdir'], "logs", "%s.log" % node)
-    if os.sep == '\\':
-        # Erlang always wants UNIX-style paths
-        logfile = logfile.replace("\\", "/")
+    logfile = toposixpath(os.path.join(ctx['devdir'], "logs", "%s.log" % node))
     repl = "file = %s" % logfile
     contents = re.sub("(?m)^file.*$", repl, content)
 
@@ -248,16 +248,10 @@ def hack_default_ini(ctx, node, content):
     mainjs = os.path.join(ctx['rootdir'], "share", "server", "main.js")
     coffeejs = os.path.join(ctx['rootdir'], "share", "server", "main-coffee.js")
 
-    repl = "javascript = %s %s" % (couchjs, mainjs)
-    if os.sep == '\\':
-        # Erlang always wants UNIX-style paths
-        repl = repl.replace("\\", "/")
+    repl = toposixpath("javascript = %s %s" % (couchjs, mainjs))
     contents = re.sub("(?m)^javascript.*$", repl, contents)
 
-    repl = "coffeescript = %s %s" % (couchjs, coffeejs)
-    if os.sep == '\\':
-        # Erlang always wants UNIX-style paths
-        repl = repl.replace("\\", "/")
+    repl = toposixpath("coffeescript = %s %s" % (couchjs, coffeejs))
     contents = re.sub("(?m)^coffeescript.*$", repl, contents)
 
     return contents
@@ -388,9 +382,7 @@ def boot_node(ctx, node):
     ]
     logfname = os.path.join(ctx['devdir'], "logs", "%s.log" % node)
     log = open(logfname, "wb")
-    if os.sep == '\\':
-        # Erlang always wants UNIX-style paths
-        cmd = [x.replace("\\", "/") for x in cmd]
+    cmd = [toposixpath(x) for x in cmd]
     return sp.Popen(cmd, stdin=sp.PIPE, stdout=log, stderr=sp.STDOUT, env=env)
 
 


Mime
View raw message