2 new revisions:
Revision: 4a91bd3f857f
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 05:39:20 2013
Log: Process: Remove env must values - user has to do these
http://code.google.com/p/robotframework/source/detail?r=4a91bd3f857f
Revision: 4333fc872686
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 05:39:53 2013
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=4333fc872686
==============================================================================
Revision: 4a91bd3f857f
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 05:39:20 2013
Log: Process: Remove env must values - user has to do these
http://code.google.com/p/robotframework/source/detail?r=4a91bd3f857f
Modified:
/atest/testdata/standard_libraries/process/test_process_library.txt
/src/robot/libraries/Process.py
=======================================
--- /atest/testdata/standard_libraries/process/test_process_library.txt Mon
Jun 10 02:16:55 2013
+++ /atest/testdata/standard_libraries/process/test_process_library.txt Mon
Jun 10 05:39:20 2013
@@ -68,7 +68,7 @@
With Env= Configuration the Environment Should Contain Only Additional
Variable
Set Environment Variable normalvar normal
- ${setenv}= Create Dictionary specialvar spessu
+ ${setenv}= Create env dictionary specialvar spessu
${result}= Run Process python -c "import os; print
os.getenv('normalvar', '-'), os.getenv('specialvar', '-');" shell=True
env=${setenv}
Should Be Equal ${result.stdout.strip()} - spessu
@@ -78,13 +78,13 @@
Should Be Equal ${result.stdout.strip()} normal spessu daaba
Setting Environment Variable Overrides Original
- Set Environment Variable vari original
- ${result}= Run Process python -c "import os; print
os.getenv('vari', '-');" shell=True env:vari=new
+ Set Environment Variable VARI original
+ ${result}= Run Process python -c "import os; print
os.getenv('VARI', '-');" shell=True env:VARI=new
Should Be Equal ${result.stdout.strip()} new
Setting Environment With Multiple Values Using Dictionary
Set Environment Variable normalvar normal
- ${setenv}= Create Dictionary specialvar spessu diiba2
daaba2
+ ${setenv}= Create env dictionary specialvar spessu diiba2
daaba2
${result}= Run Process python -c import os; print
os.getenv('normalvar', '-'), os.getenv('specialvar', '-'),
os.getenv('diiba2', '-'); env=${setenv}
Should Be Equal ${result.stdout.strip()} - spessu daaba2
@@ -180,3 +180,11 @@
Valid Platform
${is_ok}= Evaluate sys.platform != 'cli' sys
[Return] ${is_ok}
+
+Create env dictionary
+ [Arguments] @{env_args}
+ ${comspec}= Get Environment Variable COMSPEC default=.
+ ${path}= Get Environment Variable PATH default=.
+ ${systemroot}= Get Environment Variable SYSTEMROOT default=.
+ ${setenv}= Create Dictionary PATH ${path} SYSTEMROOT
${SYSTEMROOT} @{env_args}
+ [Return] ${setenv}
=======================================
--- /src/robot/libraries/Process.py Mon Jun 10 02:16:55 2013
+++ /src/robot/libraries/Process.py Mon Jun 10 05:39:20 2013
@@ -519,14 +519,18 @@
class ProcessConfig(object):
def __init__(self, cwd=None, shell=False, stdout=None, stderr=None,
- alias=None, **rest):
+ alias=None, env=None, **rest):
self.cwd = cwd or os.path.abspath(os.curdir)
self.stdout_stream = self._new_stream(stdout, 'stdout')
self.stderr_stream = self._get_stderr(stderr, stdout)
self.shell = bool(shell)
self.alias = alias
- self.env = None
+ self.env = env
self._handle_rest(rest)
+ if env:
+ for k, v in self.env.items():
+ del self.env[k]
+ self.env[str(k)] = str(v)
def _new_stream(self, name, postfix):
if name == 'PIPE':
@@ -549,29 +553,23 @@
self.env = self._construct_env(rest)
# TODO: cleanup and fixes
- # - if env is not given, individually given env values are overridden
- # by values with same names in os.environ!!
- # - confusing to first set self.env here but then reset it by
+ # - confusing to first set self.env here but then reset it by
# the returned value
# - we probably should not encode items in the given env, only
# the individually given name/value pairs
def _construct_env(self, rest):
- new_env = dict()
+ new_env = dict(os.environ.copy().items())
+ env_called = False
for key, val in rest.iteritems():
key = encode_to_system(key)
- if key == "env":
- self.env = dict()
- for k, v in val.iteritems():
- k = encode_to_system(k)
- v = encode_to_system(v)
- self.env[k] = v
- elif "env:" == key[:4]:
+ if "env:" == key[:4]:
new_env[key[4:]] = encode_to_system(val)
+ env_called = True
else:
raise RuntimeError("'%s' is not supported by this
keyword." % key)
- if not self.env:
- return dict(os.environ.copy().items()+new_env.items())
- return dict(self._must_env_values().items() + self.env.items())
+ if self.env is None and env_called:
+ return new_env
+ return self.env
# TODO: Why is this done? Can't we just let the command fail if env is
invalid?
# If this is considered useful, should add PATH to env elsewhere too.
==============================================================================
Revision: 4333fc872686
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 05:39:53 2013
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=4333fc872686
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.