Skip to content

Commit

Permalink
Enforce integer function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Nov 25, 2021
1 parent a308850 commit 1b14896
Show file tree
Hide file tree
Showing 13 changed files with 476 additions and 265 deletions.
8 changes: 4 additions & 4 deletions src/windows/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def updateProgressBar(self, title_message, start_frame, end_frame, current_frame
percentage_string = format_of_progress_string % (( current_frame - start_frame ) / ( end_frame - start_frame ) * 100)
else:
percentage_string = "100%"
self.progressExportVideo.setValue(current_frame)
self.progressExportVideo.setValue(int(current_frame))
self.progressExportVideo.setFormat(percentage_string)
self.setWindowTitle("%s %s" % (percentage_string, title_message))

Expand Down Expand Up @@ -690,9 +690,9 @@ def titlestring(sec, fps, mess):
fps_encode = 0

# Init progress bar
self.progressExportVideo.setMinimum(self.txtStartFrame.value())
self.progressExportVideo.setMaximum(self.txtEndFrame.value())
self.progressExportVideo.setValue(self.txtStartFrame.value())
self.progressExportVideo.setMinimum(int(self.txtStartFrame.value()))
self.progressExportVideo.setMaximum(int(self.txtEndFrame.value()))
self.progressExportVideo.setValue(int(self.txtStartFrame.value()))

# Prompt error message
if self.txtStartFrame.value() == self.txtEndFrame.value():
Expand Down
34 changes: 17 additions & 17 deletions src/windows/models/properties_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
new_value = None

log.info(
"%s for %s changed to %s at frame %s with interpolation: %s at closest x: %s"
% (property_key, clip_id, new_value, self.frame_number, interpolation, closest_point_x))
"%s for %s changed to %s at frame %s with interpolation: %s at closest x: %s",
property_key, clip_id, new_value, self.frame_number, interpolation, closest_point_x)

# Find this clip
c = None
Expand Down Expand Up @@ -518,35 +518,35 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
try:
clip_data[property_key] = int(new_value)
except Exception as ex:
log.warn('Invalid Integer value passed to property: %s' % ex)
log.warn('Invalid Integer value passed to property', exc_info=1)

elif property_type == "float":
clip_updated = True
try:
clip_data[property_key] = float(new_value)
except Exception as ex:
log.warn('Invalid Float value passed to property: %s' % ex)
log.warn('Invalid Float value passed to property', exc_info=1)

elif property_type == "bool":
clip_updated = True
try:
clip_data[property_key] = bool(new_value)
except Exception as ex:
log.warn('Invalid Boolean value passed to property: %s' % ex)
log.warn('Invalid Boolean value passed to property', exc_info=1)

elif property_type == "string":
clip_updated = True
try:
clip_data[property_key] = str(new_value)
except Exception as ex:
log.warn('Invalid String value passed to property: %s' % ex)
except Exception:
log.warn('Invalid String value passed to property', exc_info=1)

elif property_type in ["font", "caption"]:
clip_updated = True
try:
clip_data[property_key] = str(new_value)
except Exception as ex:
log.warn('Invalid Font/Caption value passed to property: %s' % ex)
except Exception:
log.warn('Invalid Font/Caption value passed to property', exc_info=1)

elif property_type == "reader":
# Transition
Expand All @@ -557,8 +557,8 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
clip_data[property_key] = json.loads(clip_object.Reader().Json())
clip_object.Close()
clip_object = None
except Exception as ex:
log.warn('Invalid Reader value passed to property: %s (%s)' % (value, ex))
except Exception:
log.warn('Invalid Reader value passed to property: %s (%s)', value, exc_info=1)

# Reduce # of clip properties we are saving (performance boost)
clip_data = {property_key: clip_data.get(property_key)}
Expand Down Expand Up @@ -688,9 +688,9 @@ def set_property(self, property, filter, c, item_type, object_id=None):

if type == "color":
# Color needs to be handled special
red = property[1]["red"]["value"]
green = property[1]["green"]["value"]
blue = property[1]["blue"]["value"]
red = int(property[1]["red"]["value"])
green = int(property[1]["green"]["value"])
blue = int(property[1]["blue"]["value"])
col.setBackground(QColor(red, green, blue))

if readonly or type in ["color", "font", "caption"] or choices or label == "Track":
Expand Down Expand Up @@ -789,9 +789,9 @@ def set_property(self, property, filter, c, item_type, object_id=None):

if type == "color":
# Update the color based on the color curves
red = property[1]["red"]["value"]
green = property[1]["green"]["value"]
blue = property[1]["blue"]["value"]
red = int(property[1]["red"]["value"])
green = int(property[1]["green"]["value"])
blue = int(property[1]["blue"]["value"])
col.setBackground(QColor(red, green, blue))

# Update helper dictionary
Expand Down
2 changes: 1 addition & 1 deletion src/windows/process_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def accept(self):
while(not processing.IsDone() ):
# update progressbar
progressionStatus = processing.GetProgress()
self.progressBar.setValue(progressionStatus)
self.progressBar.setValue(int(progressionStatus))
time.sleep(0.01)

# Process any queued events
Expand Down
Loading

0 comments on commit 1b14896

Please sign in to comment.