This commit is contained in:
Ian Curtis 2023-10-14 20:05:07 +01:00
commit d32641030d

View file

@ -1,7 +1,7 @@
# #
# Supermodel # Supermodel
# A Sega Model 3 Arcade Emulator. # A Sega Model 3 Arcade Emulator.
# Copyright 2003-2022 The Supermodel Team # Copyright 2003-2023 The Supermodel Team
# #
# This file is part of Supermodel. # This file is part of Supermodel.
# #
@ -35,6 +35,7 @@
# - msys/subversion package # - msys/subversion package
# - msys/zip package # - msys/zip package
# - git # - git
# - paramiko (Python package for SSH/SFTP)
# #
# To perform a test run: # To perform a test run:
# - Download https://supermodel3.com/Download.html to the directory from # - Download https://supermodel3.com/Download.html to the directory from
@ -43,11 +44,14 @@
# #
import argparse import argparse
import base64
import os import os
import shutil import shutil
import sys import sys
import tempfile import tempfile
import paramiko
class CheckoutError(Exception): class CheckoutError(Exception):
pass pass
@ -81,7 +85,7 @@ def get_web_page(test_run):
html = fp.read() html = fp.read()
else: else:
import urllib.request import urllib.request
with urllib.request.urlopen("https://supermodel3.com/Download.html") as data: with urllib.request.urlopen("http://supermodel3.com/Download.html") as data:
html = data.read().decode("utf-8") html = data.read().decode("utf-8")
return html return html
@ -141,7 +145,7 @@ def create_change_log(bash, repo_dir, file_path, uploaded_shas, current_sha):
"\n" \ "\n" \
" A Sega Model 3 Arcade Emulator.\n" \ " A Sega Model 3 Arcade Emulator.\n" \
"\n" \ "\n" \
" Copyright 2003-2022 The Supermodel Team\n" \ " Copyright 2003-2023 The Supermodel Team\n" \
"\n" \ "\n" \
" CHANGE LOG\n" \ " CHANGE LOG\n" \
"\n" \ "\n" \
@ -154,16 +158,21 @@ def write_html_file(html, file_path):
fp.write(html) fp.write(html)
def upload(html_file, zip_file_path, username, password): def upload(html_file, zip_file_path, username, password):
from ftplib import FTP # supermodel3.com host public key
ftp = FTP("supermodel3.com") keydata=b"""AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBE49lZKcEsFhEfEgVc4iNrBKOtItoXqQ/TKkPH9bAWOfn25H9BAi5AjkpqSsv/p1T5qfDni5G9sajqzamHw0TmU="""
ftp.login(username, password) key = paramiko.ECDSAKey(data=base64.decodebytes(keydata))
ftp.cwd("public_html/Files/Git_Snapshots")
with open(zip_file_path, "rb") as fp: # Create SFTP client
ftp.storbinary("STOR " + os.path.basename(zip_file_path), fp) ssh = paramiko.SSHClient()
ftp.cwd("../../") ssh.get_host_keys().add('supermodel3.com', 'ecdsa-sha2-nistp256', key)
with open(html_file, "rb") as fp: ssh.connect(hostname = "supermodel3.com", username = options.username, password = options.password)
ftp.storlines("STOR Download.html", fp) sftp = ssh.open_sftp()
ftp.quit()
# Upload
sftp.put(localpath = zip_file_path, remotepath = f"public_html/Files/Git_Snapshots/{os.path.basename(zip_file_path)}")
sftp.put(localpath = html_file, remotepath = "public_html/Download.html")
sftp.close()
ssh.close()
def confirm_package_contents(package_dir, package_files): def confirm_package_contents(package_dir, package_files):
all_found = True all_found = True