示例#1
0
 def ionice():
     try:
         if self.options.processes:
             pid = self.prompt_pid()
             exec_unit = self.process_list.get_process(pid)
         else:
             tid = self.prompt_tid()
             exec_unit = ThreadInfo(
                 tid, self.process_list.taskstats_connection)
         ioprio_value = exec_unit.get_ioprio()
         (ioprio_class, ioprio_data) = \
                                  ioprio.to_class_and_data(ioprio_value)
         ioprio_class = self.prompt_class(ioprio_class)
         if ioprio_class == 'idle':
             ioprio_data = 0
         else:
             ioprio_data = self.prompt_data(ioprio_data)
         exec_unit.set_ioprio(ioprio_class, ioprio_data)
         self.process_list.clear()
         self.process_list.refresh_processes()
     except IoprioSetError as e:
         self.prompt_error('Error setting I/O priority: %s' % e.err)
     except InvalidPid:
         self.prompt_error('Invalid process id!')
     except InvalidTid:
         self.prompt_error('Invalid thread id!')
     except InvalidIoprioData:
         self.prompt_error('Invalid I/O priority data!')
     except InvalidInt:
         self.prompt_error('Invalid integer!')
     except CancelInput:
         self.prompt_clear()
     else:
         self.prompt_clear()
示例#2
0
文件: ui.py 项目: liu-chong/iotop
 def ionice():
     try:
         if self.options.processes:
             pid = self.prompt_pid()
             exec_unit = self.process_list.get_process(pid)
         else:
             tid = self.prompt_tid()
             exec_unit = ThreadInfo(tid,
                                 self.process_list.taskstats_connection)
         ioprio_value = exec_unit.get_ioprio()
         (ioprio_class, ioprio_data) = \
                                  ioprio.to_class_and_data(ioprio_value)
         ioprio_class = self.prompt_class(ioprio_class)
         if ioprio_class == 'idle':
             ioprio_data = 0
         else:
             ioprio_data = self.prompt_data(ioprio_data)
         exec_unit.set_ioprio(ioprio_class, ioprio_data)
         self.process_list.clear()
         self.process_list.refresh_processes()
     except IoprioSetError as e:
         self.prompt_error('Error setting I/O priority: %s' % e.err)
     except InvalidPid:
         self.prompt_error('Invalid process id!')
     except InvalidTid:
         self.prompt_error('Invalid thread id!')
     except InvalidIoprioData:
         self.prompt_error('Invalid I/O priority data!')
     except InvalidInt:
         self.prompt_error('Invalid integer!')
     except CancelInput:
         self.prompt_clear()
     else:
         self.prompt_clear()