forked from jan/mem_edit
try to reduce log spam
This commit is contained in:
parent
6ab295fc26
commit
5a032da984
@ -13,7 +13,6 @@ from . import utils
|
|||||||
from .utils import ctypes_buffer_t
|
from .utils import ctypes_buffer_t
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ from .abstract import Process as AbstractProcess
|
|||||||
from .utils import ctypes_buffer_t, MemEditError
|
from .utils import ctypes_buffer_t, MemEditError
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -94,14 +93,14 @@ class Process(AbstractProcess):
|
|||||||
def get_pid_by_name(target_name: str) -> Optional[int]:
|
def get_pid_by_name(target_name: str) -> Optional[int]:
|
||||||
for pid in Process.list_available_pids():
|
for pid in Process.list_available_pids():
|
||||||
try:
|
try:
|
||||||
logger.info('Checking name for pid {}'.format(pid))
|
logger.debug('Checking name for pid {}'.format(pid))
|
||||||
with open('/proc/{}/cmdline'.format(pid), 'rb') as cmdline:
|
with open('/proc/{}/cmdline'.format(pid), 'rb') as cmdline:
|
||||||
path = cmdline.read().decode().split('\x00')[0]
|
path = cmdline.read().decode().split('\x00')[0]
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
logger.info('Name was "{}"'.format(name))
|
logger.debug('Name was "{}"'.format(name))
|
||||||
if path is not None and name == target_name:
|
if path is not None and name == target_name:
|
||||||
return pid
|
return pid
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ from .abstract import Process as AbstractProcess
|
|||||||
from .utils import ctypes_buffer_t, MemEditError
|
from .utils import ctypes_buffer_t, MemEditError
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -229,18 +228,18 @@ class Process(AbstractProcess):
|
|||||||
def get_pid_by_name(target_name: str) -> Optional[int]:
|
def get_pid_by_name(target_name: str) -> Optional[int]:
|
||||||
for pid in Process.list_available_pids():
|
for pid in Process.list_available_pids():
|
||||||
try:
|
try:
|
||||||
logger.info('Checking name for pid {}'.format(pid))
|
logger.debug('Checking name for pid {}'.format(pid))
|
||||||
with Process.open_process(pid) as process:
|
with Process.open_process(pid) as process:
|
||||||
path = process.get_path()
|
path = process.get_path()
|
||||||
|
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
logger.info('Name was "{}"'.format(name))
|
logger.debug('Name was "{}"'.format(name))
|
||||||
if path is not None and name == target_name:
|
if path is not None and name == target_name:
|
||||||
return pid
|
return pid
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
except MemEditError as err:
|
except MemEditError as err:
|
||||||
logger.info(repr(err))
|
logger.debug(repr(err))
|
||||||
|
|
||||||
logger.info('Found no process with name {}'.format(target_name))
|
logger.info('Found no process with name {}'.format(target_name))
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user