3 new revisions:
Revision: 2f668de5bbc6
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:23:25 2013
Log: Process: env handling
http://code.google.com/p/robotframework/source/detail?r=2f668de5bbc6
Revision: 992798dd04f7
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:31:08 2013
Log: Process: env handling
http://code.google.com/p/robotframework/source/detail?r=992798dd04f7
Revision: 1fe7af9291e9
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:31:17 2013
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=1fe7af9291e9
==============================================================================
Revision: 2f668de5bbc6
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:23:25 2013
Log: Process: env handling
http://code.google.com/p/robotframework/source/detail?r=2f668de5bbc6
Modified:
/src/robot/libraries/Process.py
=======================================
--- /src/robot/libraries/Process.py Mon Jun 10 05:39:20 2013
+++ /src/robot/libraries/Process.py Mon Jun 10 06:23:25 2013
@@ -526,11 +526,11 @@
self.shell = bool(shell)
self.alias = alias
self.env = env
- self._handle_rest(rest)
- if env:
+ self._construct_env(rest)
+ if self.env:
for k, v in self.env.items():
del self.env[k]
- self.env[str(k)] = str(v)
+ self.env[encode_to_system(k)] = encode_to_system(v)
def _new_stream(self, name, postfix):
if name == 'PIPE':
@@ -547,40 +547,16 @@
return self.stdout_stream
return self._new_stream(stderr, 'stderr')
- def _handle_rest(self, rest):
- if not rest:
- return
- self.env = self._construct_env(rest)
-
# TODO: cleanup and fixes
- # - 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(os.environ.copy().items())
- env_called = False
- for key, val in rest.iteritems():
- key = encode_to_system(key)
- if "env:" == key[:4]:
- new_env[key[4:]] = encode_to_system(val)
- env_called = True
- else:
+ for key in rest:
+ if not key.startswith('env:'):
raise RuntimeError("'%s' is not supported by this
keyword." % key)
- 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.
- # And that should be documented.
- def _must_env_values(self):
- must_values = {}
- if os.sep != '/':
- must_values['COMSPEC'] = os.environ['COMSPEC']
- must_values['PATH'] = os.environ['PATH']
- must_values['SYSTEMROOT'] = os.environ['SYSTEMROOT']
- return must_values
+ if self.env is None:
+ self.env = os.environ.copy()
+ self.env[key[4:]] = rest[key]
# TODO: Is this needed?
def __str__(self):
==============================================================================
Revision: 992798dd04f7
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:31:08 2013
Log: Process: env handling
http://code.google.com/p/robotframework/source/detail?r=992798dd04f7
Modified:
/src/robot/libraries/Process.py
=======================================
--- /src/robot/libraries/Process.py Mon Jun 10 06:23:25 2013
+++ /src/robot/libraries/Process.py Mon Jun 10 06:31:08 2013
@@ -525,12 +525,7 @@
self.stderr_stream = self._get_stderr(stderr, stdout)
self.shell = bool(shell)
self.alias = alias
- self.env = env
- self._construct_env(rest)
- if self.env:
- for k, v in self.env.items():
- del self.env[k]
- self.env[encode_to_system(k)] = encode_to_system(v)
+ self.env = self._construct_env(env, rest)
def _new_stream(self, name, postfix):
if name == 'PIPE':
@@ -547,16 +542,17 @@
return self.stdout_stream
return self._new_stream(stderr, 'stderr')
- # TODO: cleanup and fixes
- # - we probably should not encode items in the given env, only
- # the individually given name/value pairs
- def _construct_env(self, rest):
+ def _construct_env(self, env, rest):
for key in rest:
if not key.startswith('env:'):
raise RuntimeError("'%s' is not supported by this
keyword." % key)
- if self.env is None:
- self.env = os.environ.copy()
- self.env[key[4:]] = rest[key]
+ if env is None:
+ env = os.environ.copy()
+ env[key[4:]] = rest[key]
+ if env:
+ env = dict((encode_to_system(key), encode_to_system(env[key]))
+ for key in env)
+ return env
# TODO: Is this needed?
def __str__(self):
==============================================================================
Revision: 1fe7af9291e9
Branch: default
Author: Mikko Korpela <mikko.korp...@gmail.com>
Date: Mon Jun 10 06:31:17 2013
Log: Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=1fe7af9291e9
Modified:
/src/robot/libraries/Process.py
=======================================
--- /src/robot/libraries/Process.py Mon Jun 10 05:47:56 2013
+++ /src/robot/libraries/Process.py Mon Jun 10 06:31:17 2013
@@ -525,12 +525,7 @@
self.stderr_stream = self._get_stderr(stderr, stdout)
self.shell = bool(shell)
self.alias = alias
- 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)
+ self.env = self._construct_env(env, rest)
def _new_stream(self, name, postfix):
if name == 'PIPE':
@@ -547,40 +542,17 @@
return self.stdout_stream
return self._new_stream(stderr, 'stderr')
- def _handle_rest(self, rest):
- if not rest:
- return
- self.env = self._construct_env(rest)
-
- # TODO: cleanup and fixes
- # - 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(os.environ.copy().items())
- env_called = False
- for key, val in rest.iteritems():
- key = encode_to_system(key)
- if "env:" == key[:4]:
- new_env[key[4:]] = encode_to_system(val)
- env_called = True
- else:
+ def _construct_env(self, env, rest):
+ for key in rest:
+ if not key.startswith('env:'):
raise RuntimeError("'%s' is not supported by this
keyword." % key)
- 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.
- # And that should be documented.
- def _must_env_values(self):
- must_values = {}
- if os.sep != '/':
- must_values['COMSPEC'] = os.environ['COMSPEC']
- must_values['PATH'] = os.environ['PATH']
- must_values['SYSTEMROOT'] = os.environ['SYSTEMROOT']
- return must_values
+ if env is None:
+ env = os.environ.copy()
+ env[key[4:]] = rest[key]
+ if env:
+ env = dict((encode_to_system(key), encode_to_system(env[key]))
+ for key in env)
+ return env
# TODO: Is this needed?
def __str__(self):
--
---
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.