astlog
astlog copied to clipboard
astlog not working in MacOS environments
Hello!
First of all thanks for your amazing tool, it has made my life way easier :)
I recently switched to a MacOS environment and when I try to use the tool I get an error about a file missing:
(astlog) gonzalo@XXXX ~ % astlog $PWD/sip.log
Traceback (most recent call last):
File "/Users/gonzalo/astlog/astlog/app.py", line 1112, in run
self.loop.run()
File "/Users/gonzalo/.virtualenvs/astlog/lib/python3.9/site-packages/urwid-2.6.10-py3.9.egg/urwid/event_loop/main_loop.py", line 337, in run
self._run()
File "/Users/gonzalo/.virtualenvs/astlog/lib/python3.9/site-packages/urwid-2.6.10-py3.9.egg/urwid/event_loop/main_loop.py", line 439, in _run
self.event_loop.run()
File "/Users/gonzalo/.virtualenvs/astlog/lib/python3.9/site-packages/urwid-2.6.10-py3.9.egg/urwid/event_loop/select_loop.py", line 182, in run
self._loop()
File "/Users/gonzalo/.virtualenvs/astlog/lib/python3.9/site-packages/urwid-2.6.10-py3.9.egg/urwid/event_loop/select_loop.py", line 224, in _loop
alarm_callback()
File "/Users/gonzalo/.virtualenvs/astlog/lib/python3.9/site-packages/urwid-2.6.10-py3.9.egg/urwid/event_loop/main_loop.py", line 218, in cb
callback(self, user_data)
File "/Users/gonzalo/astlog/astlog/app.py", line 1110, in <lambda>
self.loop.set_alarm_in(0, lambda loop, data: self.reload_file())
File "/Users/gonzalo/astlog/astlog/app.py", line 1035, in reload_file
self.parser.load_file(progress)
File "/Users/gonzalo/astlog/astlog/reader.py", line 559, in load_file
data = self.read_data()
File "/Users/gonzalo/astlog/astlog/reader.py", line 548, in read_data
mem_size = get_memory_size()
File "/Users/gonzalo/astlog/astlog/reader.py", line 1449, in get_memory_size
with open('/proc/meminfo') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/proc/meminfo'
I suspect this has to do with the get_memory_size
method:
Given that MacOS does not use /proc/ :
- is there any way to circumvent this memory size check?
- Alternatively, can we add support for it? -> Do you accept external PRs? I would not mind to try to fix it myself!
Best,
grubio
I ran into this issue also. You can replace get_memory_size()
in reader.py with this, and you'll be in good shape:
def get_memory_size():
try:
# Run the sysctl command to get memory information
sysctl_output = subprocess.check_output(['sysctl', 'hw.memsize']).decode('utf-8')
# Extract the memory size from the output
m = re.search(r'hw\.memsize:\s+(\d+)', sysctl_output)
if m:
mem_total_bytes = int(m.groups()[0])
return mem_total_bytes
except Exception as e:
print(f"Error retrieving memory size: {e}")
return None