@@ -545,34 +545,34 @@ def open_project(self, file_path, clear_thumbnails=True):
545
545
def clear_all_thumbnails (self ):
546
546
"""Clear all user thumbnails"""
547
547
try :
548
- openshot_thumbnail_path = os .path .join (info .USER_PATH , "thumbnail" )
549
- if os .path .exists (openshot_thumbnail_path ):
550
- log .info ("Clear all thumbnails: %s" % openshot_thumbnail_path )
551
- shutil .rmtree (openshot_thumbnail_path )
552
- os .mkdir (openshot_thumbnail_path )
548
+ clear_path = os .path .join (info .USER_PATH , "thumbnail" )
549
+ if os .path .exists (clear_path ):
550
+ log .info ("Clear all thumbnails: %s" % clear_path )
551
+ shutil .rmtree (clear_path )
552
+ os .mkdir (clear_path )
553
553
554
554
# Clear any blender animations
555
- openshot_blender_path = os .path .join (info .USER_PATH , "blender" )
556
- if os .path .exists (openshot_blender_path ):
557
- log .info ("Clear all animations: %s" % openshot_blender_path )
558
- shutil .rmtree (openshot_blender_path )
559
- os .mkdir (openshot_blender_path )
555
+ clear_path = os .path .join (info .USER_PATH , "blender" )
556
+ if os .path .exists (clear_path ):
557
+ log .info ("Clear all animations: %s" % clear_path )
558
+ shutil .rmtree (clear_path )
559
+ os .mkdir (clear_path )
560
560
561
561
# Clear any title animations
562
- openshot_title_path = os .path .join (info .USER_PATH , "title" )
563
- if os .path .exists (openshot_title_path ):
564
- log .info ("Clear all titles: %s" % openshot_title_path )
565
- shutil .rmtree (openshot_title_path )
566
- os .mkdir (openshot_title_path )
562
+ clear_path = os .path .join (info .USER_PATH , "title" )
563
+ if os .path .exists (clear_path ):
564
+ log .info ("Clear all titles: %s" % clear_path )
565
+ shutil .rmtree (clear_path )
566
+ os .mkdir (clear_path )
567
567
568
568
# Clear any backups
569
569
if os .path .exists (info .BACKUP_FILE ):
570
570
log .info ("Clear backup: %s" % info .BACKUP_FILE )
571
571
# Remove backup file
572
572
os .unlink (info .BACKUP_FILE )
573
573
574
- except :
575
- log .info ("Failed to clear thumbnails: %s" % info . THUMBNAIL_PATH )
574
+ except Exception as ex :
575
+ log .info ("Failed to clear {}: {}" . format ( clear_path , ex ) )
576
576
577
577
def actionOpen_trigger (self , event ):
578
578
app = get_app ()
@@ -1041,13 +1041,13 @@ def actionSaveFrame_trigger(self, event):
1041
1041
framePathTime = QDateTime ()
1042
1042
1043
1043
# Get and Save the frame (return is void, so we cannot check for success/fail here - must use file modification timestamp)
1044
- openshot .Timeline .GetFrame (self .timeline_sync .timeline ,self .preview_thread .current_frame ).Save (framePath , 1.0 )
1044
+ openshot .Timeline .GetFrame (self .timeline_sync .timeline , self .preview_thread .current_frame ).Save (framePath , 1.0 )
1045
1045
1046
1046
# Show message to user
1047
1047
if os .path .exists (framePath ) and (QFileInfo (framePath ).lastModified () > framePathTime ):
1048
1048
self .statusBar .showMessage (_ ("Saved Frame to %s" % framePath ), 5000 )
1049
1049
else :
1050
- self .statusBar .showMessage ( _ ("Failed to save image to %s" % framePath ), 5000 )
1050
+ self .statusBar .showMessage (_ ("Failed to save image to %s" % framePath ), 5000 )
1051
1051
1052
1052
# Reset the MaxSize to match the preview and reset the preview cache
1053
1053
viewport_rect = self .videoPreview .centeredViewport (self .videoPreview .width (), self .videoPreview .height ())
@@ -1264,7 +1264,7 @@ def actionPreviousMarker_trigger(self, event):
1264
1264
closest_position = marker_position
1265
1265
1266
1266
# Seek to marker position (if any)
1267
- if closest_position != None :
1267
+ if closest_position is not None :
1268
1268
# Seek
1269
1269
frame_to_seek = round (closest_position * fps_float ) + 1
1270
1270
self .SeekSignal .emit (frame_to_seek )
@@ -1317,7 +1317,7 @@ def actionNextMarker_trigger(self, event):
1317
1317
closest_position = marker_position
1318
1318
1319
1319
# Seek to marker position (if any)
1320
- if closest_position != None :
1320
+ if closest_position is not None :
1321
1321
# Seek
1322
1322
frame_to_seek = round (closest_position * fps_float ) + 1
1323
1323
self .SeekSignal .emit (frame_to_seek )
@@ -1404,16 +1404,16 @@ def keyPressEvent(self, event):
1404
1404
ui_util .setup_icon (self , self .actionPlay , "actionPlay" , "media-playback-pause" )
1405
1405
self .actionPlay .setChecked (True )
1406
1406
1407
- elif key .matches (self .getShortcutByName ("playToggle" )) == QKeySequence .ExactMatch or \
1408
- key .matches (self .getShortcutByName ("playToggle1" )) == QKeySequence .ExactMatch or \
1409
- key .matches (self .getShortcutByName ("playToggle2" )) == QKeySequence .ExactMatch or \
1410
- key .matches (self .getShortcutByName ("playToggle3" )) == QKeySequence .ExactMatch :
1407
+ elif ( key .matches (self .getShortcutByName ("playToggle" )) == QKeySequence .ExactMatch or
1408
+ key .matches (self .getShortcutByName ("playToggle1" )) == QKeySequence .ExactMatch or
1409
+ key .matches (self .getShortcutByName ("playToggle2" )) == QKeySequence .ExactMatch or
1410
+ key .matches (self .getShortcutByName ("playToggle3" )) == QKeySequence .ExactMatch ) :
1411
1411
# Toggle playbutton and show properties
1412
1412
self .actionPlay .trigger ()
1413
1413
self .propertyTableView .select_frame (player .Position ())
1414
1414
1415
- elif key .matches (self .getShortcutByName ("deleteItem" )) == QKeySequence .ExactMatch or \
1416
- key .matches (self .getShortcutByName ("deleteItem1" )) == QKeySequence .ExactMatch :
1415
+ elif ( key .matches (self .getShortcutByName ("deleteItem" )) == QKeySequence .ExactMatch or
1416
+ key .matches (self .getShortcutByName ("deleteItem1" )) == QKeySequence .ExactMatch ) :
1417
1417
# Delete selected clip / transition
1418
1418
self .actionRemoveClip .trigger ()
1419
1419
self .actionRemoveTransition .trigger ()
@@ -2225,11 +2225,8 @@ def setup_toolbars(self):
2225
2225
2226
2226
# Add fixed spacer(s) (one for each "Other control" to keep playback controls centered)
2227
2227
ospacer1 = QWidget (self )
2228
- ospacer1 .setMinimumSize (32 , 1 ) # actionSaveFrame
2228
+ ospacer1 .setMinimumSize (32 , 1 ) # actionSaveFrame
2229
2229
self .videoToolbar .addWidget (ospacer1 )
2230
- #ospacer2 = QWidget(self)
2231
- #ospacer2.setMinimumSize(32, 1) # ???
2232
- #self.videoToolbar.addWidget(ospacer2)
2233
2230
2234
2231
# Add left spacer
2235
2232
spacer = QWidget (self )
@@ -2283,7 +2280,9 @@ def setup_toolbars(self):
2283
2280
self .sliderZoom .setInvertedControls (True )
2284
2281
self .sliderZoom .resize (100 , 16 )
2285
2282
2286
- self .zoomScaleLabel = QLabel ( _ ("{} seconds" ).format (zoomToSeconds (self .sliderZoom .value ())) )
2283
+ self .zoomScaleLabel = QLabel (
2284
+ _ ("{} seconds" ).format (zoomToSeconds (self .sliderZoom .value ()))
2285
+ )
2287
2286
2288
2287
# add zoom widgets
2289
2288
self .timelineToolbar .addAction (self .actionTimelineZoomIn )
@@ -2386,7 +2385,7 @@ def InitCacheSettings(self):
2386
2385
log .info ("cache-limit-mb: %s" % s .get ("cache-limit-mb" ))
2387
2386
2388
2387
# Get MB limit of cache (and convert to bytes)
2389
- cache_limit = s .get ("cache-limit-mb" ) * 1024 * 1024 # Convert MB to Bytes
2388
+ cache_limit = s .get ("cache-limit-mb" ) * 1024 * 1024 # Convert MB to Bytes
2390
2389
2391
2390
# Clear old cache
2392
2391
new_cache_object = None
@@ -2426,7 +2425,7 @@ def FrameExported(self, title_message, start_frame, end_frame, current_frame):
2426
2425
launcher .set_property ("progress" , current_frame / (end_frame - start_frame ))
2427
2426
launcher .set_property ("progress_visible" , True )
2428
2427
2429
- except :
2428
+ except Exception :
2430
2429
# Just ignore
2431
2430
self .has_launcher = False
2432
2431
@@ -2438,7 +2437,7 @@ def ExportFinished(self, path):
2438
2437
# Set progress on Unity launcher and hide progress bar
2439
2438
launcher .set_property ("progress" , 0.0 )
2440
2439
launcher .set_property ("progress_visible" , False )
2441
- except :
2440
+ except Exception :
2442
2441
pass
2443
2442
2444
2443
def transformTriggered (self , clip_id ):
@@ -2596,9 +2595,9 @@ def __init__(self, mode=None):
2596
2595
2597
2596
# Set encoding method
2598
2597
if s .get ("hw-decoder" ):
2599
- openshot .Settings .Instance ().HARDWARE_DECODER = int (str (s .get ("hw-decoder" )))
2598
+ openshot .Settings .Instance ().HARDWARE_DECODER = int (str (s .get ("hw-decoder" )))
2600
2599
else :
2601
- openshot .Settings .Instance ().HARDWARE_DECODER = 0
2600
+ openshot .Settings .Instance ().HARDWARE_DECODER = 0
2602
2601
2603
2602
# Set graphics card for decoding
2604
2603
if s .get ("graca_number_de" ):
@@ -2620,9 +2619,9 @@ def __init__(self, mode=None):
2620
2619
2621
2620
# Set audio playback settings
2622
2621
if s .get ("playback-audio-device" ):
2623
- openshot .Settings .Instance ().PLAYBACK_AUDIO_DEVICE_NAME = str (s .get ("playback-audio-device" ))
2622
+ openshot .Settings .Instance ().PLAYBACK_AUDIO_DEVICE_NAME = str (s .get ("playback-audio-device" ))
2624
2623
else :
2625
- openshot .Settings .Instance ().PLAYBACK_AUDIO_DEVICE_NAME = ""
2624
+ openshot .Settings .Instance ().PLAYBACK_AUDIO_DEVICE_NAME = ""
2626
2625
2627
2626
# Set OMP thread enabled flag (for stability)
2628
2627
if s .get ("omp_threads_enabled" ):
@@ -2635,13 +2634,13 @@ def __init__(self, mode=None):
2635
2634
2636
2635
# Set use omp threads number environment variable
2637
2636
if s .get ("omp_threads_number" ):
2638
- openshot .Settings .Instance ().OMP_THREADS = max (2 ,int (str (s .get ("omp_threads_number" ))))
2637
+ openshot .Settings .Instance ().OMP_THREADS = max (2 , int (str (s .get ("omp_threads_number" ))))
2639
2638
else :
2640
2639
openshot .Settings .Instance ().OMP_THREADS = 12
2641
2640
2642
2641
# Set use ffmpeg threads number environment variable
2643
2642
if s .get ("ff_threads_number" ):
2644
- openshot .Settings .Instance ().FF_THREADS = max (1 ,int (str (s .get ("ff_threads_number" ))))
2643
+ openshot .Settings .Instance ().FF_THREADS = max (1 , int (str (s .get ("ff_threads_number" ))))
2645
2644
else :
2646
2645
openshot .Settings .Instance ().FF_THREADS = 8
2647
2646
0 commit comments