Changeset 11210

Show
Ignore:
Timestamp:
07/05/10 09:01:50 (2 months ago)
Author:
amir.fadlon
Message:

Re implemented using Stations. Still lots of work to do but a solid start...

Location:
jsystemFramework/trunk/systemObjects/core/scriptingLanguages/src/jsystem/sysobj/scripting/python
Files:
1 removed
1 modified

Legend:

Unmodified
Added
Removed
  • jsystemFramework/trunk/systemObjects/core/scriptingLanguages/src/jsystem/sysobj/scripting/python/PyShell.java

    r11149 r11210  
    22 
    33import jsystem.extensions.analyzers.text.TextNotFound; 
    4 import jsystem.framework.report.Reporter; 
    54import jsystem.framework.system.SystemObjectImpl; 
     5import systemobject.terminal.Prompt; 
    66 
     7import com.aqua.stations.StationDefaultImpl; 
     8import com.aqua.stations.StationsFactory; 
     9import com.aqua.sysobj.conn.CliApplication; 
     10import com.aqua.sysobj.conn.CliCommand; 
     11import com.aqua.sysobj.conn.CliFactory; 
    712 
    813public class PyShell extends SystemObjectImpl { 
    914 
    10         private TelnetConnection telnet; 
     15        private StationDefaultImpl station; 
     16        private CliApplication cliApplication; 
     17 
    1118        private String host; 
    1219        private int port; 
     
    1522         
    1623        public void init() throws Exception { 
    17                 super.init();    
    1824                 
    19                 telnet = new TelnetConnection(host, port); 
    20                 telnet.Login(user, password, 4000); 
    21                 telnet.WriteLine("cd C:\\scapy-2.1.0"); 
    22                 telnet.WriteLine("python");              
    23                 String result = telnet.Read(">>>"); 
    24                 telnet.WriteLine("from scapy.all import *"); 
    25                 result = telnet.Read(">>>"); 
    26                 telnet.WriteLine("from scapy.layers.l2 import Dot1Q"); 
    27                 result = telnet.Read(">>>"); 
    28                 telnet.WriteLine("from scapy.layers.inet import IP"); 
    29                 result = telnet.Read(">>>"); 
    30                 telnet.WriteLine("from scapy.layers.ppp import *"); 
    31                 result = telnet.Read(">>>"); 
    32                 telnet.WriteLine("from scapy.layers.l2 import *"); 
    33                 result = telnet.Read(">>>"); 
    34                 telnet.WriteLine("import sys, os"); 
    35                 result = telnet.Read(">>>"); 
    36                 setTestAgainstObject(result); 
     25                super.init(); 
     26                 
     27                Prompt[] pyPrompts = new Prompt[1]; 
     28                 
     29                pyPrompts[0] = new Prompt(); 
     30                pyPrompts[0].setPrompt(">>>"); 
     31                pyPrompts[0].setCommandEnd(true); 
     32 
     33                station = StationsFactory.createStation(getHost(), CliFactory.OPERATING_SYSTEM_WINDOWS, "telnet", getUser(), getPassword(), null); 
     34                station.init(); 
     35                cliApplication = station.getCliSession(false); 
     36                 
    3737        } 
    3838         
    39         public void handleCliCommand(String title, String command) throws Exception { 
    40                 report.startLevel(title, Reporter.CurrentPlace); 
    41                 telnet.WriteLine(command); 
    42                 String result = telnet.Read(">>>"); 
    43                 setTestAgainstObject(result); 
    44                 analyze(new TextNotFound("error")); 
    45                 report.stopLevel(); 
     39        public void handleCliCommand(String command) throws Exception { 
     40                cliApplication.handleCliCommand(command, new CliCommand(command)); 
     41                cliApplication.analyze(new TextNotFound("Error")); 
    4642        } 
    4743 
    48         public void handleCliCommand(String title, String[] commands) throws Exception { 
    49                 report.startLevel(title, Reporter.CurrentPlace); 
    50                 for (String command : commands) { 
    51                         telnet.WriteLine(command); 
    52                         String result = (telnet.Read(">>>")); 
    53                         setTestAgainstObject(result); 
    54                         analyze(new TextNotFound("error")); 
    55                 } 
    56                 report.stopLevel(); 
     44        public void handleCliCommandWithoutWait(String title, String command) throws Exception { 
     45//              report.startLevel(title, Reporter.CurrentPlace); 
     46//              telnet.WriteLine(command); 
     47//              Thread.sleep(200); 
     48//              String result = telnet.Read(""); 
     49//              setTestAgainstObject(result); 
     50//              report.stopLevel(); 
    5751        } 
    5852