Skip to content

Commit

Permalink
Fix running on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Mar 4, 2024
1 parent 959c2b9 commit dd9ef93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,17 @@ jobs:
- run: python -m pip install requests

- name: Get old version of Andorid Auto app for test purposes
run: curl.exe --output old-apk.apk "https://github.com/usefulness/storage/raw/master/android-auto-old.apk"
run: curl.exe --output old-apk.apk --url "https://github.com/usefulness/storage/raw/master/android-auto-old.apk"

- name: Get new version of Andorid Auto app for test purposes
run: curl.exe --output new-apk.apk "https://github.com/usefulness/storage/raw/master/android-auto-new.apk"
run: curl.exe --output new-apk.apk --url "https://github.com/usefulness/storage/raw/master/android-auto-new.apk"

- id: diffuse
uses: ./
with:
old-file-path: old-apk.apk
new-file-path: new-apk.apk
lib-version: 0.1.0
lib-version: 0.3.0
diffuse-repo: JakeWharton/diffuse
debug: true

Expand Down
12 changes: 8 additions & 4 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,20 @@ def sizeof_fmt(num, suffix='B', sign=False):
downloadArgs += "-q"

if url.endswith(".jar"):
os.system(f"wget \"{url}\" {downloadArgs} -O diffuse.jar")
r = requests.get(url, allow_redirects=True)
open("diffuse.jar", "wb").write(r.content)
exec_call = ["java", "-jar", "diffuse.jar"]
else:
os.system(f"wget \"{url}\" {downloadArgs} -O diffuse.zip")
r = requests.get(url, allow_redirects=True)
open("diffuse.zip", "wb").write(r.content)
with zipfile.ZipFile("diffuse.zip", "r") as zip_ref:
zip_ref.extractall("diffuse_extracted")

if os.name == "nt":
executable_name = "diffuse.bat"
else:
executable_name = "diffuse"
runnable = f"diffuse_extracted/diffuse-{lib_version}/bin/{executable_name}"
runnable = os.path.join("diffuse_extracted", f"diffuse-{lib_version}", "bin", executable_name)
st = os.stat("diffuse_extracted")
os.chmod(runnable, st.st_mode | stat.S_IEXEC)
exec_call = [runnable]
Expand Down Expand Up @@ -165,10 +167,12 @@ def sizeof_fmt(num, suffix='B', sign=False):
process = subprocess.Popen(exec_call, stdout=subprocess.PIPE)
out, _ = process.communicate()

diff = out.decode("utf-8").strip()

if process.returncode != 0:
print(f"output={diff}")
raise Exception("Error while executing diffuse")

diff = out.decode("utf-8").strip()

if is_debug():
print(f"Diff size: {len(diff)}")
Expand Down

0 comments on commit dd9ef93

Please sign in to comment.