Class: Cosmos::CmdExtractor

Inherits:
QtTool show all
Defined in:
lib/cosmos/tools/cmd_extractor/cmd_extractor.rb

Overview

Breaks a binary log of commands into readable text.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from QtTool

#about, #closeEvent, #complete_initialize, create_default_options, graceful_kill, #initialize_help_menu, post_options_parsed_hook, pre_window_new_hook, redirect_io, restore_io

Constructor Details

#initialize(options) ⇒ CmdExtractor

Returns a new instance of CmdExtractor.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cosmos/tools/cmd_extractor/cmd_extractor.rb', line 24

def initialize(options)
  # MUST BE FIRST - All code before super is executed twice in RubyQt Based classes
  super(options)

  # Define instance variables
  @output_filename = nil
  @input_filenames = []
  @log_dir = System.paths['LOGS']
  @export_dir = @log_dir.clone
  @packet_log_reader = System.default_packet_log_reader.new
  @time_start = nil
  @time_end = nil

  Cosmos.load_cosmos_icon("cmd_extractor.png")

  initialize_actions()
  initialize_menus()
  initialize_central_widget()
  complete_initialize()

  # Bring up slash screen for long duration tasks after creation
  Splash.execute(self) do |splash|
    ConfigParser.splash = splash
    System.commands
    ConfigParser.splash = nil
  end
end

Class Method Details

.run(option_parser = nil, options = nil) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cosmos/tools/cmd_extractor/cmd_extractor.rb', line 105

def self.run(option_parser = nil, options = nil)
  Cosmos.catch_fatal_exception do
    unless option_parser and options
      option_parser, options = create_default_options()
      options.width = 700
      options.height = 425
      options.title = "Command Extractor"
    end

    super(option_parser, options)
  end
end

Instance Method Details

#initialize_actionsObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/cosmos/tools/cmd_extractor/cmd_extractor.rb', line 52

def initialize_actions
  super()

  # Mode Menu Actions
  @include_raw = Qt::Action.new(tr('Include &Raw Data'), self)
  @include_raw_keyseq = Qt::KeySequence.new(tr('Ctrl+R'))
  @include_raw.shortcut = @include_raw_keyseq
  @include_raw.statusTip = tr('Include raw packet data in the text output')
  @include_raw.setCheckable(true)
end

#initialize_central_widgetObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cosmos/tools/cmd_extractor/cmd_extractor.rb', line 77

def initialize_central_widget
  @central_widget = Qt::Widget.new
  setCentralWidget(@central_widget)
  @top_layout = Qt::VBoxLayout.new(@central_widget)

  # Packet Log Frame
  @packet_log_frame = PacketLogFrame.new(self, @log_dir, System.default_packet_log_reader.new, @input_filenames, @output_filename, true, true, true, Cosmos::CMD_FILE_PATTERN, Cosmos::TXT_FILE_PATTERN)
  @packet_log_frame.change_callback = method(:change_callback)
  @top_layout.addWidget(@packet_log_frame)

  # Separator before buttons
  @sep2 = Qt::Frame.new(@central_widget)
  @sep2.setFrameStyle(Qt::Frame::HLine | Qt::Frame::Sunken)
  @top_layout.addWidget(@sep2)

  # Process and Open Buttons
  @button_layout = Qt::HBoxLayout.new
  @process_button = Qt::PushButton.new('&Process Files')
  @process_button.connect(SIGNAL('clicked()')) { process_log_files() }
  @button_layout.addWidget(@process_button)

  @open_button = Qt::PushButton.new('&Open in Text Editor')
  @open_button.connect(SIGNAL('clicked()')) { open_button() }
  @open_button.setEnabled(false)
  @button_layout.addWidget(@open_button)
  @top_layout.addLayout(@button_layout)
end

#initialize_menusObject



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cosmos/tools/cmd_extractor/cmd_extractor.rb', line 63

def initialize_menus
  # File Menu
  @file_menu = menuBar.addMenu(tr('&File'))
  @file_menu.addAction(@exit_action)

  # Mode Menu
  @mode_menu = menuBar.addMenu(tr('&Mode'))
  @mode_menu.addAction(@include_raw)

  # Help Menu
  @about_string = "Command Extractor extracts commands from a binary command log file into a human readable text file."
  initialize_help_menu()
end