def is_running(self): """Return whether the program is currently running""" resp_cli="" logger = logging.getLogger(__name__) for running in self.running: test = running[0] pathname = running[1] if 'exe' == test and 'posix' == os.name: if Unix.is_running(pathname): #print "debug: process '%s' is running" % pathname logger.debug("Debug: process '%s' is running", pathname) if options.get("close_run"): if not subprocess.mswindows: #print "debug: Closing process '%s'" % pathname if "--preset" in sys.argv: resp_cli = raw_input("Do you Want BleachBit to Close " + pathname + " y/n : ") else: resp = GuiBasic.message_dialog(None,"Do you Want BleachBit to Close " + pathname,gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO) if gtk.RESPONSE_YES == resp or resp_cli.lower() == "y": # user cancelled, so don't toggle option logger.debug("Debug: Closing process '%s'",pathname) subprocess.check_output(["killall", "-9", pathname]) if not Unix.is_running(pathname): logger.debug("Debug: Closing process '%s' successful",pathname) return False return True elif 'exe' == test and 'nt' == os.name: if Windows.is_process_running(pathname): #print "debug: process '%s' is running" % pathname logger.debug("Debug: process '%s' is running", pathname) if options.get("close_run"): if subprocess.mswindows: #print "debug: Closing process '%s'" % pathname if "--preset" in sys.argv: resp_cli = raw_input("Do you Want BleachBit to Close " + pathname + " y/n : ") else: resp = GuiBasic.message_dialog(None,"Do you Want BleachBit to Close " + pathname,gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO) if gtk.RESPONSE_YES == resp or resp_cli.lower() == "y": logger.debug("debug: Closing process '%s'",pathname) subprocess.check_output(["taskkill", "/IM", pathname]) if not Windows.is_process_running(pathname): logger.debug("debug: Closing process '%s' successful",pathname) return False logger.debug("process '%s' is running", pathname) return True elif 'exe' == test and 'nt' == os.name: if Windows.is_process_running(pathname): logger.debug("process '%s' is running", pathname) return True elif 'pathname' == test: expanded = expanduser(expandvars(pathname)) for globbed in glob.iglob(expanded): if os.path.exists(globbed): logger.debug("file '%s' exists indicating '%s' is running", self.name) return True else: raise RuntimeError( "Unknown running-detection test '%s'" % test) return False
def is_running(self): """Return whether the program is currently running""" logger = logging.getLogger(__name__) for running in self.running: test = running[0] pathname = running[1] if 'exe' == test and 'posix' == os.name: if Unix.is_running(pathname): logger.debug("process '%s' is running", pathname) return True elif 'exe' == test and 'nt' == os.name: if Windows.is_process_running(pathname): logger.debug("process '%s' is running", pathname) return True elif 'pathname' == test: expanded = expanduser(expandvars(pathname)) for globbed in glob.iglob(expanded): if os.path.exists(globbed): logger.debug( "file '%s' exists indicating '%s' is running", globbed, self.name) return True else: raise RuntimeError("Unknown running-detection test '%s'" % test) return False
def is_running(self): """Return whether the program is currently running""" logger = logging.getLogger(__name__) for running in self.running: test = running[0] pathname = running[1] if 'exe' == test and 'posix' == os.name: if Unix.is_running(pathname): logger.debug("process '%s' is running", pathname) return True elif 'exe' == test and 'nt' == os.name: if Windows.is_process_running(pathname): logger.debug("process '%s' is running", pathname) return True elif 'pathname' == test: expanded = expanduser(expandvars(pathname)) for globbed in glob.iglob(expanded): if os.path.exists(globbed): logger.debug( "file '%s' exists indicating '%s' is running", globbed, self.name) return True else: raise RuntimeError( "Unknown running-detection test '%s'" % test) return False
def is_running(self): """Return whether the program is currently running""" # 프로그램이 현재 실행 중인지 여부를 반환하는 함수 logger = logging.getLogger(__name__) # __name__에서 로거 추출 for running in self.running: # running 리스트의 값들 반복 test = running[0] # running[0] = detection_type ( add_running 함수 참고) pathname = running[1] if 'exe' == test and 'posix' == os.name: # os이름이 posix이고 exe 타입인지 확인 if Unix.is_running(pathname): # Unix에서 is_running함수썼을때 True이면 logger.debug("process '%s' is running", pathname) # 프로세스가 실행중이라는 debug 메세지를 로그하고 True반환 return True elif 'exe' == test and 'nt' == os.name: # os이름이 nt 이고 exe타입인지 확인 if Windows.is_process_running(pathname): # 만약 Windows에서 is_process_running 함수를 사용했을때 true이면 logger.debug("process '%s' is running", pathname) # 프로세스가 실행중이라는 debug 메세지를 로그하고 true반환 return True elif 'pathname' == test: # test expanded = expanduser(expandvars(pathname)) # pathname 안에 환경변수가 있으면 확장하고 현재 사용자 디렉토리의 절대경로로 대체 # ex) C:\\Documents and Settings\\Administrator\\pathname for globbed in glob.iglob(expanded): # iglob() : expanded의 모든 값을 실제로 동시에 저장하지 않고 # glob()값과 동일한 값을 산출하는 반복기를 반환함 if os.path.exists(globbed): # globbed로 저장한 경로에 특정파일이 존재하는지 확인 logger.debug( "file '%s' exists indicating '%s' is running", globbed, self.name) # 존재하면 파일이 존재하며 실행중임을 나타내는 메세지출력 return True else: raise RuntimeError( "Unknown running-detection test '%s'" % test) # test가 exe , pathname도 아니면 알수없는 실행타입메세지와 함께 런타임에러발생 return False