Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't wait for lockfile #3

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def windows(self):
sys.exit(0)
else:
windows.run_elevated(
__file__, "--only-elevated --skip-python", wait_for_exit=True
__file__, "--only-elevated --skip-python"
)

qt = qt_utils.WindowsQt(*self.config.get_qt_config())
Expand Down
17 changes: 1 addition & 16 deletions scripts/lib/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import lib.env as env
from lib.certificate import Certificate

LOCK_FILE = "tmp/elevated.lock"
MSBUILD_CMD = "msbuild"
SIGNTOOL_CMD = "signtool"
CERTUTIL_CMD = "certutil"
Expand All @@ -30,14 +29,10 @@
MSI_FILE = f"{BUILD_DIR}/installer/bin/Release/Synergy.msi"


def run_elevated(script, args=None, use_sys_argv=True, wait_for_exit=False):
def run_elevated(script, args=None, use_sys_argv=True):
if not args and use_sys_argv:
args = " ".join(sys.argv[1:])

if wait_for_exit:
args += f" --lock-file {LOCK_FILE}"
env.persist_lock_file(LOCK_FILE)

command = f"{script} {args} --pause-on-exit"
print(f"Running script with elevated privileges: {command}")

Expand All @@ -63,16 +58,6 @@ def run_elevated(script, args=None, use_sys_argv=True, wait_for_exit=False):

print("Script is running with elevated privileges")

if wait_for_exit:
with open(LOCK_FILE, "r") as f:
pid = f.read()

print(f"Waiting for elevated process to exit: {pid}")
while os.path.exists(LOCK_FILE):
# Intentionally wait forever, since this code should not run where a developer
# has no control, such as in a CI environment.
pass


def is_admin():
"""Returns True if the current process has admin privileges."""
Expand Down