Modernize code for easier Python 3 port
- Replace print statement with function call - Replace except ..., ...: syntax with except ... as ...: - Simplify obsolete try ... except ... code block - Replace some unicode calls with u-prefixed strings - Do not use `len(SEQUENCE)` to determine if a sequence is empty - Replace dictionary creation - Drop support for GObject static bindings
This commit is contained in:
13
whipper/extern/task/task.py
vendored
13
whipper/extern/task/task.py
vendored
@@ -22,10 +22,7 @@ from __future__ import print_function
|
||||
import logging
|
||||
import sys
|
||||
|
||||
try:
|
||||
from gi.repository import GLib as gobject
|
||||
except ImportError:
|
||||
import gobject
|
||||
from gi.repository import GLib as GLib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -463,7 +460,7 @@ class TaskRunner(LogStub):
|
||||
|
||||
class SyncRunner(TaskRunner, ITaskListener):
|
||||
"""
|
||||
I run the task synchronously in a gobject MainLoop.
|
||||
I run the task synchronously in a GObject MainLoop.
|
||||
"""
|
||||
|
||||
def __init__(self, verbose=True):
|
||||
@@ -478,11 +475,11 @@ class SyncRunner(TaskRunner, ITaskListener):
|
||||
self._verboseRun = verbose
|
||||
self._skip = skip
|
||||
|
||||
self._loop = gobject.MainLoop()
|
||||
self._loop = GLib.MainLoop()
|
||||
self._task.addListener(self)
|
||||
# only start the task after going into the mainloop,
|
||||
# otherwise the task might complete before we are in it
|
||||
gobject.timeout_add(0L, self._startWrap, self._task)
|
||||
GLib.timeout_add(0L, self._startWrap, self._task)
|
||||
self.debug('run loop')
|
||||
self._loop.run()
|
||||
|
||||
@@ -526,7 +523,7 @@ class SyncRunner(TaskRunner, ITaskListener):
|
||||
self.debug('schedule: scheduling %r(*args=%r, **kwargs=%r)',
|
||||
callable, args, kwargs)
|
||||
|
||||
gobject.timeout_add(int(delta * 1000L), c)
|
||||
GLib.timeout_add(int(delta * 1000L), c)
|
||||
|
||||
# ITaskListener methods
|
||||
def progressed(self, task, value):
|
||||
|
||||
Reference in New Issue
Block a user