From 8cea241b8c248c904ea92d40bb50a9f0616b9ac7 Mon Sep 17 00:00:00 2001 From: hakantkn Date: Thu, 20 Feb 2014 15:39:45 +0200 Subject: [PATCH] For running in Windows To run on Windows path seperator must be changed. Also close_fds is not available on Windows. --- weka/classifiers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weka/classifiers.py b/weka/classifiers.py index b272403..7ec6940 100644 --- a/weka/classifiers.py +++ b/weka/classifiers.py @@ -30,7 +30,7 @@ BP = os.path.dirname(os.path.abspath(__file__)) CP = os.environ.get('WEKA_JAR_PATH', DEFAULT_WEKA_JAR_PATH) -for _cp in CP.split(':'): +for _cp in CP.split(os.pathsep): assert os.path.isfile(_cp), ("Weka JAR file %s not found. Ensure the " + \ "file is installed or update your environment's WEKA_JAR_PATH to " + \ "only include valid locations.") % (_cp,) @@ -283,7 +283,7 @@ def train(self, training_data, testing_data=None, verbose=False): # Create new model file. cmd = "java -cp %(CP)s %(classifier_name)s -t \"%(training_fn)s\" -T \"%(testing_fn)s\" -d \"%(model_fn)s\" %(ckargs)s" % args if verbose: print cmd - p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=sys.platform != "win32") stdin, stdout, stderr = (p.stdin, p.stdout, p.stderr) stdout_str = stdout.read() stderr_str = stderr.read() @@ -664,4 +664,4 @@ def test_updateable(self): if __name__ == '__main__': unittest.main() - \ No newline at end of file +