Skip to content

Commit a6ab03d

Browse files
committed
Handling .torrent file differently, since the URL was invalid
1 parent ef7036d commit a6ab03d

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

installer/deploy.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import platform
3232
import traceback
3333
import re
34+
import urllib3
3435
from github3 import login
3536
from requests.auth import HTTPBasicAuth
3637
from requests import post, get
@@ -43,6 +44,9 @@
4344
# Access info class (for version info)
4445
sys.path.append(os.path.join(PATH, 'src', 'classes'))
4546

47+
# Disable SSL warnings
48+
urllib3.disable_warnings()
49+
4650

4751
if __name__ == "__main__":
4852
"""Only run this code when directly executing this script. """
@@ -180,14 +184,20 @@
180184
artifact_path = artifact_path_orig
181185
artifact_base, artifact_ext = os.path.splitext(artifact_name)
182186

183-
if os.path.exists(artifact_path) and artifact_ext in ['.exe', '.dmg', '.AppImage', '.torrent',
187+
if artifact_ext == '.torrent':
188+
# Delete torrent and continue (we'll recreate the torrents below when needed)
189+
# The artifact torrents have the incorrect URL inside them
190+
os.unlink(artifact_path)
191+
continue
192+
193+
if os.path.exists(artifact_path) and artifact_ext in ['.exe', '.dmg', '.AppImage',
184194
'.verify', '.sha256sum']:
185195
# Valid artifact/installer - Upload to GitHub Release
186196
output("GitHub: Uploading %s to GitHub Release: %s" % (artifact_path, github_release.tag_name))
187197
download_url = upload(artifact_path, github_release)
188198

189-
# Create shasum for installer
190-
if not artifact_name.endswith(".torrent"):
199+
# Create shasum and torrents for installers-only
200+
if artifact_ext in ['.exe', '.dmg', '.AppImage']:
191201
output("Generating file hash for %s" % artifact_path)
192202
shasum_output = ''
193203
for line in run_command('shasum -a 256 "%s"' % artifact_name, artifact_dir):
@@ -230,6 +240,22 @@
230240
f.write(' %s: OK' % artifact_name)
231241
upload(sha256sum_instructions_path, github_release)
232242

243+
# Create torrent and upload
244+
torrent_path = "%s.torrent" % artifact_path
245+
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"' % (github_release.tag_name, download_url, "%s.torrent" % artifact_name, artifact_name)
246+
torrent_output = ""
247+
for line in run_command(torrent_command, artifact_dir):
248+
output(line)
249+
if line:
250+
torrent_output = line.decode('UTF-8').strip()
251+
252+
if not torrent_output.endswith("Writing metainfo file... done."):
253+
# Torrent failed
254+
raise Exception("Failed to create .torrent for %s" % download_url)
255+
else:
256+
# Torrent succeeded! Upload the torrent to github
257+
url = upload(torrent_path, github_release)
258+
233259
# Submit blog post (if it doesn't already exist) (in draft mode)
234260
auth = HTTPBasicAuth(os.getenv('OPENSHOT_ORG_USER'), os.getenv('OPENSHOT_ORG_PASS'))
235261
r = post("https://www.openshot.org/api/release/submit/", auth=auth, data={ "version": github_release.tag_name,

0 commit comments

Comments
 (0)