Beispiel #1
0
 def get_command(self):
     command = None
     for line in reversed(self.buffer):
         x = "".join(map(operator.attrgetter("data"), line)).strip()
         if len(x) > 0:
             command = command_parser(x)
             if command is not None:
                 break
     return command
Beispiel #2
0
 def test_special_command_parser(self):
     ps1_command = "[vagrant@cyberivy-test-dev002-shjj ~]$ cd"
     self.assertEquals(command_parser(ps1_command), "cd")
Beispiel #3
0
 def test_not_special_space_command_parser(self):
     ps1_command = "[vagrant ~]$ cd /var/tmp && dd"
     self.assertEquals(command_parser(ps1_command), None)
Beispiel #4
0
 def test_genernal_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$ ls"
     self.assertEquals(command_parser(ps1_command), "ls")
Beispiel #5
0
 def test_genernal_space_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$ cat 1.txt >> 2.txt"
     self.assertEquals(command_parser(ps1_command), "cat 1.txt >> 2.txt")
Beispiel #6
0
 def test_null_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$"
     self.assertEquals(command_parser(ps1_command), "")
Beispiel #7
0
 def test_special_command_parser(self):
     ps1_command = "[vagrant@cyberivy-test-dev002-shjj ~]$ cd"
     self.assertEquals(command_parser(ps1_command), "cd")
Beispiel #8
0
 def test_genernal_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$ ls"
     self.assertEquals(command_parser(ps1_command), "ls")
Beispiel #9
0
 def test_not_special_space_command_parser(self):
     ps1_command = "[vagrant ~]$ cd /var/tmp && dd"
     self.assertEquals(command_parser(ps1_command), None)
Beispiel #10
0
 def test_null_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$"
     self.assertEquals(command_parser(ps1_command), "")
Beispiel #11
0
 def test_genernal_space_command_parser(self):
     ps1_command = "0;vagrant@cyberivy-test-dev002-shjj:~[vagrant@cyberivy-test-dev002-shjj ~]$ cat 1.txt >> 2.txt"
     self.assertEquals(command_parser(ps1_command), "cat 1.txt >> 2.txt")