-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit b7809b9 Author: EpochFlame <[email protected]> Date: Mon Jan 1 10:52:02 2024 -0500 fix missing files with workflow commit 0cb6273 Author: EpochFlame <[email protected]> Date: Mon Jan 1 10:22:55 2024 -0500 update workflow
- Loading branch information
1 parent
17220af
commit 9b42ea1
Showing
4 changed files
with
210 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
# borrowed from prime-decomp | ||
import argparse | ||
import os | ||
from platform import uname | ||
from typing import List | ||
|
||
if os.name != 'nt': | ||
wineprefix = os.environ.get('WINEPREFIX', os.path.join(os.environ['HOME'], '.wine')) | ||
winedevices = os.path.join(wineprefix, 'dosdevices') | ||
|
||
|
||
def in_wsl() -> bool: | ||
# wsl1 has Microsoft, wsl2 has microsoft-standard | ||
release = uname().release | ||
return 'microsoft-standard' in release or 'Microsoft' in release | ||
|
||
|
||
def convert_path(path: str) -> str: | ||
# lowercase drive letter | ||
path = path[0].lower() + path[1:] | ||
if os.name == 'nt': | ||
return path.replace('\\', '/') | ||
elif path[0] == 'z': | ||
# shortcut for z: | ||
return path[2:].replace('\\', '/') | ||
elif in_wsl(): | ||
if path.startswith(r'\\wsl'): | ||
# first part could be wsl$ or wsl.localhost | ||
pos = path.find('\\', 2) | ||
pos = path.find('\\', pos + 1) | ||
path = path[pos:] | ||
return path.replace('\\', '/') | ||
else: | ||
path = path[0:1] + path[2:] | ||
return os.path.join('/mnt', path.replace('\\', '/')) | ||
else: | ||
# use $WINEPREFIX/dosdevices to resolve path | ||
return os.path.realpath(os.path.join(winedevices, path.replace('\\', '/'))) | ||
|
||
|
||
def import_d_file(in_file: str) -> str: | ||
out_lines: List[str] = [] | ||
|
||
with open(in_file, 'r') as file: | ||
it = iter(file) | ||
line = next(it) | ||
if line.endswith(' \\\n'): | ||
out_lines.append(line[:-3].replace('\\', '/') + " \\\n") | ||
else: | ||
out_lines.append(line.replace('\\', '/')) | ||
|
||
return ''.join(out_lines) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="""Transform a .d file from Wine paths to normal paths""" | ||
) | ||
parser.add_argument( | ||
"d_file", | ||
help="""Dependency file in""", | ||
) | ||
parser.add_argument( | ||
"d_file_out", | ||
help="""Dependency file out""", | ||
) | ||
args = parser.parse_args() | ||
|
||
output = import_d_file(args.d_file) | ||
|
||
with open(args.d_file_out, "w", encoding="UTF-8") as f: | ||
f.write(output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
|
||
def import_d_file(in_file) -> str: | ||
out_text = '' | ||
|
||
with open(in_file) as file: | ||
for idx, line in enumerate(file): | ||
if idx != 0: | ||
path_found_pos = line.find("include") | ||
line = "\t" + line[path_found_pos:] | ||
if line.endswith(' \\\n'): | ||
out_text += line[:-3].replace('\\', '/') + " \\\n" | ||
else: | ||
out_text += line.replace('\\', '/') | ||
else: | ||
if line.endswith(' \\\n'): | ||
out_text += line[:-3].replace('\\', '/') + " \\\n" | ||
else: | ||
out_text += line.replace('\\', '/') | ||
|
||
return out_text | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description="""Transform a .d file from Wine paths to normal paths""" | ||
) | ||
parser.add_argument( | ||
"d_file", | ||
help="""Dependency file in""", | ||
) | ||
parser.add_argument( | ||
"d_file_out", | ||
help="""Dependency file out""", | ||
) | ||
args = parser.parse_args() | ||
|
||
output = import_d_file(args.d_file) | ||
|
||
with open(args.d_file_out, "w", encoding="UTF-8") as f: | ||
f.write(output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import json | ||
import os | ||
import subprocess | ||
from pprint import pprint | ||
|
||
import requests | ||
|
||
|
||
def get_git_commit_timestamp() -> int: | ||
return int(subprocess.check_output(['git', 'show', '-s', '--format=%ct']).decode('ascii').rstrip()) | ||
|
||
|
||
def get_git_commit_sha() -> str: | ||
return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() | ||
|
||
|
||
def generate_url(args: argparse.Namespace) -> str: | ||
url_components = [args.base_url.rstrip('/'), 'data'] | ||
|
||
for arg in [args.project, args.version.replace('.', '-')]: | ||
if arg != "": | ||
url_components.append(arg) | ||
|
||
return str.join('/', url_components) + '/' | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description="Upload progress information.") | ||
parser.add_argument("-b", "--base_url", help="API base URL", required=True) | ||
parser.add_argument("-a", "--api_key", help="API key (env var PROGRESS_API_KEY)") | ||
parser.add_argument("-p", "--project", help="Project slug", required=True) | ||
parser.add_argument("-v", "--version", help="Version slug", required=True) | ||
parser.add_argument("input", help="Progress JSON input") | ||
|
||
args = parser.parse_args() | ||
api_key = args.api_key or os.environ.get("PROGRESS_API_KEY") | ||
if not api_key: | ||
raise "API key required" | ||
url = generate_url(args) | ||
|
||
entries = [] | ||
with open(args.input, "r") as f: | ||
data = json.load(f) | ||
entries.append({ | ||
"timestamp": get_git_commit_timestamp(), | ||
"git_hash": get_git_commit_sha(), | ||
"categories": data, | ||
}) | ||
|
||
print("Publishing entries to", url) | ||
pprint(entries) | ||
data = { | ||
"api_key": api_key, | ||
"entries": entries, | ||
} | ||
r = requests.post(url, json=data) | ||
r.raise_for_status() | ||
print("Done!") |