@@ -80,9 +80,12 @@ def run_command(command, working_dir=None):
80
80
"""Utility function to return output from command line"""
81
81
short_command = command .split ('" ' )[0 ] # We don't need to print args
82
82
output ("Running %s... (%s)" % (short_command , working_dir ))
83
- p = subprocess .Popen (command , shell = True , cwd = working_dir ,
84
- stdout = subprocess .PIPE ,
85
- stderr = subprocess .STDOUT )
83
+ p = subprocess .Popen (
84
+ command ,
85
+ shell = True ,
86
+ cwd = working_dir ,
87
+ stdout = subprocess .PIPE ,
88
+ stderr = subprocess .STDOUT )
86
89
return iter (p .stdout .readline , b"" )
87
90
88
91
@@ -187,7 +190,7 @@ def upload(file_path, github_release):
187
190
return url
188
191
189
192
190
- if __name__ == "__main__" :
193
+ def main () :
191
194
# Only run this code when directly executing this script. Parts of this file
192
195
# are also used in the deploy.py script.
193
196
try :
@@ -215,7 +218,12 @@ def upload(file_path, github_release):
215
218
git_branch_name = sys .argv [7 ]
216
219
217
220
# Start log
218
- output ("%s Build Log for %s (branch: %s)" % (platform .system (), datetime .datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ), git_branch_name ))
221
+ output (
222
+ "%s Build Log for %s (branch: %s)" % (
223
+ platform .system (),
224
+ datetime .datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ),
225
+ git_branch_name )
226
+ )
219
227
220
228
# Detect artifact folder (if any)
221
229
artifact_path = os .path .join (PATH , "build" , "install-x64" )
@@ -227,7 +235,8 @@ def upload(file_path, github_release):
227
235
228
236
# Parse artifact version files (if found)
229
237
for repo_name in ["libopenshot-audio" , "libopenshot" , "openshot-qt" ]:
230
- version_info .update (parse_version_info (os .path .join (artifact_path , "share" , repo_name )))
238
+ version_info .update (
239
+ parse_version_info (os .path .join (artifact_path , "share" , repo_name )))
231
240
output (str (version_info ))
232
241
233
242
# Get GIT description of openshot-qt-git branch (i.e. v2.0.6-18-ga01a98c)
@@ -279,12 +288,13 @@ def upload(file_path, github_release):
279
288
os .makedirs (os .path .join (app_dir_path , "usr" ), exist_ok = True )
280
289
281
290
# XDG Freedesktop icon paths
282
- icons = [ ("scalable" , os .path .join (PATH , "xdg" , "openshot-qt.svg" )),
283
- ("64x64" , os .path .join (PATH , "xdg" , "icon" , "64" , "openshot-qt.png" )),
284
- ("128x128" , os .path .join (PATH , "xdg" , "icon" , "128" , "openshot-qt.png" )),
285
- ("256x256" , os .path .join (PATH , "xdg" , "icon" , "256" , "openshot-qt.png" )),
286
- ("512x512" , os .path .join (PATH , "xdg" , "icon" , "512" , "openshot-qt.png" )),
287
- ]
291
+ icons = [
292
+ ("scalable" , os .path .join (PATH , "xdg" , "openshot-qt.svg" )),
293
+ ("64x64" , os .path .join (PATH , "xdg" , "icon" , "64" , "openshot-qt.png" )),
294
+ ("128x128" , os .path .join (PATH , "xdg" , "icon" , "128" , "openshot-qt.png" )),
295
+ ("256x256" , os .path .join (PATH , "xdg" , "icon" , "256" , "openshot-qt.png" )),
296
+ ("512x512" , os .path .join (PATH , "xdg" , "icon" , "512" , "openshot-qt.png" )),
297
+ ]
288
298
289
299
# Copy desktop icons
290
300
icon_theme_path = os .path .join (app_dir_path , "usr" , "share" , "icons" , "hicolor" )
@@ -348,7 +358,11 @@ def upload(file_path, github_release):
348
358
349
359
# Create AppImage (OpenShot-%s-x86_64.AppImage)
350
360
app_image_success = False
351
- for line in run_command ('/home/ubuntu/apps/AppImageKit/AppImageAssistant "%s" "%s"' % (app_dir_path , app_build_path )):
361
+ for line in run_command (" " .join ([
362
+ '/home/ubuntu/apps/AppImageKit/AppImageAssistant' ,
363
+ '"%s"' % app_dir_path ,
364
+ '"%s"' % app_build_path ,
365
+ ])):
352
366
output (line )
353
367
app_image_success = os .path .exists (app_build_path )
354
368
@@ -361,23 +375,28 @@ def upload(file_path, github_release):
361
375
# Delete build (since something failed)
362
376
os .remove (app_build_path )
363
377
364
-
365
378
if platform .system () == "Darwin" :
366
-
367
379
# Create DMG (OpenShot-%s-x86_64.DMG)
368
380
app_image_success = False
369
381
370
382
# Build app.bundle and create DMG
371
383
for line in run_command ("bash installer/build-mac-dmg.sh" ):
372
384
output (line )
373
- if ("error" .encode ("UTF-8" ) in line and "No errors" .encode ("UTF-8" ) not in line ) or "rejected" .encode ("UTF-8" ) in line :
385
+ if (
386
+ ("error" .encode ("UTF-8" ) in line
387
+ and "No errors" .encode ("UTF-8" ) not in line )
388
+ or "rejected" .encode ("UTF-8" ) in line
389
+ ):
374
390
error ("Build-Mac-DMG Error: %s" % line )
375
391
if "Your image is ready" .encode ("UTF-8" ) in line :
376
392
app_image_success = True
377
393
378
394
# Rename DMG (to be consistent with other OS installers)
379
395
for dmg_path in os .listdir (os .path .join (PATH , "build" )):
380
- if os .path .isfile (os .path .join (PATH , "build" , dmg_path )) and dmg_path .endswith (".dmg" ):
396
+ if (
397
+ os .path .isfile (os .path .join (PATH , "build" , dmg_path ))
398
+ and dmg_path .endswith (".dmg" )
399
+ ):
381
400
os .rename (os .path .join (PATH , "build" , dmg_path ), app_build_path )
382
401
383
402
# Was the DMG creation successful
@@ -389,9 +408,7 @@ def upload(file_path, github_release):
389
408
# Delete build (since key signing might have failed)
390
409
os .remove (app_build_path )
391
410
392
-
393
411
if platform .system () == "Windows" :
394
-
395
412
# Move python folder structure, since Cx_Freeze doesn't put it in the correct place
396
413
exe_dir = os .path .join (PATH , 'build' , 'exe.mingw-3.7' )
397
414
python_dir = os .path .join (exe_dir , 'lib' , 'python3.7' )
@@ -402,7 +419,14 @@ def upload(file_path, github_release):
402
419
shutil .rmtree (duplicate_openshot_qt_path , True )
403
420
404
421
# Remove the following paths. cx_Freeze is including many unneeded files. This prunes them out.
405
- paths_to_delete = ['mediaservice' , 'imageformats' , 'platforms' , 'printsupport' , 'lib/openshot_qt' , 'resvg.dll' ]
422
+ paths_to_delete = [
423
+ 'mediaservice' ,
424
+ 'imageformats' ,
425
+ 'platforms' ,
426
+ 'printsupport' ,
427
+ 'lib/openshot_qt' ,
428
+ 'resvg.dll' ,
429
+ ]
406
430
for delete_path in paths_to_delete :
407
431
full_delete_path = os .path .join (exe_dir , delete_path )
408
432
output ("Delete path: %s" % full_delete_path )
@@ -420,14 +444,24 @@ def upload(file_path, github_release):
420
444
paths_to_replace = ['imageformats' , 'platforms' ]
421
445
for replace_name in paths_to_replace :
422
446
if windows_32bit :
423
- shutil .copytree (os .path .join ('C:\\ msys32\\ mingw32\\ share\\ qt5\\ plugins' , replace_name ), os .path .join (exe_dir , replace_name ))
447
+ shutil .copytree (
448
+ os .path .join ('C:\\ msys32\\ mingw32\\ share\\ qt5\\ plugins' , replace_name ),
449
+ os .path .join (exe_dir , replace_name ))
424
450
else :
425
- shutil .copytree (os .path .join ('C:\\ msys64\\ mingw64\\ share\\ qt5\\ plugins' , replace_name ), os .path .join (exe_dir , replace_name ))
451
+ shutil .copytree (
452
+ os .path .join ('C:\\ msys64\\ mingw64\\ share\\ qt5\\ plugins' , replace_name ),
453
+ os .path .join (exe_dir , replace_name ))
426
454
427
455
# Copy Qt5Core.dll, Qt5Svg.dll to root of frozen directory
428
- paths_to_copy = [("Qt5Core.dll" , "C:\\ msys64\\ mingw64\\ bin\\ " ), ("Qt5Svg.dll" , "C:\\ msys64\\ mingw64\\ bin\\ " )]
456
+ paths_to_copy = [
457
+ ("Qt5Core.dll" , "C:\\ msys64\\ mingw64\\ bin\\ " ),
458
+ ("Qt5Svg.dll" , "C:\\ msys64\\ mingw64\\ bin\\ " ),
459
+ ]
429
460
if windows_32bit :
430
- paths_to_copy = [("Qt5Core.dll" , "C:\\ msys32\\ mingw32\\ bin\\ " ), ("Qt5Svg.dll" , "C:\\ msys32\\ mingw32\\ bin\\ " )]
461
+ paths_to_copy = [
462
+ ("Qt5Core.dll" , "C:\\ msys32\\ mingw32\\ bin\\ " ),
463
+ ("Qt5Svg.dll" , "C:\\ msys32\\ mingw32\\ bin\\ " ),
464
+ ]
431
465
for qt_file_name , qt_parent_path in paths_to_copy :
432
466
qt5_path = os .path .join (qt_parent_path , qt_file_name )
433
467
new_qt5_path = os .path .join (exe_dir , qt_file_name )
@@ -452,7 +486,17 @@ def upload(file_path, github_release):
452
486
# Add version metadata to frozen app launcher
453
487
launcher_exe = os .path .join (exe_dir , "openshot-qt.exe" )
454
488
verpatch_success = True
455
- verpatch_command = '"verpatch.exe" "{}" /va /high "{}" /pv "{}" /s product "{}" /s company "{}" /s copyright "{}" /s desc "{}"' .format (launcher_exe , info .VERSION , info .VERSION , info .PRODUCT_NAME , info .COMPANY_NAME , info .COPYRIGHT , info .PRODUCT_NAME )
489
+ verpatch_command = " " .join ([
490
+ 'verpatch.exe' ,
491
+ '{}' .format (launcher_exe ),
492
+ '/va' ,
493
+ '/high "{}"' .format (info .VERSION ),
494
+ '/pv "{}"' .format (info .VERSION ),
495
+ '/s product "{}"' .format (info .PRODUCT_NAME ),
496
+ '/s company "{}"' .format (info .COMPANY_NAME ),
497
+ '/s copyright "{}"' .format (info .COPYRIGHT ),
498
+ '/s desc "{}"' .format (info .PRODUCT_NAME ),
499
+ ])
456
500
verpatch_output = ""
457
501
# version-stamp executable
458
502
for line in run_command (verpatch_command ):
@@ -472,7 +516,13 @@ def upload(file_path, github_release):
472
516
473
517
# Create Installer (OpenShot-%s-x86_64.exe)
474
518
inno_success = True
475
- inno_command = '"iscc.exe" /Q /DVERSION=%s /DONLY_64_BIT=%s "%s"' % (version , only_64_bit , os .path .join (PATH , 'installer' , 'windows-installer.iss' ))
519
+ inno_command = " " .join ([
520
+ 'iscc.exe' ,
521
+ '/Q' ,
522
+ '/DVERSION=%s' % version ,
523
+ '/DONLY_64_BIT=%s' % only_64_bit ,
524
+ '"%s"' % os .path .join (PATH , 'installer' , 'windows-installer.iss' ),
525
+ ])
476
526
inno_output = ""
477
527
# Compile Inno installer
478
528
for line in run_command (inno_command ):
@@ -495,7 +545,14 @@ def upload(file_path, github_release):
495
545
496
546
# Sign the installer
497
547
key_sign_success = True
498
- key_sign_command = '"kSignCMD.exe" /f "%s%s" /p "%s" /d "OpenShot Video Editor" /du "http://www.openshot.org" "%s"' % (windows_key , only_64_bit , windows_key_password , app_build_path )
548
+ key_sign_command = " " .join ([
549
+ 'kSignCMD.exe' ,
550
+ '/f "%s%s"' % (windows_key , only_64_bit ),
551
+ '/p "%s"' % windows_key_password ,
552
+ '/d "OpenShot Video Editor"' ,
553
+ '/du "http://www.openshot.org"' ,
554
+ '"%s"' % app_build_path ,
555
+ ])
499
556
key_sign_output = ""
500
557
# Sign MSI
501
558
for line in run_command (key_sign_command ):
@@ -513,7 +570,6 @@ def upload(file_path, github_release):
513
570
# Delete build (since key signing might have failed)
514
571
os .remove (app_build_path )
515
572
516
-
517
573
# Upload Installer to GitHub (if build path exists)
518
574
if needs_upload and os .path .exists (app_build_path ):
519
575
# Upload file to GitHub
@@ -522,7 +578,19 @@ def upload(file_path, github_release):
522
578
523
579
# Create torrent and upload
524
580
torrent_path = "%s.torrent" % app_build_path
525
- torrent_command = 'mktorrent -a "udp://tracker.openbittorrent.com:80/announce, udp://tracker.publicbt.com:80/announce, udp://tracker.opentrackr.org:1337" -c "OpenShot Video Editor %s" -w "%s" -o "%s" "%s"' % (version , download_url , "%s.torrent" % app_name , app_name )
581
+ tracker_list = [
582
+ "udp://tracker.openbittorrent.com:80/announce" ,
583
+ "udp://tracker.publicbt.com:80/announce" ,
584
+ "udp://tracker.opentrackr.org:1337" ,
585
+ ]
586
+ torrent_command = " " .join ([
587
+ 'mktorrent' ,
588
+ '-a "%s"' % (", " .join (tracker_list )),
589
+ '-c "OpenShot Video Editor %s"' % version ,
590
+ '-w "%s"' % download_url ,
591
+ '-o "%s"' % ("%s.torrent" % app_name ),
592
+ '"%s"' % app_name ,
593
+ ])
526
594
torrent_output = ""
527
595
528
596
# Remove existing torrents (if any found)
@@ -544,7 +612,10 @@ def upload(file_path, github_release):
544
612
url = upload (torrent_path , github_release )
545
613
546
614
# Notify Zulip
547
- zulip_upload_log (zulip_token , log , "%s: Build logs for %s" % (platform .system (), app_name ), "Successful *%s* build: %s" % (git_branch_name , download_url ))
615
+ zulip_upload_log (
616
+ zulip_token , log ,
617
+ "%s: Build logs for %s" % (platform .system (), app_name ),
618
+ "Successful *%s* build: %s" % (git_branch_name , download_url ))
548
619
549
620
except Exception as ex :
550
621
tb = traceback .format_exc ()
@@ -555,5 +626,12 @@ def upload(file_path, github_release):
555
626
else :
556
627
# Report any errors detected
557
628
output ("build-server script failed!" )
558
- zulip_upload_log (zulip_token , log , "%s: Error log for *%s* build" % (platform .system (), git_branch_name ), ":skull_and_crossbones: %s" % truncate (errors_detected [0 ], 100 ))
629
+ zulip_upload_log (
630
+ zulip_token , log ,
631
+ "%s: Error log for *%s* build" % (platform .system (), git_branch_name ),
632
+ ":skull_and_crossbones: %s" % truncate (errors_detected [0 ], 100 ))
559
633
exit (1 )
634
+
635
+
636
+ if __name__ == "__main__" :
637
+ main ()
0 commit comments