diff --git a/functions.py b/functions.py index 27283631..d5899c8c 100644 --- a/functions.py +++ b/functions.py @@ -1260,7 +1260,7 @@ def isocurve(data, level, connected=False, extendToEdge=False, path=False): points[b[1]].append([b,a]) ## rearrange into chains - for k in points.keys(): + for k in list(points.keys()): try: chains = points[k] except KeyError: ## already used this point elsewhere diff --git a/graphicsItems/GraphicsItem.py b/graphicsItems/GraphicsItem.py index c90821a3..94615fe3 100644 --- a/graphicsItems/GraphicsItem.py +++ b/graphicsItems/GraphicsItem.py @@ -4,7 +4,7 @@ from pyqtgraph.Point import Point import pyqtgraph.functions as fn import weakref from pyqtgraph.pgcollections import OrderedDict -import operator +import operator, sys class FiniteCache(OrderedDict): """Caches a finite number of objects, removing @@ -17,7 +17,7 @@ class FiniteCache(OrderedDict): self.pop(item, None) # make sure item is added to end OrderedDict.__setitem__(self, item, val) while len(self) > self._length: - del self[self.keys()[0]] + del self[list(self.keys())[0]] def __getitem__(self, item): val = dict.__getitem__(self, item) @@ -197,14 +197,14 @@ class GraphicsItem(object): ## check local cache if direction is None and dt == self._pixelVectorCache[0]: - return map(Point, self._pixelVectorCache[1]) ## return a *copy* + return tuple(map(Point, self._pixelVectorCache[1])) ## return a *copy* ## check global cache key = (dt.m11(), dt.m21(), dt.m31(), dt.m12(), dt.m22(), dt.m32(), dt.m31(), dt.m32()) pv = self._pixelVectorGlobalCache.get(key, None) if pv is not None: self._pixelVectorCache = [dt, pv] - return map(Point,pv) ## return a *copy* + return tuple(map(Point,pv)) ## return a *copy* if direction is None: diff --git a/graphicsItems/ROI.py b/graphicsItems/ROI.py index c3620edb..4da8fa4a 100644 --- a/graphicsItems/ROI.py +++ b/graphicsItems/ROI.py @@ -1808,7 +1808,7 @@ class LineSegmentROI(ROI): for i in range(len(imgPts)-1): d = Point(imgPts[i+1] - imgPts[i]) o = Point(imgPts[i]) - r = fn.affineSlice(data, shape=(int(d.length()),), vectors=[d.norm()], origin=o, axes=axes, order=1) + r = fn.affineSlice(data, shape=(int(d.length()),), vectors=[Point(d.norm())], origin=o, axes=axes, order=1) rgns.append(r) return np.concatenate(rgns, axis=axes[0]) diff --git a/graphicsItems/ScatterPlotItem.py b/graphicsItems/ScatterPlotItem.py index 2e41cb7c..0b422596 100644 --- a/graphicsItems/ScatterPlotItem.py +++ b/graphicsItems/ScatterPlotItem.py @@ -41,7 +41,7 @@ def drawSymbol(painter, symbol, size, pen, brush): if isinstance(symbol, basestring): symbol = Symbols[symbol] if np.isscalar(symbol): - symbol = Symbols.values()[symbol % len(Symbols)] + symbol = list(Symbols.values())[symbol % len(Symbols)] painter.drawPath(symbol) diff --git a/graphicsItems/ViewBox/ViewBox.py b/graphicsItems/ViewBox/ViewBox.py index ae7298ba..f5aa03b8 100644 --- a/graphicsItems/ViewBox/ViewBox.py +++ b/graphicsItems/ViewBox/ViewBox.py @@ -1198,7 +1198,7 @@ class ViewBox(GraphicsWidget): if ViewBox is None: ## can happen as python is shutting down return ## Called with ID and name of view (the view itself is no longer available) - for v in ViewBox.AllViews.keys(): + for v in list(ViewBox.AllViews.keys()): if id(v) == vid: ViewBox.AllViews.pop(v) break diff --git a/multiprocess/bootstrap.py b/multiprocess/bootstrap.py index 6ac9fce4..28818135 100644 --- a/multiprocess/bootstrap.py +++ b/multiprocess/bootstrap.py @@ -4,13 +4,19 @@ import sys, pickle, os if __name__ == '__main__': if hasattr(os, 'setpgrp'): os.setpgrp() ## prevents signals (notably keyboard interrupt) being forwarded from parent to this process - name, port, authkey, ppid, targetStr, path = pickle.load(sys.stdin) + if sys.version[0] == '3': + name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin.buffer) + else: + name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin) #print "key:", ' '.join([str(ord(x)) for x in authkey]) if path is not None: ## rewrite sys.path without assigning a new object--no idea who already has a reference to the existing list. while len(sys.path) > 0: sys.path.pop() sys.path.extend(path) + + if pyside: + import PySide #import pyqtgraph #import pyqtgraph.multiprocess.processes target = pickle.loads(targetStr) ## unpickling the target should import everything we need diff --git a/multiprocess/parallelizer.py b/multiprocess/parallelizer.py index c805cfdb..9925a573 100644 --- a/multiprocess/parallelizer.py +++ b/multiprocess/parallelizer.py @@ -1,6 +1,6 @@ import os, sys, time, multiprocessing, re -from processes import ForkedProcess -from remoteproxy import ClosedError +from .processes import ForkedProcess +from .remoteproxy import ClosedError class CanceledError(Exception): """Raised when the progress dialog is canceled during a processing operation.""" diff --git a/multiprocess/processes.py b/multiprocess/processes.py index 1103ef15..4c3be4e9 100644 --- a/multiprocess/processes.py +++ b/multiprocess/processes.py @@ -1,7 +1,11 @@ -from remoteproxy import RemoteEventHandler, ClosedError, NoResultError, LocalObjectProxy, ObjectProxy +from .remoteproxy import RemoteEventHandler, ClosedError, NoResultError, LocalObjectProxy, ObjectProxy import subprocess, atexit, os, sys, time, random, socket, signal -import cPickle as pickle import multiprocessing.connection +from pyqtgraph.Qt import USE_PYSIDE +try: + import cPickle as pickle +except ImportError: + import pickle __all__ = ['Process', 'QtProcess', 'ForkedProcess', 'ClosedError', 'NoResultError'] @@ -75,7 +79,10 @@ class Process(RemoteEventHandler): targetStr = pickle.dumps(target) ## double-pickle target so that child has a chance to ## set its sys.path properly before unpickling the target pid = os.getpid() # we must sent pid to child because windows does not have getppid - pickle.dump((name+'_child', port, authkey, pid, targetStr, sysPath), self.proc.stdin) + pyside = USE_PYSIDE + + ## Send everything the remote process needs to start correctly + pickle.dump((name+'_child', port, authkey, pid, targetStr, sysPath, pyside), self.proc.stdin) self.proc.stdin.close() ## open connection for remote process diff --git a/multiprocess/remoteproxy.py b/multiprocess/remoteproxy.py index 887d2e87..096f2006 100644 --- a/multiprocess/remoteproxy.py +++ b/multiprocess/remoteproxy.py @@ -1,6 +1,11 @@ -import os, __builtin__, time, sys, traceback, weakref -import cPickle as pickle +import os, time, sys, traceback, weakref import numpy as np +try: + import __builtin__ as builtins + import cPickle as pickle +except ImportError: + import builtins + import pickle class ClosedError(Exception): """Raised when an event handler receives a request to close the connection @@ -181,7 +186,7 @@ class RemoteEventHandler(object): elif cmd == 'import': name = opts['module'] fromlist = opts.get('fromlist', []) - mod = __builtin__.__import__(name, fromlist=fromlist) + mod = builtins.__import__(name, fromlist=fromlist) if len(fromlist) == 0: parts = name.lstrip('.').split('.') diff --git a/widgets/RemoteGraphicsView.py b/widgets/RemoteGraphicsView.py index bea5a02d..3722e87e 100644 --- a/widgets/RemoteGraphicsView.py +++ b/widgets/RemoteGraphicsView.py @@ -27,7 +27,7 @@ class RemoteGraphicsView(QtGui.QWidget): rpgRemote = self._proc._import('pyqtgraph.widgets.RemoteGraphicsView') self._view = rpgRemote.Renderer(*args, **kwds) self._view._setProxyOptions(deferGetattr=True) - self.setFocusPolicy(self._view.focusPolicy()) + self.setFocusPolicy(QtCore.Qt.FocusPolicy(self._view.focusPolicy())) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.setMouseTracking(True) self.shm = None