Skip to content

Commit a849579

Browse files
committed
fix various bugs
* fix not clobbering when using a pattern * fixed installer not getting path when using pattern * fix registry not encoding properly when using different code pages. now uses powershell utility instead * fixed network error when version matches
1 parent cf30744 commit a849579

3 files changed

Lines changed: 71 additions & 31 deletions

File tree

pbpy/pbgh.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def get_cli_executable(git_url=None):
7070
def download_release_file(
7171
version: str | None, pattern=None, directory=None, repo: str | None = None
7272
):
73-
7473
cli_exec_path = get_cli_executable(repo)
7574

7675
if not os.path.isfile(cli_exec_path):
@@ -101,24 +100,28 @@ def try_remove(path):
101100
return 0
102101

103102
def check_wildcard(path):
104-
if "*" in file:
105-
return False
106-
return True
103+
if "*" in path:
104+
return True
105+
return False
107106

108107
if pattern:
109108
if not isinstance(pattern, list):
110109
pattern = [pattern]
111110
for file in pattern:
112-
if check_wildcard(file):
111+
if not check_wildcard(file):
113112
res = try_remove(file)
114113
if res != 0:
115114
return res
115+
elif "gh" in cli_exec_path:
116+
args.extend(["--clobber"])
116117
if "glab" in cli_exec_path:
117118
args.extend(["-n", file])
118119
else:
119120
args.extend(["-p", file])
120121
else:
121122
pattern = "*"
123+
if "gh" in cli_exec_path:
124+
args.extend(["--clobber"])
122125

123126
creds = get_token_env(repo)
124127

pbpy/pbunreal.py

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
p4merge_path = "/p4merge/p4merge.exe"
3434

35+
ps_reg_path = r'"HKCU:/Software/Epic Games/Unreal Engine/Builds"'
3536
reg_path = r"HKCU\Software\Epic Games\Unreal Engine\Builds"
3637

3738
long_path = "\\\\?\\"
@@ -186,10 +187,10 @@ def project_version_increase(increase_type):
186187
return False
187188
if increase_type == "patch":
188189
new_version = (
189-
f"{version_split[0] }.{version_split[1]}.{str(int(version_split[2]) + 1)}"
190+
f"{version_split[0]}.{version_split[1]}.{str(int(version_split[2]) + 1)}"
190191
)
191192
elif increase_type == "minor":
192-
new_version = f"{version_split[0] }.{str(int(version_split[1]) + 1)}.0"
193+
new_version = f"{version_split[0]}.{str(int(version_split[1]) + 1)}.0"
193194
elif increase_type == "major":
194195
new_version = f"{str(int(version_split[2]) + 1)}.0.0"
195196
else:
@@ -739,25 +740,46 @@ def generate_project_files():
739740
def parse_reg_query(proc):
740741
query = proc.stdout.splitlines()
741742
for res in query:
742-
if res.startswith(" "):
743-
key, rtype, value = res.split(" ")[1:]
744-
yield key, rtype, value
743+
res = res.strip()
744+
if not res:
745+
continue
746+
if res.startswith("PS"):
747+
continue
748+
key, value = res.split(" : ", 1)
749+
yield key, value
745750

746751

747752
def register_engine(version, path):
748753
if os.name == "nt":
754+
path = Path(path)
755+
target_path = str(Path(path).as_posix())
756+
registry_list = pbtools.run_with_combined_output(
757+
["powershell", "-Command", "Get-ItemProperty", "-Path", ps_reg_path]
758+
)
749759
# query if this path is used elsewhere, if so, we delete it
750-
for key, rtype, value in parse_reg_query(
751-
pbtools.run_with_combined_output(
752-
["reg", "query", reg_path, "/f", path, "/e", "/t", "REG_SZ"]
753-
)
754-
):
755-
# if we already have this version, no need to reregister it
756-
if key == version:
760+
for key, value in parse_reg_query(registry_list):
761+
# if we already have this version with our target path, no need to reregister it
762+
is_target_version = key == version
763+
if is_target_version and target_path == value:
757764
return False
758-
pbtools.run(["reg", "delete", reg_path, "/v", key, "/f"])
765+
# clear out if:
766+
# 1) if we do have a version match, but the path is different, OR
767+
# 2) if we have this path under a different version
768+
if is_target_version or path == Path(value):
769+
pbtools.run(["reg", "delete", reg_path, "/v", key, "/f"])
759770
pbtools.run(
760-
["reg", "add", reg_path, "/f", "/v", version, "/t", "REG_SZ", "/d", path]
771+
[
772+
"reg",
773+
"add",
774+
reg_path,
775+
"/f",
776+
"/v",
777+
version,
778+
"/t",
779+
"REG_SZ",
780+
"/d",
781+
target_path,
782+
]
761783
)
762784
return True
763785

@@ -950,7 +972,7 @@ def download_engine(bundle_name: str, download_symbols: bool):
950972
gcs_bucket = get_versionator_gsuri()
951973
if not gcs_bucket:
952974
pbtools.error_state(
953-
f"Cloud storage bucket not configured. Please get support from {pbconfig.get("support_channel")}"
975+
f"Cloud storage bucket not configured. Please get support from {pbconfig.get('support_channel')}"
954976
)
955977
return
956978
# TODO: maybe cache out Saved and Intermediate folders?
@@ -1035,10 +1057,19 @@ def change_args(args: list[str]):
10351057
# print out a newline
10361058
print("")
10371059

1060+
version_matches = (
1061+
branch_version and get_engine_version_with_prefix() == branch_version
1062+
)
1063+
10381064
if proc.returncode:
1039-
pbtools.error_state(
1040-
f"Failed to download engine update. Make sure your system time is synced. If this issue persists, please request help from {pbconfig.get('support_channel')}."
1041-
)
1065+
if not version_matches:
1066+
pbtools.error_state(
1067+
f"Failed to download engine update. Make sure your system time is synced. If this issue persists, please request help from {pbconfig.get('support_channel')}."
1068+
)
1069+
else:
1070+
pblog.error(
1071+
f"Failed to download engine update. Make sure your system time is synced. You may also be offline. If this issue persists, please request help from {pbconfig.get('support_channel')}."
1072+
)
10421073
# TODO: similarly, have to copy PDBs out into a store so longtail doesn't touch the engine and delete everything but symbols
10431074
if download_symbols:
10441075
pblog.warning(
@@ -1105,9 +1136,9 @@ def update_source_control():
11051136
with ue_config(
11061137
"Saved/Config/Windows/SourceControlSettings.ini"
11071138
) as source_control_config:
1108-
source_control_config["SourceControl.SourceControlSettings"][
1109-
"Provider"
1110-
] = "Git LFS 2"
1139+
source_control_config["SourceControl.SourceControlSettings"]["Provider"] = (
1140+
"Git LFS 2"
1141+
)
11111142
git_lfs_2 = source_control_config["GitSourceControl.GitSourceControlSettings"]
11121143
binary_path = pbgit.get_git_executable()
11131144
if binary_path and binary_path != "git":
@@ -1424,9 +1455,10 @@ def inspect_source(all=False):
14241455
if not zip_path.exists():
14251456
pblog.info(f"Downloading Resharper {version}")
14261457
url = f"https://download-cdn.jetbrains.com/resharper/dotUltimate.{version}/{zip_name}"
1427-
with urllib.request.urlopen(url) as response, open(
1428-
str(zip_path), "wb"
1429-
) as out_file:
1458+
with (
1459+
urllib.request.urlopen(url) as response,
1460+
open(str(zip_path), "wb") as out_file,
1461+
):
14301462
shutil.copyfileobj(response, out_file)
14311463
resharper_dir = saved_dir / Path("ResharperCLI")
14321464
pblog.info(f"Unpacking Resharper {version}")
@@ -1535,7 +1567,7 @@ def build_installed_build():
15351567
# reconstruct a versioned branch name
15361568
major = build_version["MajorVersion"]
15371569
minor = build_version["MinorVersion"]
1538-
branch_version = f"{major}.{minor}-{branch.split("-main")[0].upper()}"
1570+
branch_version = f"{major}.{minor}-{branch.split('-main')[0].upper()}"
15391571
changelist = build_version["Changelist"] + 1
15401572
code_changelist = build_version["CompatibleChangelist"] + 1
15411573

pbsync/prereqs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from pathlib import Path
99
from typing import Optional, Sequence
1010

11+
from pbpy import pbconfig, pbgh, pbgit, pblog, pbtools, pbuac
1112
from pbpy.platform import PlatformSpecificLazyValue, PlatformSpecificValue
12-
from pbpy import pblog, pbtools, pbconfig, pbgh, pbgit, pbuac
1313

1414

1515
class GenericInstaller:
@@ -57,6 +57,11 @@ def _download_and_get_path(self, directory: str) -> Optional[Path]:
5757
repo=repo_url,
5858
)
5959
if res == 0:
60+
if "*" in pat:
61+
for path in Path(directory).glob(pat):
62+
if path.is_file():
63+
return path
64+
return None
6065
return Path(directory) / pat
6166
return None
6267

0 commit comments

Comments
 (0)