Skip to content

Commit bb1ba63

Browse files
committed
qtvcp project: fix various issues
missing modules, copy/paste, undefined variables, whitespace, etc.
1 parent 4591036 commit bb1ba63

8 files changed

Lines changed: 33 additions & 31 deletions

File tree

lib/python/qtvcp/lib/audio_player.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def set_sounds(self):
100100
self.logout = '/usr/share/sounds/LinuxMint/stereo/desktop-logout.ogg'
101101
self.bell = '/usr/share/sounds/freedesktop/stereo/bell.oga'
102102
if not os.path.exists(self.error):
103-
log.error('Audio player - Mint sound File not found {}'.format(self.error))
103+
LOG.error('Audio player - Mint sound File not found {}'.format(self.error))
104104
return
105105
except:
106106
pass
@@ -127,7 +127,7 @@ def _register_messages(self):
127127

128128
# jump to a builtin alert sound
129129
# This uses the system to play the sound because gst is not available
130-
# this can still fail if gstreamer/tools are not available
130+
# this can still fail if gstreamer/tools are not available
131131
def os_jump(self, w, f):
132132
if 'beep' in f.lower():
133133
self[f.lower()]()
@@ -254,7 +254,7 @@ def os_speak(self, f):
254254
# fallback call the system espeak - no queue used
255255
os.system('''espeak -s 160 -v m3 -p 1 "%s" &''' % cmd)
256256

257-
# when sentences ends, start the next one, until there are none.
257+
# when sentences ends, start the next one, until there are none.
258258
def speak_finished(self, *args):
259259
if args[0] == espeak.event_MSG_TERMINATED:
260260
if not esQueue.empty():

lib/python/qtvcp/qt_action.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def CALL_DIALOG(self, command):
641641
try:
642642
a = command['NAME']
643643
except:
644-
LOG.warning("Call Dialog command Dict not recogzied: {}".format(option))
644+
LOG.warning("Call Dialog command Dict not recogzied: {}".format(command))
645645
STATUS.emit('dialog-request', command)
646646

647647
def HIDE_POINTER(self, state):
@@ -746,7 +746,7 @@ def ADD_WIDGET_TO_TAB(self, widgetTo, widget,name):
746746
widgetTo.setMaximumWidth(widget.maximumWidth())
747747
widgetTo.addWidget(tw)
748748
else:
749-
LOG.warning('Widget {} is not a Tab or stacked Widget - skipping'.format(loc))
749+
LOG.warning('Widget {} is not a Tab or stacked Widget - skipping'.format(widgetTo))
750750
return False
751751
except Exception as e:
752752
LOG.warning("problem inserting child into location: {},{}".format(widget,e))
@@ -797,7 +797,7 @@ def SET_SHADOW(self, widget,state,color):
797797

798798
# In free (joint) mode we use the plain joint number.
799799
# In axis mode we convert the joint number to the equivalent
800-
# axis number
800+
# axis number
801801
def get_jog_info(self, num):
802802
if STATUS.stat.motion_mode == linuxcnc.TRAJ_MODE_FREE:
803803
return True, self.jnum_check(num)
@@ -1042,7 +1042,7 @@ def finish(self):
10421042

10431043
# request an error dialog box
10441044
def error(self, exitcode, stderr):
1045-
message = '''The filter program '{}' that was filtering '{}'
1045+
message = '''The filter program '{}' that was filtering '{}'
10461046
exited with an error'''.format(self.program_filter, self.filtered_program)
10471047
if stderr != '':
10481048
more = "The error messages it produced are shown below:"

lib/python/qtvcp/widgets/camview_widget.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def convertToGray(self, img):
171171
return CV.cvtColor(img, CV.COLOR_BGR2GRAY)
172172

173173
def blur(self, img, B=7):
174-
return CV.GaussingBlur(img, (b,b), CV.BORDER_DEFAULT)
174+
return CV.GaussingBlur(img, (B,B), CV.BORDER_DEFAULT)
175175

176176
def canny(self, img, x=125, y=175):
177177
return CV.Canny(img , x, y)
@@ -212,12 +212,12 @@ def zoom(self, frame, scale):
212212
return frame[ch-coh:ch+coh, cw-cow:cw+cow]
213213

214214
# draw a circle around small holes
215-
#
215+
#
216216
def findCircles(self,frame):
217217
# Our operations on the frame come here
218218
gray = CV.cvtColor(frame, CV.COLOR_BGR2GRAY)
219219
# Display the resulting frame
220-
220+
221221
circles = CV.HoughCircles(gray,CV.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=10,maxRadius=15)
222222
# print circles
223223
if circles is not None:
@@ -235,27 +235,27 @@ def blobInit(self):
235235
# Setup BlobDetector
236236
detector = CV.SimpleBlobDetector()
237237
params = CV.SimpleBlobDetector_Params()
238-
238+
239239
# Filter by Area.
240240
params.filterByArea = True
241241
params.minArea = 20000
242242
params.maxArea = 40000
243-
243+
244244
# Filter by Circularity
245245
params.filterByCircularity = True
246246
params.minCircularity = 0.5
247-
247+
248248
# Filter by Convexity
249249
params.filterByConvexity = False
250250
#params.minConvexity = 0.87
251-
251+
252252
# Filter by Inertia
253253
params.filterByInertia = True
254254
params.minInertiaRatio = 0.8
255255

256256
# Distance Between Blobs
257257
params.minDistBetweenBlobs = 200
258-
258+
259259
# Create a detector with the parameters
260260
self.detector = CV.SimpleBlobDetector(params)
261261

@@ -266,9 +266,9 @@ def findBlob(self, image):
266266

267267
keypoints = self.detector.detect(image)
268268
for k in keypoints:
269-
CV.circle(overlay, (int(k.pt[0]), int(k.pt[1])), int(k.size/2), (0, 0, 255), -1)
270-
CV.line(overlay, (int(k.pt[0])-20, int(k.pt[1])), (int(k.pt[0])+20, int(k.pt[1])), (0,0,0), 3)
271-
CV.line(overlay, (int(k.pt[0]), int(k.pt[1])-20), (int(k.pt[0]), int(k.pt[1])+20), (0,0,0), 3)
269+
CV.circle(overlay, (int(k.pt[0]), int(k.pt[1])), int(k.size/2), (0, 0, 255), -1)
270+
CV.line(overlay, (int(k.pt[0])-20, int(k.pt[1])), (int(k.pt[0])+20, int(k.pt[1])), (0,0,0), 3)
271+
CV.line(overlay, (int(k.pt[0]), int(k.pt[1])-20), (int(k.pt[0]), int(k.pt[1])+20), (0,0,0), 3)
272272

273273
opacity = 0.5
274274
CV.addWeighted(overlay, opacity, image, 1 - opacity, 0, image)
@@ -444,7 +444,7 @@ def list_ports(self):
444444
dev_port = 0
445445
working_ports = []
446446
available_ports = []
447-
while len(non_working_ports) < 6: # if there are more than 5 non working ports stop the testing.
447+
while len(non_working_ports) < 6: # if there are more than 5 non working ports stop the testing.
448448
camera = CV.VideoCapture(dev_port)
449449
if not camera.isOpened():
450450
non_working_ports.append(dev_port)

lib/python/qtvcp/widgets/file_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ def onJumpClicked(self):
260260
if temp is not None:
261261
self.updateDirectoryView(temp)
262262
else:
263-
STATUS.emit('error', linuxcnc.OPERATOR_ERROR, 'file jumopath: {} not valid'.format(data))
264-
log.debug('file jumopath: {} not valid'.format(data))
263+
STATUS.emit('error', OPERATOR_ERROR, 'file jumopath: {} not valid'.format(data))
264+
LOG.debug('file jumopath: {} not valid'.format(data))
265265

266266
# jump directly to a saved path from the menu
267267
def jumpTriggered(self, data):
@@ -301,7 +301,7 @@ def _getPathActivated(self):
301301
self.listClicked(row)
302302

303303
fname = self.currentPath
304-
if fname is None:
304+
if fname is None:
305305
return
306306
if fname:
307307
self.load(fname)
@@ -447,7 +447,7 @@ def load(self, fname=None):
447447
# This can be class patched to do something else
448448
def recordBookKeeping(self):
449449
fname = self.currentPath
450-
if fname is None:
450+
if fname is None:
451451
return
452452
if self.PREFS_:
453453
self.PREFS_.putpref('last_loaded_directory', self.model.rootPath(), str, 'BOOK_KEEPING')

lib/python/qtvcp/widgets/mdi_history.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
class MDIHistory(QWidget, _HalWidgetBase):
4040
def __init__(self, parent=None):
4141
super(MDIHistory, self).__init__(parent)
42-
self.setMinimumSize(QSize(200, 150))
43-
self.setWindowTitle("PyQt5 editor test example")
42+
self.setMinimumSize(QSize(200, 150))
43+
self.setWindowTitle("PyQt5 editor test example")
4444

4545
lay = QVBoxLayout()
4646
lay.setContentsMargins(0,0,0,0)
@@ -100,7 +100,7 @@ def reload(self, w=None ):
100100
self.list.scrollToBottom()
101101
self.MDILine.setText('')
102102
except:
103-
LOG.debug('File path is not valid: {}'.format(fp))
103+
LOG.debug('File path is not valid: {}'.format(self.fp))
104104

105105
def selectionChanged(self,old, new):
106106
cmd = self.getSelected()

lib/python/qtvcp/widgets/nurbs_editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
QStyleFactory, QWidget, QColorDialog)
4949
from PyQt5 import QtGui, QtCore
5050

51+
import gcode
5152
from qt5_graphics import Lcnc_3dGraphics
5253
from qtvcp.core import Info, Path, Action
5354

@@ -101,7 +102,7 @@ def __init__(self, parent=None, path=None):
101102
self.update()
102103

103104
def setGraphicsDisplay(self):
104-
# class patch to catch gcode errors - in theory
105+
# class patch to catch gcode errors - in theory
105106
self.graphics.report_gcode_error = self.report_gcode_error
106107
# reset trverse color so other displays don;t change
107108
self.defaultColor = self.graphics.colors['traverse']
@@ -304,5 +305,4 @@ def report_gcode_error(self, result, seq, filename):
304305
window = NurbsEditor(path = inifilename)
305306
window.load_dialog()
306307
sys.exit(app.exec_())
307-
308308

lib/python/qtvcp/widgets/overlay_widget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def __init__(self, parent=None):
147147
# STATUS messages
148148
# adjust image path name at runtime
149149
def _hal_init(self):
150-
STATUS.connect('focus-overlay-changed', lambda w, data, text, color:
150+
STATUS.connect('focus-overlay-changed', lambda w, data, text, color:
151151
self._status_response(data, text, color))
152152
STATUS.connect('graphics-loading-progress',lambda w,f: self.updateProgress(f))
153153
if self.PREFS_:
@@ -327,7 +327,7 @@ def setShowText(self, value):
327327
self.mb.setVisible(value)
328328
def getShowText(self):
329329
return self._show_text
330-
def resetShowText(self):
330+
def resetShowText(self, value):
331331
self._show_text = True
332332
self.mb.setVisible(value)
333333

lib/python/qtvcp/widgets/stylesheeteditor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949

5050
from qtvcp.core import Info, Path
5151
from qtvcp.qt_makegui import VCPWindow
52+
from qtvcp import logger
53+
LOG = logger.getLogger(__name__)
5254
INFO = Info()
5355
PATH = Path()
5456
WIDGETS = VCPWindow()
@@ -115,7 +117,7 @@ def setPath(self):
115117
except Exception as e:
116118
print(e)
117119

118-
# check for qss in the users's config folder
120+
# check for qss in the users's config folder
119121
localqss = PATH.CONFIGPATH
120122
try:
121123
fileNames= [f for f in os.listdir(localqss) if f.endswith('.qss')]

0 commit comments

Comments
 (0)