|
|
@@ -162,88 +162,8 @@ def install_db( |
|
|
|
influxframework.flags.in_install_db = False |
|
|
|
|
|
|
|
|
|
|
|
def find_org(org_repo: str) -> tuple[str, str]: |
|
|
|
"""find the org a repo is in |
|
|
|
|
|
|
|
find_org() |
|
|
|
ref -> https://github.com/influxframework/bench/blob/develop/bench/utils/__init__.py#L390 |
|
|
|
|
|
|
|
:param org_repo: |
|
|
|
:type org_repo: str |
|
|
|
|
|
|
|
:raises InvalidRemoteException: if the org is not found |
|
|
|
|
|
|
|
:return: organisation and repository |
|
|
|
:rtype: Tuple[str, str] |
|
|
|
""" |
|
|
|
import requests |
|
|
|
|
|
|
|
from influxframework.exceptions import InvalidRemoteException |
|
|
|
|
|
|
|
for org in ["influxframework", "influxerp"]: |
|
|
|
response = requests.head(f"https://api.github.com/repos/{org}/{org_repo}") |
|
|
|
if response.status_code == 400: |
|
|
|
response = requests.head(f"https://github.com/{org}/{org_repo}") |
|
|
|
if response.ok: |
|
|
|
return org, org_repo |
|
|
|
|
|
|
|
raise InvalidRemoteException |
|
|
|
|
|
|
|
|
|
|
|
def fetch_details_from_tag(_tag: str) -> tuple[str, str, str]: |
|
|
|
"""parse org, repo, tag from string |
|
|
|
|
|
|
|
fetch_details_from_tag() |
|
|
|
ref -> https://github.com/influxframework/bench/blob/develop/bench/utils/__init__.py#L403 |
|
|
|
|
|
|
|
:param _tag: input string |
|
|
|
:type _tag: str |
|
|
|
|
|
|
|
:return: organisation, repostitory, tag |
|
|
|
:rtype: Tuple[str, str, str] |
|
|
|
""" |
|
|
|
app_tag = _tag.split("@") |
|
|
|
org_repo = app_tag[0].split("/") |
|
|
|
|
|
|
|
try: |
|
|
|
repo, tag = app_tag |
|
|
|
except ValueError: |
|
|
|
repo, tag = app_tag + [None] |
|
|
|
|
|
|
|
try: |
|
|
|
org, repo = org_repo |
|
|
|
except Exception: |
|
|
|
org, repo = find_org(org_repo[0]) |
|
|
|
|
|
|
|
return org, repo, tag |
|
|
|
|
|
|
|
|
|
|
|
def parse_app_name(name: str) -> str: |
|
|
|
"""parse repo name from name |
|
|
|
|
|
|
|
__setup_details_from_git() |
|
|
|
ref -> https://github.com/influxframework/bench/blob/develop/bench/app.py#L114 |
|
|
|
|
|
|
|
|
|
|
|
:param name: git tag |
|
|
|
:type name: str |
|
|
|
|
|
|
|
:return: repository name |
|
|
|
:rtype: str |
|
|
|
""" |
|
|
|
name = name.rstrip("/") |
|
|
|
if os.path.exists(name): |
|
|
|
repo = os.path.split(name)[-1] |
|
|
|
elif is_git_url(name): |
|
|
|
if name.startswith("git@") or name.startswith("ssh://"): |
|
|
|
_repo = name.split(":")[1].rsplit("/", 1)[1] |
|
|
|
else: |
|
|
|
_repo = name.rsplit("/", 2)[2] |
|
|
|
repo = _repo.split(".")[0] |
|
|
|
else: |
|
|
|
_, repo, _ = fetch_details_from_tag(name) |
|
|
|
return repo |
|
|
|
|
|
|
|
return name |
|
|
|
|
|
|
|
def install_app(name, verbose=False, set_as_patched=True, force=False): |
|
|
|
from influxframework.core.doctype.scheduled_job_type.scheduled_job_type import sync_jobs |
|
|
|