Skip to content

Commit

Permalink
added Try block for vlc bindings
Browse files Browse the repository at this point in the history
In situations where vlc bindings not work (e.g. windows newer vlc software, cant find libvlc.dll) the software will not crash, but will not be able to use audio/video coding.
  • Loading branch information
ccbogel authored Apr 17, 2019
1 parent 1093119 commit 4992582
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
17 changes: 12 additions & 5 deletions qualcoder/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,8 @@ def view(self):
url = QtCore.QUrl(path)

def link_clicked(self, url):
''' View image or audio/video media in dialog. '''
''' View image or audio/video media in dialog.
For A/V, added try block in case VLC bindings do not work. '''

x = -1
for i in range(0, len(self.source)):
Expand All @@ -658,10 +659,16 @@ def link_clicked(self, url):
if x == -1:
return
ui = None
if self.source[x]['mediapath'][:6] == "/video":
ui = DialogViewAV(self.settings, self.source[x])
if self.source[x]['mediapath'][:6] == "/audio":
ui = DialogViewAV(self.settings, self.source[x])
try:
if self.source[x]['mediapath'][:6] == "/video":
ui = DialogViewAV(self.settings, self.source[x])
if self.source[x]['mediapath'][:6] == "/audio":
ui = DialogViewAV(self.settings, self.source[x])
except Exception as e:
logger.debug(str(e))
print(e)
QtWidgets.QMessageBox.warning(None, 'view av error', str(e), QtWidgets.QMessageBox.Ok)
return
if self.source[x]['mediapath'][:7] == "/images":
ui = DialogViewImage(self.settings, self.source[x])
ui.exec_()
Expand Down
41 changes: 24 additions & 17 deletions qualcoder/manage_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,25 +303,32 @@ def view(self):

def view_av(self, x):
""" View an audio or video file. Edit the memo. Edit the transcribed file.
Added try block in case VLC bindings do not work.
"""

ui = DialogViewAV(self.settings, self.source[x])
#ui.exec_() # this dialog does not display well on Windows 10 so trying .show()
self.dialogList.append(ui)
ui.show()
memo = ui.ui.textEdit.toPlainText()
if self.source[x]['memo'] != memo:
self.source[x]['memo'] = memo
cur = self.settings['conn'].cursor()
cur.execute('update source set memo=? where id=?', (self.source[x]['memo'],
self.source[x]['id']))
self.settings['conn'].commit()
if self.source[x]['memo'] == "":
self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem())
else:
self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem("Yes"))
# easy way to update transcribed files
self.load_file_data()
try:
ui = DialogViewAV(self.settings, self.source[x])
#ui.exec_() # this dialog does not display well on Windows 10 so trying .show()
self.dialogList.append(ui)
ui.show()
memo = ui.ui.textEdit.toPlainText()
if self.source[x]['memo'] != memo:
self.source[x]['memo'] = memo
cur = self.settings['conn'].cursor()
cur.execute('update source set memo=? where id=?', (self.source[x]['memo'],
self.source[x]['id']))
self.settings['conn'].commit()
if self.source[x]['memo'] == "":
self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem())
else:
self.ui.tableWidget.setItem(x, self.MEMO_COLUMN, QtWidgets.QTableWidgetItem("Yes"))
# easy way to update transcribed files
self.load_file_data()
except Exception as e:
logger.debug(e)
print(e)
QtWidgets.QMessageBox.warning(None, 'view av error', str(e), QtWidgets.QMessageBox.Ok)
return

def view_image(self, x):
""" View an image file and edit the image memo. """
Expand Down
15 changes: 10 additions & 5 deletions qualcoder/qualcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,17 @@ def image_coding(self):

def av_coding(self):
""" Create edit and delete codes. Apply and remove codes to segements of the
audio or video file. """
audio or video file. Added try block in case VLC bindings do not work. """

ui = DialogCodeAV(self.settings, self.ui.textEdit)
ui.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.dialogList.append(ui)
ui.show()
try:
ui = DialogCodeAV(self.settings, self.ui.textEdit)
ui.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.dialogList.append(ui)
ui.show()
except Exception as e:
logger.debug(str(e))
print(e)
QtWidgets.QMessageBox.warning(None, "A/V Coding", str(e), QtWidgets.QMessageBox.Ok)
self.clean_dialog_refs()

def codebook(self):
Expand Down

0 comments on commit 4992582

Please sign in to comment.