Exemple #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
Exemple #2
0
 def test_special_command_parser(self):
     ps1_command = "[vagrant@cyberivy-test-dev002-shjj ~]$ cd"
     self.assertEquals(command_parser(ps1_command), "cd")
Exemple #3
0
 def test_not_special_space_command_parser(self):
     ps1_command = "[vagrant ~]$ cd /var/tmp && dd"
     self.assertEquals(command_parser(ps1_command), None)
Exemple #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")
Exemple #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")
Exemple #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), "")
 def test_special_command_parser(self):
     ps1_command = "[vagrant@cyberivy-test-dev002-shjj ~]$ cd"
     self.assertEquals(command_parser(ps1_command), "cd")
 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")
 def test_not_special_space_command_parser(self):
     ps1_command = "[vagrant ~]$ cd /var/tmp && dd"
     self.assertEquals(command_parser(ps1_command), None)
 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), "")
 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")