(self,cmd)
| 60 | # Split command arguments, trying to consider "strings with quotes |
| 61 | # and spaces" as a single one. So the user can type: !cmd "argu ment". |
| 62 | def split_arguments(self,cmd): |
| 63 | sp = cmd.split() |
| 64 | argv = [] |
| 65 | in_quotes = False |
| 66 | for a in sp: |
| 67 | if in_quotes: |
| 68 | if len(a) and a[-1] == '"': |
| 69 | a = a[:-1] |
| 70 | in_quotes = False |
| 71 | argv[-1] += " "+a |
| 72 | else: |
| 73 | if len(a) and a[0] == '"' and a[-1] == '"': |
| 74 | a = a[1:-1] |
| 75 | elif len(a) and a[0] == '"': |
| 76 | a = a[1:] |
| 77 | in_quotes = True |
| 78 | argv.append(a) |
| 79 | return argv |
| 80 | |
| 81 | # 'command' is the command string to execute, while 'fw' is |
| 82 | # our FreaWAN application class, used by the CommandsController |
no test coverage detected