Skip to content

Commit bb5cfb4

Browse files
committed
#4 potential fix for windows support
1 parent 7bf0cc3 commit bb5cfb4

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ def createConfig():
3737
flags = ["--color", "--color-bg", "-b"]
3838
createConfig()
3939

40-
41-
# Determine whether to use file-based execution for Windows
42-
useFile = platform.system().upper() == 'WINDOWS'
43-
4440
# Check if ascii-image-converter needs to be installed
4541
try:
4642
subprocess.run(["ascii-image-converter", "--version"], check=True, capture_output=True)
@@ -97,7 +93,7 @@ def createConfig():
9793

9894
# Convert the image to colorful ASCII using ascii-image-converter and print it.
9995
try:
100-
binary_name = "ascii-image-converter.exe" if useFile else "ascii-image-converter"
96+
binary_name = r"C:\Program Files\TheZoraiz\ascii-image-converter\ascii-image-converter.exe" if platform.system().upper() == 'WINDOWS' else "ascii-image-converter"
10197
subprocess.run([binary_name, *flags, image_file], check=True)
10298
except subprocess.CalledProcessError as e:
10399
print(f"Error running ascii-image-converter: {e}")

src/setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, subprocess, platform, shutil, tarfile, zipfile, yaml, sys, requests
1+
import os, subprocess, platform, shutil, tarfile, zipfile, yaml, sys, requests, ctypes
22

33
def main():
44
# Detect the operating system and architecture to select the correct binary for ascii-image-converter
@@ -40,6 +40,11 @@ def main():
4040
# Detect the architecture and the OS, set the release name
4141
match system:
4242
case 'WINDOWS':
43+
if os.getuid() == 0:
44+
print("Running as administrator.")
45+
else:
46+
print("Please run the program with administrator rights for setup.")
47+
sys.exit(1)
4348
useFile = True
4449
match machine:
4550
case 'AMD64' | 'X86_64':
@@ -118,6 +123,7 @@ def main():
118123
print("Error extracting file: Unsupported file format.")
119124
sys.exit(1)
120125

126+
121127
# Check if the operating system is not Windows
122128
if system != 'WINDOWS':
123129
if system == 'LINUX': # Assign the platform to match the binary name
@@ -133,6 +139,12 @@ def main():
133139
except Exception as e:
134140
print(f"Failed to move binaries: {e}")
135141
sys.exit(1)
142+
else:
143+
os.makedirs("C:\\Program Files\\TheZoraiz\\ascii-image-converter")
144+
os.makedirs("C:\\Program Files\\widkit\\greetings")
145+
binary_path = os.path.join(extract_dir, releaseName.replace('.zip', '.exe'), 'ascii-image-converter')
146+
subprocess.run([ "mv", binary_path, "C:\\Program Files\\TheZoraiz\\ascii-image-converter"], check=True)
147+
subprocess.run([ "cp", "greetings-windows", "C:\\Program Files\\widkit\\greetings\\greetings.exe"], check=True)
136148

137149
# Cleanup
138150
print("Cleaning up...")

0 commit comments

Comments
 (0)