Exemplo n.º 1
0
 def env_quote(key, value):
     if not DeviceUtils._VALID_SHELL_VARIABLE.match(key):
         raise KeyError('Invalid shell variable name %r' % key)
     # using double quotes here to allow interpolation of shell variables
     return '%s=%s' % (key, cmd_helper.DoubleQuote(value))
Exemplo n.º 2
0
 def testSingleQuote_doExpand(self):
     test_string = 'hello $TEST_VAR'
     cmd = 'TEST_VAR=world; echo %s' % cmd_helper.DoubleQuote(test_string)
     self.assertEquals('hello world',
                       cmd_helper.GetCmdOutput(cmd, shell=True).rstrip())
Exemplo n.º 3
0
 def testDoubleQuote_withSpaces(self):
     self.assertEquals('"hello world"',
                       cmd_helper.DoubleQuote('hello world'))
Exemplo n.º 4
0
 def testDoubleQuote_withUnsafeChars(self):
     self.assertEquals('''"hello\\"; rm -rf /"''',
                       cmd_helper.DoubleQuote('hello"; rm -rf /'))
Exemplo n.º 5
0
 def testDoubleQuote_basic(self):
     self.assertEquals('hello', cmd_helper.DoubleQuote('hello'))