Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
5d87134e
Commit
5d87134e
authored
Apr 06, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor DBus sleep inhibition testing and improve messages #522
parent
867e56cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
__init__.py
printrun/power/__init__.py
+14
-7
pronsole.py
printrun/pronsole.py
+2
-2
No files found.
printrun/power/__init__.py
View file @
5d87134e
...
...
@@ -15,6 +15,7 @@
import
platform
import
traceback
import
logging
import
os
if
platform
.
system
()
==
"Darwin"
:
...
...
@@ -37,6 +38,7 @@ else:
try
:
inhibit_sleep_handler
=
None
inhibit_sleep_token
=
None
bus
=
dbus
.
SessionBus
()
try
:
# GNOME uses the right object path, try it first
...
...
@@ -44,24 +46,29 @@ else:
proxy
=
bus
.
get_object
(
service_name
,
"/org/freedesktop/ScreenSaver"
)
inhibit_sleep_handler
=
dbus
.
Interface
(
proxy
,
service_name
)
# Do a test run
token
=
inhibit_sleep_handler
.
Inhibit
(
"printrun"
,
"test"
)
inhibit_sleep_handler
.
UnInhibit
(
token
)
except
dbus
.
DBusException
:
# KDE uses /ScreenSaver object path, let's try it as well
proxy
=
bus
.
get_object
(
service_name
,
"/ScreenSaver"
)
inhibit_sleep_handler
=
dbus
.
Interface
(
proxy
,
service_name
)
token
=
inhibit_sleep_handler
.
Inhibit
(
"printrun"
,
"test"
)
inhibit_sleep_handler
.
UnInhibit
(
token
)
def
inhibit_sleep
(
reason
):
global
inhibit_sleep_handler
inhibit_sleep
.
token
=
inhibit_sleep_handler
.
Inhibit
(
"printrun"
,
reason
)
global
inhibit_sleep_handler
,
inhibit_sleep_token
inhibit_sleep
_
token
=
inhibit_sleep_handler
.
Inhibit
(
"printrun"
,
reason
)
def
deinhibit_sleep
():
global
inhibit_sleep_handler
if
inhibit_sleep_handler
is
None
:
global
inhibit_sleep_handler
,
inhibit_sleep_token
if
inhibit_sleep_handler
is
None
or
inhibit_sleep_token
is
None
:
return
inhibit_sleep_handler
.
UnInhibit
(
inhibit_sleep
.
token
)
inhibit_sleep
.
token
=
None
inhibit_sleep_handler
.
UnInhibit
(
inhibit_sleep
_
token
)
inhibit_sleep
_
token
=
None
except
dbus
.
DBusException
,
e
:
print
"dbus unavailable:"
,
e
.
message
logging
.
warning
(
"Could not setup DBus for sleep inhibition:
%
s"
%
e
)
def
inhibit_sleep
(
reason
):
return
...
...
printrun/pronsole.py
View file @
5d87134e
...
...
@@ -1430,14 +1430,14 @@ class pronsole(cmd.Cmd):
try
:
powerset_print_start
(
reason
=
"Preventing sleep during print"
)
except
:
logging
.
error
(
_
(
"Failed to
inhibit sleep
:"
))
logging
.
error
(
_
(
"Failed to
set power settings
:"
))
traceback
.
print_exc
(
file
=
sys
.
stdout
)
def
endcb
(
self
):
try
:
powerset_print_stop
()
except
:
logging
.
error
(
_
(
"Failed to
uninhibit sleep
:"
))
logging
.
error
(
_
(
"Failed to
set power settings
:"
))
traceback
.
print_exc
(
file
=
sys
.
stdout
)
if
self
.
p
.
queueindex
==
0
:
print_duration
=
int
(
time
.
time
()
-
self
.
starttime
+
self
.
extra_print_time
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment