Exemplo n.º 1
0
def system3(*parms, **kwargs):
    print subprocess.list2cmdline(parms)
    try:
        subprocess.check_call(parms, **kwargs)
    except (OSError, subprocess.CalledProcessError), err:
        print "execution failure, aborting:", parms
        print err
        sys.exit(2)
Exemplo n.º 2
0
 def test_list2cmdline(self):
     self.assertEqual(subprocess.list2cmdline(["a b c", "d", "e"]), '"a b c" d e')
     self.assertEqual(subprocess.list2cmdline(['ab"c', "\\", "d"]), 'ab\\"c \\ d')
     self.assertEqual(subprocess.list2cmdline(["a\\\\\\b", "de fg", "h"]), 'a\\\\\\b "de fg" h')
     self.assertEqual(subprocess.list2cmdline(['a\\"b', "c", "d"]), 'a\\\\\\"b c d')
     self.assertEqual(subprocess.list2cmdline(["a\\\\b c", "d", "e"]), '"a\\\\b c" d e')
     self.assertEqual(subprocess.list2cmdline(["a\\\\b\\ c", "d", "e"]), '"a\\\\b\\ c" d e')
     self.assertEqual(subprocess.list2cmdline(["ab", ""]), 'ab ""')
Exemplo n.º 3
0
 def test_list2cmdline(self):
     self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),
                      '"a b c" d e')
     self.assertEqual(subprocess.list2cmdline(['ab"c', '\\', 'd']),
                      'ab\\"c \\ d')
     self.assertEqual(subprocess.list2cmdline(['a\\\\\\b', 'de fg', 'h']),
                      'a\\\\\\b "de fg" h')
     self.assertEqual(subprocess.list2cmdline(['a\\"b', 'c', 'd']),
                      'a\\\\\\"b c d')
     self.assertEqual(subprocess.list2cmdline(['a\\\\b c', 'd', 'e']),
                      '"a\\\\b c" d e')
     self.assertEqual(subprocess.list2cmdline(['a\\\\b\\ c', 'd', 'e']),
                      '"a\\\\b\\ c" d e')
     self.assertEqual(subprocess.list2cmdline(['ab', '']),
                      'ab ""')