Closed SimPilotAdamT closed 2 years ago
(Posting here cos the debug info gitched out the original message)
OS: Arch Linux Method of installing fetchcord: AUR
The uptime as shown in the actual rich presence resets itself roughly every 24 hours, since it runs on UNIX Epoch time.
I am uncure of how this could be fixed.... Maybe see if the time can be stored in some C datetime format instead?
(Posting here cos the debug info gitched out the original message)
Operating system & way of installation
OS: Arch Linux Method of installing fetchcord: AUR
Error/issue
The uptime as shown in the actual rich presence resets itself roughly every 24 hours, since it runs on UNIX Epoch time.
Other notes(optional)
I am uncure of how this could be fixed.... Maybe see if the time can be stored in some C datetime format instead?
Mine does too on iMac, isn't it supposed to?
Mine does too on iMac, isn't it supposed to?
No, it isn't... I started to think it was an issue with Discord's RPC API but I saw it working with a custom RPC script I was using (with NodeJS as the backend). The script I was using stored the bootup time as a UNIX Epoch value, correct to the second (in seconds after the First of January 1970).
Mine does too on iMac, isn't it supposed to?
No, it isn't... I started to think it was an issue with Discord's RPC API but I saw it working with a custom RPC script I was using (with NodeJS as the backend). The script I was using stored the bootup time as a UNIX Epoch value, correct to the second (in seconds after the First of January 1970).
I do feel like I saw something in the code a week or so ago, but when looking for it again today, I could not find it. I'll look into this soon.
The only instance of a uptime (that I can find), being mentioned is found in this file: fetch_cord/computer/Computer.py, on lines 39 and 303. Has something to do with the psutil.boot_time
(found in line 303 of this repository), so I would check that file if possible.
I think that will have to be it... I'm 90% certain that psutil boot time should be given in Unix Epoch anyways so idk what could be causing the issue... I'll check the file myself and see.
Just checked, and it looks like it does, _pslinux.py (I think it is line 1574?).
Here is the code block:
def boot_time():
"""Return the system boot time expressed in seconds since the epoch."""
global BOOT_TIME
path = '%s/stat' % get_procfs_path()
with open_binary(path) as f:
for line in f:
if line.startswith(b'btime'):
ret = float(line.strip().split()[1])
BOOT_TIME = ret
return ret
raise RuntimeError(
"line 'btime' not found in %s" % path)
Yep that does return it correctly according to the comment and the output of when I ran it...
Though I got thinking, that could be rduced to less lines of code, using the os
module.
def boot_time():
"""Return the system boot time expressed in seconds since the epoch."""
from os import popen
return popen('stat -c %Z /proc/').read().strip()
Could that work?
Yep that does return it correctly according to the comment and the output of when I ran it...
Though I got thinking, that could be rduced to less lines of code, using the
os
module.def boot_time(): """Return the system boot time expressed in seconds since the epoch.""" from os import popen stream = popen('stat -c %Z /proc/') return stream.read()
Could that work?
I could try it, but that'd be tomorrow probably. I have to open up my raspberry pi now 😀
Just tested it, it works on all of my machines and virtual machines.
Just tested it, it works on all of my machines and virtual machines.
Edited the code to remove all whitespace outputted by that command.
Just tested it, it works on all of my machines and virtual machines.
Edited the code to remove all whitespace outputted by that command.
So did it fix FetchCord timing, or just psutil?
So did it fix FetchCord timing, or just psutil?
Seems like it did fix fetchcord as well on my machine yeah.
So did it fix FetchCord timing, or just psutil?
Seems like it did fix fetchcord as well on my machine yeah.
Nice! Any PR is accepted, especially ones that fix bugs :) (Although I would change the function name slightly, to avoid confusion between psutil and this)
Nice! Any PR is accepted, especially ones that fix bugs :) (Although I would change the function name slightly, to avoid confusion between psutil and this)
If I make a PR there in the linked file it tried to make the PR for PSUTIL and not here on Fetchcord...
EDIT: Found a way to make it work on here (https://github.com/MrPotatoBobx/FetchCord/blob/master/fetch_cord/computer/Computer.py#L303), but it will only work on UNIX-Based OS's... Trying to edit my function accordingly now.
Debug info