def __init__(self, *args, **kwargs):
		super(CampaignViewDashboardTab, self).__init__(*args, **kwargs)
		self.graphs = []
		"""The :py:class:`.CampaignGraph` classes represented on the dash board."""

		dash_ports = {
			# dashboard position, (width, height)
			'top_left': (380, 200),
			'top_right': (380, 200),
			'bottom': (760, 200)
		}
		for dash_port, details in dash_ports.items():
			graph_name = self.config['dashboard.' + dash_port]
			cls = graphs.get_graph(graph_name)
			if not cls:
				self.logger.warning('could not get graph: ' + graph_name)
				logo_file_path = find.find_data_file('king-phisher-icon.svg')
				if logo_file_path:
					image = Gtk.Image.new_from_pixbuf(GdkPixbuf.Pixbuf.new_from_file_at_size(logo_file_path, 128, 128))
					image.show()
					self.gobjects['scrolledwindow_' + dash_port].add(image)
				continue
			graph_inst = cls(self.application, details, getattr(self, self.top_gobject).get_style_context())
			self.gobjects['scrolledwindow_' + dash_port].add(graph_inst.canvas)
			self.gobjects['box_' + dash_port].pack_end(graph_inst.navigation_toolbar, False, False, 0)
			self.graphs.append(graph_inst)
		self.logger.debug("dashboard refresh frequency set to {0} seconds".format(self.refresh_frequency))
		GLib.timeout_add_seconds(self.refresh_frequency, self.loader_idle_routine)
	def __init__(self, *args, **kwargs):
		self.label = Gtk.Label(self.label_text)
		super(CampaignViewDashboardTab, self).__init__(*args, **kwargs)
		self.last_load_time = float('-inf')
		self.load_lifetime = utilities.timedef_to_seconds('3m')
		self.loader_thread = None
		self.loader_thread_lock = threading.RLock()
		self.graphs = []

		# Position: (DefaultGraphName, Size)
		dash_ports = {
			'top_left': (380, 200),
			'top_right': (380, 200),
			'bottom': None
		}
		for dash_port, details in dash_ports.items():
			graph_name = self.config['dashboard.' + dash_port]
			Klass = graphs.get_graph(graph_name)
			if not Klass:
				self.logger.warning('could not get graph: ' + graph_name)
				continue
			graph_inst = Klass(self.config, self.parent, details)
			self.gobjects['scrolledwindow_' + dash_port].add_with_viewport(graph_inst.canvas)
			self.gobjects['box_' + dash_port].pack_end(graph_inst.navigation_toolbar, False, False, 0)
			self.graphs.append(graph_inst)
		GLib.timeout_add_seconds(self.load_lifetime, self.loader_idle_routine)
Exemple #3
0
    def _add_menu_optional_actions(self, action_group, uimanager):
        if sys.platform.startswith('linux'):
            action = Gtk.Action(name='ToolsSFTPClient',
                                label='SFTP Client',
                                tooltip='SFTP Client',
                                stock_id=None)
            action.connect('activate', lambda x: self.start_sftp_client())
            action_group.add_action_with_accel(action, '<control>F2')
            merge_id = uimanager.new_merge_id()
            uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient',
                             'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM,
                             False)

        if graphs.has_matplotlib:
            action = Gtk.Action(name='ToolsGraphMenu',
                                label='Create Graph',
                                tooltip='Create A Graph',
                                stock_id=None)
            action_group.add_action(action)

            for graph_name in graphs.get_graphs():
                action_name = 'ToolsGraph' + graph_name
                graph = graphs.get_graph(graph_name)
                action = Gtk.Action(name=action_name,
                                    label=graph.name_human,
                                    tooltip=graph.name_human,
                                    stock_id=None)
                action.connect('activate',
                               self.signal_activate_popup_menu_create_graph,
                               graph_name)
                action_group.add_action(action)

            merge_id = uimanager.new_merge_id()
            uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu',
                             'ToolsGraphMenu', Gtk.UIManagerItemType.MENU,
                             False)
            for graph_name in sorted(
                    graphs.get_graphs(),
                    key=lambda gn: graphs.get_graph(gn).name_human):
                action_name = 'ToolsGraph' + graph_name
                uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu',
                                 action_name, action_name,
                                 Gtk.UIManagerItemType.MENUITEM, False)
Exemple #4
0
    def show_campaign_graph(self, graph_name):
        """
		Create a new :py:class:`.CampaignGraph` instance and make it into
		a window. *graph_name* must be the name of a valid, exported
		graph provider.

		:param str graph_name: The name of the graph to make a window of.
		"""
        cls = graphs.get_graph(graph_name)
        graph_inst = cls(self, style_context=self.style_context)
        graph_inst.load_graph()
        window = graph_inst.make_window()
        window.show()
	def show_campaign_graph(self, graph_name):
		"""
		Create a new :py:class:`.CampaignGraph` instance and make it into
		a window. *graph_name* must be the name of a valid, exported
		graph provider.

		:param str graph_name: The name of the graph to make a window of.
		"""
		cls = graphs.get_graph(graph_name)
		graph_inst = cls(self, style_context=self.style_context)
		graph_inst.load_graph()
		window = graph_inst.make_window()
		window.show()
	def _configure_settings_dashboard(self):
		if not graphs.has_matplotlib:
			self.gtk_builder_get('frame_dashboard').set_sensitive(False)
			return
		graph_providers = Gtk.ListStore(str, str)
		for graph in graphs.get_graphs():
			graph = graphs.get_graph(graph)
			graph_providers.append([graph.name_human, graph.name])
		for dash_position in ['top_left', 'top_right', 'bottom']:
			combobox = self.gtk_builder_get('combobox_dashboard_' + dash_position)
			combobox.set_model(graph_providers)
			ti = gui_utilities.gtk_list_store_search(graph_providers, self.config.get('dashboard.' + dash_position), column=1)
			combobox.set_active_iter(ti)
Exemple #7
0
	def _configure_settings_dashboard(self):
		if not graphs.has_matplotlib:
			self.gtk_builder_get('frame_dashboard').set_sensitive(False)
			return
		graph_providers = Gtk.ListStore(str, str)
		for graph in graphs.get_graphs():
			graph = graphs.get_graph(graph)
			graph_providers.append([graph.name_human, graph.name])
		for dash_position in ['top_left', 'top_right', 'bottom']:
			combobox = self.gtk_builder_get('combobox_dashboard_' + dash_position)
			combobox.set_model(graph_providers)
			ti = gui_utilities.gtk_list_store_search(graph_providers, self.config.get('dashboard.' + dash_position), column=1)
			combobox.set_active_iter(ti)
Exemple #8
0
	def _add_menu_optional_actions(self, action_group, uimanager):
		if sys.platform.startswith('linux'):
			action = Gtk.Action(name='ToolsSFTPClient', label='SFTP Client', tooltip='SFTP Client', stock_id=None)
			action.connect('activate', lambda x: self.start_sftp_client())
			action_group.add_action_with_accel(action, '<control>F2')
			merge_id = uimanager.new_merge_id()
			uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsSFTPClient', 'ToolsSFTPClient', Gtk.UIManagerItemType.MENUITEM, False)

		if graphs.has_matplotlib:
			action = Gtk.Action(name='ToolsGraphMenu', label='Create Graph', tooltip='Create A Graph', stock_id=None)
			action_group.add_action(action)

			for graph_name in graphs.get_graphs():
				action_name = 'ToolsGraph' + graph_name
				graph = graphs.get_graph(graph_name)
				action = Gtk.Action(name=action_name, label=graph.name_human, tooltip=graph.name_human, stock_id=None)
				action.connect('activate', self.signal_activate_popup_menu_create_graph, graph_name)
				action_group.add_action(action)

			merge_id = uimanager.new_merge_id()
			uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu', 'ToolsGraphMenu', 'ToolsGraphMenu', Gtk.UIManagerItemType.MENU, False)
			for graph_name in sorted(graphs.get_graphs(), key=lambda gn: graphs.get_graph(gn).name_human):
				action_name = 'ToolsGraph' + graph_name
				uimanager.add_ui(merge_id, '/MenuBar/ToolsMenu/ToolsGraphMenu', action_name, action_name, Gtk.UIManagerItemType.MENUITEM, False)
Exemple #9
0
	def __init__(self, application, window):
		assert isinstance(window, MainAppWindow)
		super(MainMenuBar, self).__init__(application)
		self.window = weakref.proxy(window)
		self._add_accelerators()
		graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph')
		if graphs.has_matplotlib:
			graphs_submenu = Gtk.Menu.new()
			for graph_name in graphs.get_graphs():
				graph = graphs.get_graph(graph_name)
				menu_item = Gtk.MenuItem.new_with_label(graph.name_human)
				menu_item.connect('activate', self.do_tools_show_campaign_graph, graph_name)
				graphs_submenu.append(menu_item)
			graphs_menu_item.set_submenu(graphs_submenu)
			graphs_menu_item.show_all()
		else:
			graphs_menu_item.set_sensitive(False)
Exemple #10
0
	def __init__(self, application, window):
		utilities.assert_arg_type(application, Gtk.Application, arg_pos=1)
		utilities.assert_arg_type(window, MainAppWindow, arg_pos=2)
		super(MainMenuBar, self).__init__(application)
		self.window = weakref.proxy(window)
		self._add_accelerators()
		graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph')
		if graphs.has_matplotlib:
			graphs_submenu = Gtk.Menu.new()
			for graph_name in graphs.get_graphs():
				graph = graphs.get_graph(graph_name)
				menu_item = Gtk.MenuItem.new_with_label(graph.name_human)
				menu_item.connect('activate', self.signal_activate_tools_show_campaign_graph, graph_name)
				graphs_submenu.append(menu_item)
			graphs_menu_item.set_submenu(graphs_submenu)
			graphs_menu_item.show_all()
		else:
			graphs_menu_item.set_sensitive(False)
Exemple #11
0
	def __init__(self, *args, **kwargs):
		super(CampaignViewDashboardTab, self).__init__(*args, **kwargs)
		self.graphs = []
		"""The :py:class:`.CampaignGraph` classes represented on the dash board."""

		# Position: (DefaultGraphName, Size)
		dash_ports = {
			'top_left': (380, 200),
			'top_right': (380, 200),
			'bottom': None
		}
		for dash_port, details in dash_ports.items():
			graph_name = self.config['dashboard.' + dash_port]
			Klass = graphs.get_graph(graph_name)
			if not Klass:
				self.logger.warning('could not get graph: ' + graph_name)
				continue
			graph_inst = Klass(self.config, self.parent, details)
			self.gobjects['scrolledwindow_' + dash_port].add_with_viewport(graph_inst.canvas)
			self.gobjects['box_' + dash_port].pack_end(graph_inst.navigation_toolbar, False, False, 0)
			self.graphs.append(graph_inst)
		self.logger.debug("dashboard refresh frequency set to {0} seconds".format(self.refresh_frequency))
		GLib.timeout_add_seconds(self.refresh_frequency, self.loader_idle_routine)
Exemple #12
0
	def test_graph_classes(self):
		for graph in graphs.get_graphs():
			self.assertTrue(isinstance(graph, str))
			self.assertTrue(issubclass(graphs.get_graph(graph), graphs.CampaignGraph))
Exemple #13
0
 def test_graph_classes(self):
     for graph in graphs.get_graphs():
         self.assertTrue(isinstance(graph, str))
         self.assertTrue(
             issubclass(graphs.get_graph(graph), graphs.CampaignGraph))
Exemple #14
0
	def test_graph_classes(self):
		for graph in graphs.get_graphs():
			self.assertIsInstance(graph, str)
			self.assertIsSubclass(graphs.get_graph(graph), graphs.CampaignGraph)
Exemple #15
0
 def test_graph_classes(self):
     for graph in graphs.get_graphs():
         self.assertIsInstance(graph, str)
         self.assertIsSubclass(graphs.get_graph(graph),
                               graphs.CampaignGraph)
	def show_campaign_graph(self, graph_name):
		Klass = graphs.get_graph(graph_name)
		graph_inst = Klass(self.config, self)
		graph_inst.load_graph()
		window = graph_inst.make_window()
		window.show_all()