def run_test(case): kb = PropKB() p = IOParser() input_data: InputParser = p.load_input("input/{}.txt".format(case)) kb.tell_batch(input_data.input_clauses) #kb.tell(['-A', 'B']) #kb.tell(['B', '-C']) #kb.tell(['A', '-B', 'C']) # kb.tell(['-B']) reslt, list_clause = pl_resolution(kb, input_data.query_alpha) output_result("output/{}.txt".format(case), reslt, list_clause) print('YES' if reslt else 'NO')
from io_parser import IOParser # video io from videoreader import VideoReader from videowriter import VideoWriter # OpenCV import cv2 if __name__ == '__main__': parser = IOParser() reader = VideoReader(parser.input_file) writer = VideoWriter(parser.output_file, reader.fps, (reader.width, reader.height), color=False) ''' OpenCV allows for you to easily switch between colorspaces using the cvtColor method Note - no video players will be able to play a single channel grayscale video so each channel, R,G,B are given the same intensity values to represent grayscale. ''' for frame in reader: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) ''' if we didn't specify that our VideoWriter is grayscale, we would have to convert back to BGR to output a playable version. ''' # to_bgr = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR) writer.write_frame(gray) writer.close() reader.close()
print("********** ADDRESS NOT FOUND - Please submit revised I/O list. **********") print(packet_contents) sys.exit(3) #for key in final_dict: #print(key) #for item in final_dict[key]: #print(item) #for thing in final_dict[key][item]: #print(thing) return final_dict if __name__ == '__main__': #1. Parse IO list parser = IOParser() #try: parser.parseList("/sne/home/pprjevara/projects/virtuaplant/documentation/modbus_io_list.csv") modbus_device_list = parser.generateDataStructure() #all devices lists should be indexed based on the addresses they are using, so when #a packet is captured, the respective device can be filtered out easily #print(modbus_modbus_device_list) #protocol can also be sniffed but for proof of concept we will just assume modbus only protocols = ["modbus"] protocolVariables = setProtocolVariables(protocols) #2. Start learning phase - learn valid states and the sequence that they follow each other in capture = pyshark.LiveCapture(interface='lo') myDissector = Dissector()