Skip to content

Commit

Permalink
Parses arguments in Windows. Fixes robotframework#1891
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 committed Sep 3, 2019
1 parent 0099678 commit 16bea3b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/robotide/contrib/testrunner/runprofiles.py
Expand Up @@ -36,6 +36,7 @@
from robotide.robotapi import DataError, Information
from robotide.utils import (overrides, SYSTEM_ENCODING, ArgumentParser,
is_unicode, PY3)
from robotide.context import IS_WINDOWS
from robotide.contrib.testrunner.usages import USAGE
from sys import getfilesystemencoding

Expand Down Expand Up @@ -150,8 +151,20 @@ def get_command_prefix(self):
return [self.get_command()] + self._get_arguments()

def _get_arguments(self):
if IS_WINDOWS:
self._parse_windows_command()
return self.arguments.split()

def _parse_windows_command(self):
from subprocess import Popen, PIPE
try:
p = Popen(['echo', self.arguments], stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
output, _ = p.communicate()
output = str(output).lstrip("b\'").strip()
self.arguments = output.replace('"', '').replace('\'', '')
except IOError:
pass

def get_command(self): # TODO Test on Windows
from subprocess import call
from tempfile import TemporaryFile
Expand Down Expand Up @@ -301,7 +314,7 @@ def OnArgumentsChanged(self, evt):

def _validate_arguments(self, args):
# assert type(args) is unicode
print("DEBUG: runprofiles: args=%s is_unicode(args)=%s" % (args, is_unicode(args)))
# print("DEBUG: runprofiles: args=%s is_unicode(args)=%s" % (args, is_unicode(args)))
invalid_message = self._get_invalid_message(args)
self._arguments.SetBackgroundColour(
'red' if invalid_message else 'white')
Expand All @@ -321,6 +334,8 @@ def MySetToolTip(self, obj, tip):

def _get_invalid_message(self, args):
invalid = None
if not args:
return None
try:
# print("DEBUG: runprofiles get inv msg: %s\n" % args)
clean_args = args.split("`") # Shell commands
Expand Down

0 comments on commit 16bea3b

Please sign in to comment.