Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def upload_error(self, name, error):
dialog = QtWidgets.QMessageBox(self)
dialog.setWindowTitle(translate(
'UploaderTabsAll', 'Photini: upload error'))
dialog.setText(translate(
'UploaderTabsAll', '<h3>File "{}" upload failed.</h3>').format(
name))
dialog.setInformativeText(error)
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(QtWidgets.QMessageBox.Abort |
QtWidgets.QMessageBox.Retry)
dialog.setDefaultButton(QtWidgets.QMessageBox.Retry)
self.abort_upload.emit(dialog.exec_() == QtWidgets.QMessageBox.Retry)
' accept and Photini cannot convert.')
buttons = QtWidgets.QMessageBox.Ignore
elif (self.image_types['rejected'] == '*' or
image.file_type in self.image_types['rejected']):
msg = translate(
'UploaderTabsAll',
'File "{0}" is of type "{1}", which {2} does not' +
' accept. Would you like to convert it to JPEG?')
buttons = QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Ignore
else:
msg = translate(
'UploaderTabsAll',
'File "{0}" is of type "{1}", which {2} may not' +
' handle correctly. Would you like to convert it to JPEG?')
buttons = QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
dialog = QtWidgets.QMessageBox(parent=self)
dialog.setWindowTitle(
translate('UploaderTabsAll', 'Photini: incompatible type'))
dialog.setText(
translate('UploaderTabsAll', '<h3>Incompatible image type.</h3>'))
dialog.setInformativeText(msg.format(os.path.basename(image.path),
image.file_type, self.service_name))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(buttons)
dialog.setDefaultButton(QtWidgets.QMessageBox.Yes)
result = dialog.exec_()
if result == QtWidgets.QMessageBox.Ignore:
return 'omit'
if result == QtWidgets.QMessageBox.Yes:
return self.convert_to_jpeg
return None
min(spec.min_fl_fn, spec.max_fl_fn))
if new_aperture == 0 and new_fl == 0:
continue
if (new_aperture == image.metadata.aperture and
new_fl == image.metadata.focal_length):
continue
if make_changes:
pass
elif QtWidgets.QMessageBox.question(
self,
translate('TechnicalTab', 'Update aperture & focal length'),
translate('TechnicalTab', 'Adjust image aperture and focal'
' length to agree with lens specification?'),
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
QtWidgets.QMessageBox.No
) == QtWidgets.QMessageBox.No:
return
make_changes = True
if new_aperture:
image.metadata.aperture = new_aperture
if new_fl:
# only update 35mm equiv if already set
if image.metadata.focal_length_35:
image.metadata.focal_length_35 = self.calc_35(
image.metadata, new_fl)
image.metadata.focal_length = new_fl
if make_changes:
self._update_aperture()
self._update_focal_length()
self._update_focal_length_35()
def get_conversion_function(self, image, params):
convert = super(
TabWidget, self).get_conversion_function(image, params)
if convert == 'omit':
return convert
max_size = 25 * 1024 * 1024
size = os.stat(image.path).st_size
if size < max_size:
return convert
dialog = QtWidgets.QMessageBox(parent=self)
dialog.setWindowTitle(
translate('GooglePhotosTab', 'Photini: large file'))
dialog.setText(
translate('GooglePhotosTab', '<h3>Large file.</h3>'))
dialog.setInformativeText(
translate('GooglePhotosTab',
'File "{0}" is over 25MB. Remember that Photini '
'uploads count towards storage in your Google Account. '
'Upload it anyway?').format(os.path.basename(image.path)))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Ignore)
dialog.exec_()
return 'omit'
def unsaved_files_dialog(
self, all_files=False, with_cancel=True, with_discard=True):
"""Return true if OK to continue with close or quit or whatever"""
for image in self.images:
if image.metadata.changed() and (all_files or image.selected):
break
else:
return True
dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle(self.tr('Photini: unsaved data'))
dialog.setText(self.tr('<h3>Some images have unsaved metadata.</h3>'))
dialog.setInformativeText(self.tr('Do you want to save your changes?'))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
buttons = QtWidgets.QMessageBox.Save
if with_cancel:
buttons |= QtWidgets.QMessageBox.Cancel
if with_discard:
buttons |= QtWidgets.QMessageBox.Discard
dialog.setStandardButtons(buttons)
dialog.setDefaultButton(QtWidgets.QMessageBox.Save)
result = dialog.exec_()
if result == QtWidgets.QMessageBox.Save:
self._save_files()
return True
return result == QtWidgets.QMessageBox.Discard
def do_not_close(self):
if not self.upload_worker:
return False
dialog = QtWidgets.QMessageBox(parent=self)
dialog.setWindowTitle(translate(
'UploaderTabsAll', 'Photini: upload in progress'))
dialog.setText(translate(
'UploaderTabsAll',
'<h3>Upload to {} has not finished.</h3>').format(self.service_name))
dialog.setInformativeText(
translate('UploaderTabsAll', 'Closing now will terminate the upload.'))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(
QtWidgets.QMessageBox.Close | QtWidgets.QMessageBox.Cancel)
dialog.setDefaultButton(QtWidgets.QMessageBox.Cancel)
result = dialog.exec_()
return result == QtWidgets.QMessageBox.Cancel
def get_conversion_function(self, image, params):
if not params['function']:
return None
convert = super(
TabWidget, self).get_conversion_function(image, params)
if convert == 'omit':
return convert
max_size = 2 ** 30
size = os.stat(image.path).st_size
if size < max_size:
return convert
dialog = QtWidgets.QMessageBox(parent=self)
dialog.setWindowTitle(
translate('FlickrTab', 'Photini: too large'))
dialog.setText(
translate('FlickrTab', '<h3>File too large.</h3>'))
dialog.setInformativeText(
translate('FlickrTab',
'File "{0}" has {1} bytes and exceeds Flickr\'s limit' +
' of {2} bytes.').format(
os.path.basename(image.path), size, max_size))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(QtWidgets.QMessageBox.Ignore)
dialog.exec_()
return 'omit'
def unsaved_files_dialog(
self, all_files=False, with_cancel=True, with_discard=True):
"""Return true if OK to continue with close or quit or whatever"""
for image in self.images:
if image.metadata.changed() and (all_files or image.selected):
break
else:
return True
dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle(self.tr('Photini: unsaved data'))
dialog.setText(self.tr('<h3>Some images have unsaved metadata.</h3>'))
dialog.setInformativeText(self.tr('Do you want to save your changes?'))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
buttons = QtWidgets.QMessageBox.Save
if with_cancel:
buttons |= QtWidgets.QMessageBox.Cancel
if with_discard:
buttons |= QtWidgets.QMessageBox.Discard
dialog.setStandardButtons(buttons)
dialog.setDefaultButton(QtWidgets.QMessageBox.Save)
result = dialog.exec_()
if result == QtWidgets.QMessageBox.Save:
self._save_files()
return True
return result == QtWidgets.QMessageBox.Discard
size = os.stat(image.path).st_size
if size < max_size:
return convert
dialog = QtWidgets.QMessageBox(parent=self)
dialog.setWindowTitle(
translate('GooglePhotosTab', 'Photini: large file'))
dialog.setText(
translate('GooglePhotosTab', '<h3>Large file.</h3>'))
dialog.setInformativeText(
translate('GooglePhotosTab',
'File "{0}" is over 25MB. Remember that Photini '
'uploads count towards storage in your Google Account. '
'Upload it anyway?').format(os.path.basename(image.path)))
dialog.setIcon(QtWidgets.QMessageBox.Warning)
dialog.setStandardButtons(
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Ignore)
dialog.exec_()
return 'omit'