Пример #1
0
    def __init__(self, num_rows=20, w=(14, 14, 18, 16, 16, 16, 20)):
        """
            @method __init__
            Initializes the widget
        """
        self.m_process_list = ProcessList(w)
        self.prev_sort_item = None

        self.w_status = HeaderButton('Status', 'status', self.handle_click)
        self.w_pid = HeaderButton('PID', 'pid', self.handle_click)
        self.w_name = HeaderButton('Name', 'name', self.handle_click)
        self.w_cpu = HeaderButton('CPU %', 'cpu_perc', self.handle_click)
        self.w_mem = HeaderButton('MEM %', 'mem_perc', self.handle_click)
        self.w_up = HeaderButton('Uptime', 'uptime', self.handle_click)
        self.w_pname = HeaderButton('Process', 'pname', self.handle_click)

        self.w_cpu.activate()
        self.prev_sort_item = self.w_cpu

        self.header_buttons = h = [
            self.w_status, self.w_pid, self.w_name, self.w_cpu, self.w_mem,
            self.w_up, self.w_pname
        ]

        m_header = AttrMap(
            Columns([('fixed', w[i], h[i]) for i in range(0, len(h))]),
            'invert')
        m_lb = ListBox(
            SimpleListWalker(
                [m_header, BoxAdapter(self.m_process_list, num_rows)]))
        super(ProcessTable, self).__init__(m_lb, None)
        self.update()
Пример #2
0
class process_monitor:

	_ProcessList=None
	_StatusLog=None
    	
	def __init__(self): # define process_monitor object with delay input
		self._ProcessList=ProcessList()
		self._StatusLog=StatusLog()

	def start_monitor(self,delay):	#start process monitor
		__delay =delay
		observer =FilesHandler.Observer()
        	observer.schedule(FilesHandler.MyHandler(), '.')
		observer.start()
		while(1):
			Current_psutil = psutil
			self._ProcessList.write(Current_psutil,datetime.datetime.now().strftime("%y-%m-%d %H-%M"))
			self._StatusLog.write(Current_psutil,time.ctime())	
           	 	time.sleep(__delay)

	def check_samples(self):  #check the difference between the sampels
       		good_input = False
       		while not good_input:
           		first_date = raw_input("Enter Date of sample (yy-mm-dd hh-mm): ")
           		try:  
                		userIn = datetime.datetime.strptime(first_date, "%y-%m-%d %H-%M")
               			good_input = True
           		except:
                		print "Input doesn't match the pattern, try again!\n"
        			good_input = False
		good_input = False
        	while not good_input:
          		second_date = raw_input("Enter Date of later sample (yy-mm-dd hh-mm): ")
            		try: 
                		userIn = datetime.datetime.strptime(second_date, "%y-%m-%d %H-%M")
                		good_input = True
            		except:
                		print "Input doesn't match the pattern, try again!\n"
				good_input=False
		first_sample = self._ProcessList.find_sample(first_date)
       		second_sample = self._ProcessList.find_sample(second_date)

		new_process = []
           	not_alive_process = []
            	for pid in second_sample:
                	if pid not in first_sample:
                    		new_process.append(pid)
          	for pid in first_sample:
               		if pid not in second_sample:
                  		not_alive_process.append(pid)
	
		if(new_process):
            		print('new processes:' + '\n')
            		for pid in new_process:
                		print("pid: "+str(pid))
		if(not_alive_process):
         		print('processes that not alive anymore:' + '\n')
            		for pid in not_alive_process:
                		print("pid: "+str(pid))
Пример #3
0
    def readChild(self, child):
        elementType = self.getElementType(child.tag)
        elementClass = ProcessList.getClass(elementType)
        #print( elementType, elementClass )

        if elementClass != None:
            element = elementClass()
            element.read(child)

            processNodeClass = ProcessList.getClass("ProcessNode")
            if issubclass(elementClass, processNodeClass):
                self.addProcess( element )
            else:
                self.addElement( element )
        else:
            print( "Group::read - Ignoring element : %s" % child.tag)

        return None
Пример #4
0
    def readChild(self, child):
        elementType = child.tag.replace('-', '')
        elementType = child.tag.replace('_', '')
        elementClass = ProcessList.getClass(elementType)
        #print( elementType, elementClass )

        if elementClass != None:
            element = elementClass()
            element.read(child)

            processNodeClass = ProcessList.getClass("ProcessNode")
            if issubclass(elementClass, processNodeClass):
                self.addProcess( element )
            else:
                self.addElement( element )
        else:
            print( "Group::read - Ignoring element : %s" % child.tag)

        return None
Пример #5
0
    def write(self, tree, writeSelfContained=False):
        node = ProcessNode.write(self, tree)

        # Add ProcessNode elements
        for process in self._processes:
            # Choose whether to write Reference node or nodes referred to
            if isinstance(process, ProcessList.getClass("Reference")):
                process.setWriteReferencedNodes(writeSelfContained)
            process.write(node)
        
        return node
Пример #6
0
    def write(self, tree, writeSelfContained=False):
        node = ProcessNode.write(self, tree)

        # Add ProcessNode elements
        for process in self._processes:
            # Choose whether to write Reference node or nodes referred to
            if isinstance(process, ProcessList.getClass("Reference")):
                process.setWriteReferencedNodes(writeSelfContained)
            process.write(node)
        
        return node
Пример #7
0
    def windowDidLoad(self):
        NSWindowController.windowDidLoad(self)

        device = [
            device
            for device in frida.get_device_manager().enumerate_devices()
            if device.type == 'local'
        ][0]
        self.processList = ProcessList(device)
        self.capture = Capture(device)
        self.processCombo.setUsesDataSource_(True)
        self.processCombo.setDataSource_(self.processList)
        self.capture.setDelegate_(self)

        self.callTableView.setDataSource_(self.capture.calls)
        self.capture.calls.setDelegate_(self)

        self.loadDefaults()

        self.updateAttachForm_(self)
Пример #8
0
 def killChildProcesses(self,parent_pid=None):
     p = ProcessList()
     child_pid = p.getChildren(parent_pid)
     for pid in child_pid:
         os.kill(pid, signal.SIGTERM)
Пример #9
0
    game.restart()
    return game.getOutput()


# Log received messages
def logger(update):
    print("%i > %s" % (update.chat.id, update.text))


#
# MAIN:
#
if __name__ == "__main__":
    # create games list
    global games
    games = ProcessList()
    # intercept SIGINT (Ctrl+C) and SIGTERM
    signal.signal(signal.SIGINT, exitGracefully)
    signal.signal(signal.SIGTERM, exitGracefully)
    # create bot
    bot = botbuilder.BotBuilder(apikey_file="apikey.txt")
    # bot actions
    bot.do_when(lambda update: (True), logger, botbuilder.DO_NOT_CONSUME)
    bot.send_message_when("start", start)
    bot.send_message_when("cave", process_input)
    bot.send_message_when("help", help_text)
    bot.send_message_when("restart", restart)
    # create bot and launch it
    bot.build().start()
Пример #10
0
	def __init__(self): # define process_monitor object with delay input
		self._ProcessList=ProcessList()
		self._StatusLog=StatusLog()
Пример #11
0
 def __init__(self):
     # take user input for rows using helper input function to make sure input is valid
     rows = self.input_valid_dim('row')
     # we loop over the input for columns until user inputs a value different from the rows value
     while 1:
         cols = self.input_valid_dim('col')
         if not cols == rows:
             break
         # prompt is displayed to user if they input the same number as for rows
         print('Number of columns is the same as number of rows!')
     # instance of ProcessList is created and valid values of rows and columns are passed to it
     process = PL(rows, cols)
     # we call randomlyFillList using the instance we created to fill its respective list
     process.randomlyFillList()
     # we call computeListValues using the instance we created to fill its respective list
     process.computeListValues()
     # header line to indicate which list is being printed is output
     print('\n\nInitial list with random numbers:\n')
     # ProcessList's printList function is called, and using an accessor, we pass the process instance's rand list
     process.printList(process.get_rand_list())
     # header line to indicate which list is being printed is output
     print('\n\nComputed list:\n')
     # ProcessList's printList function is called, using an accessor, we pass the process instance's computed list
     process.printList(process.get_adj_sum_list())