MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / dedsec_os_server_source

Function dedsec_os_server_source

Scripts/Settings.py:2880–6747  ·  view source on GitHub ↗

Returns the generated DedSec OS local server source code.

()

Source from the content-addressed store, hash-verified

2878 """Runs git with the authenticated GitHub token using GIT_ASKPASS."""
2879 askpass_path = _write_sponsors_git_askpass(token)
2880 env = os.environ.copy()
2881 env["GIT_ASKPASS"] = askpass_path
2882 env["GIT_TERMINAL_PROMPT"] = "0"
2883 env["DEDSEC_GITHUB_TOKEN"] = token
2884 try:
2885 completed = subprocess.run(
2886 ["git"] + list(git_args),
2887 cwd=cwd,
2888 text=True,
2889 stdout=subprocess.PIPE,
2890 stderr=subprocess.STDOUT,
2891 check=False,
2892 env=env,
2893 )
2894 return completed.returncode, (completed.stdout or "").strip()
2895 except Exception as error:
2896 return 1, str(error)
2897 finally:
2898 try:
2899 os.remove(askpass_path)
2900 except Exception:
2901 pass
2902
2903
2904def sponsors_repo_access_status(tier_key="3"):
2905 """Returns (has_access, message) for a private Sponsors-Only tier repository."""
2906 config = get_sponsor_tier_config(tier_key)
2907 if not config:
2908 return False, _("Invalid sponsor tier.")
2909
2910 if not github_cli_available() or not github_auth_status():
2911 return False, _("GitHub is not connected yet.")
2912
2913 if not ensure_pkg_command("git", "git"):
2914 return False, "git could not be installed. Run manually: pkg install git"
2915
2916 token = github_token_for_sponsors()
2917 if not token:
2918 return False, "Could not read GitHub token. Run manually: gh auth refresh -h github.com -s repo"
2919
2920 rc, out = run_sponsors_git_command(["ls-remote", config["git_url"], "HEAD"], token)
2921 if rc == 0:
2922 success_message = _("Sponsors-Only access confirmed.") + f" ({config['label']})"
2923 return True, success_message
2924
2925 message = (out or "").strip()
2926 if "saml" in message.lower() or "sso" in message.lower():
2927 message = "GitHub access exists but the token may need SSO approval for the organization. Open GitHub in browser and authorize the gh token for this organization."
2928 elif not message or "repository not found" in message.lower() or "authentication failed" in message.lower():
2929 message = _("You do not have access to the Sponsors-Only repository yet.")
2930 return False, message
2931
2932
2933def remove_old_sponsors_copies(tier_key="3", include_final=True):
2934 config = get_sponsor_tier_config(tier_key)
2935 if not config:
2936 return
2937

Callers 1

ensure_dedsec_os_filesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected