#!/usr/bin/python3
import time
WAITTIME = 1
BUMPTIME = WAITTIME + 10
last = time.time()
while True:
time.sleep(WAITTIME)
now = time.time()
if (now - last) > BUMPTIME:
print('We suspended')
else:
print('We did not suspend')
last = now
def main():
lastS = int(strftime("%S", gmtime()))
lastM = int(strftime("%M", gmtime()))
lastH = int(strftime("%H", gmtime()))
while True:
difS = lastS - int(strftime("%S", gmtime()))
difM = lastM - int(strftime("%M", gmtime()))
difH = lastH - int(strftime("%H", gmtime()))
if difS < -1:
print('suspended')
if difM < 0 and difS != 59:
print('susp')
lastS = int(strftime("%S", gmtime()))
lastM = int(strftime("%M", gmtime()))
lastH = int(strftime("%H", gmtime()))
sleep(1)
It's a quick fix and not a very neat one but this works to check if computer was suspended or not! Thanks for the idea Morn
]]>I'm not in the position to check right now but I would think that then you have everything you could need, way more than enough in fact. Make sure that you don't have any of the packages installed by PIP or whatever as well, that might lead to conflicts. Everything you need is definitely in the official repositories, so get rid of everything from the AUR , PIP, and other sources.
If that also doesn't work, maybe you'd have to search in the direction of gi-repository's internals, maybe there's some weird caching involved. But I can't imagine it to be a problem there, it Just Worked (TM) on my machine and I've never done Python development.
Tomorrow morning I'm leaving for a computer-free vacation (aka a scouting camp) so I'm afraid I won't be able to help you further any time soon. Hopefully the others remain vigilant
]]>If you've got something python/glib/gobject-related for that package, then what?
]]>gobject-introspection-runtime 1.56.1-1
pygobject-devel 3.28.3-1
pygobject2-devel 2.28.7-1
python-gobject 3.28.3-1
python2-gobject2 2.28.7-1
gi 0.1.2-1
gtk2 2.24.32-1
gtk3 3.22.30-1
pygtk 2.24.0-8
glib2 2.56.1-1
dbus 1.12.8-1
dbus-glib 0.110-1
python-dbus 1.2.8-1
python-dbus-common 1.2.8-1
And I still can't import GLib or Gio from anything other than overrides but overrides give me the error I mentioned. I've installed most of the stuff through regular Pacman and some from AUR. gobject-introspection-runtime was already installed when I made the post.
]]>from gi.overrides import GLib
from gi.overrides import Gio
But these imports give me errors
Traceback (most recent call last):
File "/home/archuser/py.py", line 7, in <module>
from gi.overrides import GLib
File "/usr/lib/python3.6/site-packages/gi/overrides/GLib.py", line 501, in <module>
MainLoop = override(MainLoop)
File "/usr/lib/python3.6/site-packages/gi/overrides/__init__.py", line 207, in override
module = sys.modules["gi.repository." + namespace]
KeyError: 'gi.repository.GLib'
But maybe all you need is to understand that these are dynamic bindings/imports. (Follow Steef435's example and don't try something like dir(gi.repository).)
]]>python-gobject is a repository package, too -- due to the fact that large parts of an entire programming language, plus multiple desktop environments (have you ever heard of gnome? Right, they're the ones who invented gobject, and they use it major time) depend on it.
I have no idea how screwed up your installation might be if you installed some mysterious AUR package instead. It's entirely plausible that you're missing core requirements like the base runtime libraries.
]]>I think that the packages glib2 (providing GLib, Gio) and python-gobject (which provides gi.repository so you get the Python bindings) from the main repositories should be sufficient, definitely no need for the gi from the AUR.
(Seeing that you don't have GLib installed already: it's probably also possible to use Qt for the D-Bus part, but I've never used Qt myself)
]]>