Ejemplo n.º 1
0
	def __init__(self):
		super(Stateful_thread, self).__init__()
		self.os_type = common.get_os_type()
		self.checks = checks.Checks()
		self.controlchannel = controlchannel.ControlChannel()

		# control message handlers
		self.cmh_struct  = {
			# num : [string to look for, function, server(1) or client(0), return on success, return on failure]
			# return value meanings: True  - module continues
			#						 False - module thread terminates
			# in case of Stateless modules, the whole module terminates if the return value is False
			0  : [common.CONTROL_CHECK, 		self.controlchannel.cmh_check_query, 1, True, False],
			1  : [common.CONTROL_CHECK_RESULT, 	self.controlchannel.cmh_check_check, 0, True, False],
			2  : [common.CONTROL_AUTH, 			self.controlchannel.cmh_auth, 1, True, False],
			3  : [common.CONTROL_AUTH_OK, 		self.controlchannel.cmh_auth_ok, 0, True, False],
			4  : [common.CONTROL_AUTH_NOTOK, 	self.controlchannel.cmh_auth_not_ok, 0, True, False],
			5  : [common.CONTROL_LOGOFF, 		self.controlchannel.cmh_logoff, 1, False, False]
		}

		self.packet_writer = self.packet_writer_default
		self.packet_reader = self.packet_reader_default
		self.communication = self.communication_unix

		if self.os_type == common.OS_WINDOWS:
			self.packet_writer = self.packet_writer_win
			self.communication = self.communication_win
			self.packet_reader = None

		if self.os_type == common.OS_MACOSX:
			self.packet_writer = self.packet_writer_mac
			self.packet_reader = self.packet_reader_mac

		return
Ejemplo n.º 2
0
    def __init__(self):
        super(Stateless_module, self).__init__()
        self.checks = checks.Checks()
        self.timeout = 1.0
        self.controlchannel = controlchannel.ControlChannel()

        # control message handlers
        self.cmh_struct = {
            # num : [string to look for, function, server(1) or client(0), return on success, return on failure]
            # return value meanings: True  - module continues
            #						 False - module thread terminates
            # in case of Stateless modules, the whole module terminates if the return value is False
            0: [
                common.CONTROL_CHECK, self.controlchannel.cmh_check_query, 1,
                True, True
            ],
            1: [
                common.CONTROL_CHECK_RESULT,
                self.controlchannel.cmh_check_check, 0, True, False
            ],
            2:
            [common.CONTROL_INIT, self.controlchannel.cmh_init, 1, True, True],
            3: [
                common.CONTROL_INIT_DONE, self.controlchannel.cmh_init_done, 0,
                True, False
            ],
            4: [
                common.CONTROL_LOGOFF, self.controlchannel.cmh_logoff, 1, True,
                False
            ],
            5: [
                common.CONTROL_DUMMY_PACKET,
                self.controlchannel.cmh_dummy_packet, 1, True, True
            ],
        }

        # reading/writing packets can be different based on the OS
        self.packet_writer = self.packet_writer_default
        self.packet_reader = self.packet_reader_default
        # different communication function for Unix and Windows
        self.communication = self.communication_unix

        # setting up for Windows
        if self.os_type == common.OS_WINDOWS:
            self.packet_writer = self.packet_writer_win
            self.communication = self.communication_win
            self.packet_reader = None

        # setting up for MacOS(X)
        if self.os_type == common.OS_MACOSX:
            self.packet_writer = self.packet_writer_mac
            self.packet_reader = self.packet_reader_mac

        return
Ejemplo n.º 3
0
    def __init__(self, data, deterministic_data, metadata):

        curdoc().title = "Verificarlo Report"

        self.data = data
        self.deterministic_data = deterministic_data
        self.metadata = metadata

        # Initialize repository selection

        # Generate display names for repositories
        remote_urls = self.metadata["remote_url"].drop_duplicates().to_list()
        branches = self.metadata["branch"].drop_duplicates().to_list()
        repo_names_dict = helper.gen_repo_names(remote_urls, branches)
        self.metadata["repo_name"] = self.metadata["remote_url"].apply(
            lambda x: repo_names_dict[x]
        )

        # Add the repository selection widget
        select_repo = Select(
            name="select_repo", title="",
            value=list(repo_names_dict.values())[0],
            options=list(repo_names_dict.values())
        )
        curdoc().add_root(select_repo)

        select_repo.on_change("value", self.change_repo)

        change_repo_callback_js = "changeRepository(cb_obj.value);"
        select_repo.js_on_change(
            "value",
            CustomJS(code=change_repo_callback_js)
        )

        # Invert key/values for repo_names_dict and pass it to the template as
        # a JSON string
        repo_names_dict = {
            value: key for key,
            value in repo_names_dict.items()}
        curdoc().template_variables["repo_names_dict"] = json.dumps(
            repo_names_dict)

        # Pass metadata to the template as a JSON string
        curdoc().template_variables["metadata"] = self.metadata.to_json(
            orient="index")

        # Show the first repository by default
        repo_name = list(repo_names_dict.keys())[0]

        # Filter metadata by repository
        filtered_metadata = self.metadata[
            self.metadata["repo_name"] == repo_name
        ]

        # Filter data and deterministic_data by repository
        if not data.empty:
            filtered_data = self.data[
                helper.filterby_repo(
                    self.metadata, repo_name, self.data["timestamp"]
                )
            ]
        else:
            filtered_data = data

        if not deterministic_data.empty:
            filtered_deterministic_data = self.deterministic_data[
                helper.filterby_repo(
                    self.metadata, repo_name, self.deterministic_data["timestamp"]
                )
            ]
        else:
            filtered_deterministic_data = deterministic_data

        # Initialize views

        # Initialize runs comparison
        self.compare = compare_runs.CompareRuns(
            master=self,
            doc=curdoc(),
            data=filtered_data,
            metadata=filtered_metadata
        )

        # Initialize deterministic runs comparison
        self.deterministic = deterministic_compare.DeterministicCompare(
            master=self,
            doc=curdoc(),
            data=filtered_deterministic_data,
            metadata=filtered_metadata
        )

        # Initialize runs inspection
        self.inspect = inspect_runs.InspectRuns(
            master=self,
            doc=curdoc(),
            data=filtered_data,
            metadata=filtered_metadata
        )

        # Initialize checks table view
        self.checks = checks.Checks(
            master=self,
            doc=curdoc(),
            data=filtered_data,
            deterministic_data=filtered_deterministic_data,
            metadata=filtered_metadata
        )