Skip to content

Commit 50dde37

Browse files
committed
Let's see how this'll do
1 parent 31c6beb commit 50dde37

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

.github/workflows/pre-commit-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
pre-commit:
1313
name: "Pre-commit checks"
14-
runs-on: ubuntu-latest
14+
runs-on: windows-latest
1515
steps:
1616
- uses: actions/checkout@v3
1717
- uses: actions/setup-python@v4
Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
11
#!/usr/bin/env python3
2+
import os
23
import sys
34
import shlex
45
import shutil
6+
import requests
57
import subprocess
8+
from zipfile import ZipFile
69

710

811
def main():
912
if sys.platform == "win32":
10-
executable = shutil.which("powershell.exe")
11-
cmd = shlex.split("Set-ExecutionPolicy RemoteSigned -Scope CurrentUser;irm get.scoop.sh | iex", posix=False)
12-
p_scoop = subprocess.run(cmd, shell=True, executable=executable)
13-
p_install = subprocess.run(shlex.split("scoop install gettext", posix=False), shell=True, executable=executable)
13+
powershell = shutil.which("powershell.exe")
14+
gettext_url = "https://github.com/vslavik/gettext-tools-windows/releases/download/v0.21.1/gettext-tools-windows-0.21.1.zip"
15+
gettext_path = os.path.join(os.environ["LOCALAPPDATA"], "Programs", "gettext-tools")
16+
gettext_zip = os.path.join(gettext_path, "gettext-tools.zip")
17+
18+
try:
19+
subprocess.run(shlex.split(f"mkdir -p {gettext_path}", posix=False), shell=True, executable=powershell)
20+
21+
response = requests.get(gettext_url)
22+
with open(gettext_zip, "wb") as f:
23+
f.write(response.content)
24+
25+
with ZipFile(gettext_zip, "r") as zip:
26+
zip.extractall(gettext_path)
27+
28+
os.remove(gettext_zip)
29+
os.environ["PATH"] += os.pathsep + os.path.join(gettext_path, "bin")
1430

15-
return p_scoop.returncode or p_install.returncode
31+
except Exception as e:
32+
print(e)
33+
return 1
34+
35+
else:
36+
return 0
1637

1738
elif sys.platform in ["linux", "linux2"]:
1839
cmd = "sudo apt update; sudo apt install -y gettext"
@@ -22,5 +43,5 @@ def main():
2243

2344

2445
if __name__ == "__main__":
25-
print(".")
46+
print("Installing gettext...")
2647
exit(main())

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tqdm
44
pre-commit
55
polib
66
deep_translator
7+
requests

0 commit comments

Comments
 (0)