.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.version Namespace Reference

Functions

 subprocess_run (args, **kwargs)
 
 get_git_url_and_branch ()
 
 get_git_version ()
 

Variables

str VERSION_STRING = "1.0.0"
 
str VERSION_TAG = "1.0.0"
 
str GIT_URL = "unknow"
 
str GIT_BRANCH = "unknow"
 
 logger = logging.getLogger("searx")
 
dict SUBPROCESS_RUN_ENV
 
 vf = importlib.import_module('searx.version_frozen')
 
 DOCKER_TAG
 
str python_code
 
 encoding
 
str shell_code
 

Function Documentation

◆ get_git_url_and_branch()

searx.version.get_git_url_and_branch ( )

Definition at line 43 of file version.py.

43def get_git_url_and_branch():
44 try:
45 ref = subprocess_run("git rev-parse --abbrev-ref @{upstream}")
46 except subprocess.CalledProcessError:
47 ref = subprocess_run("git rev-parse --abbrev-ref master@{upstream}")
48 origin, git_branch = ref.split("/", 1)
49 git_url = subprocess_run(["git", "remote", "get-url", origin])
50
51 # get https:// url from git@ url
52 if git_url.startswith("git@"):
53 git_url = git_url.replace(":", "/", 2).replace("git@", "https://", 1)
54 if git_url.endswith(".git"):
55 git_url = git_url.replace(".git", "", 1)
56
57 return git_url, git_branch
58
59

References searx.version.subprocess_run().

+ Here is the call graph for this function:

◆ get_git_version()

searx.version.get_git_version ( )

Definition at line 60 of file version.py.

60def get_git_version():
61 git_commit_date_hash = subprocess_run(r"git show -s --date='format:%Y.%m.%d' --format='%cd+%h'")
62 # Remove leading zero from minor and patch level / replacement of PR-2122
63 # which depended on the git version: '2023.05.06+..' --> '2023.5.6+..'
64 git_commit_date_hash = git_commit_date_hash.replace('.0', '.')
65 tag_version = git_version = git_commit_date_hash
66
67 # add "+dirty" suffix if there are uncommitted changes except searx/settings.yml
68 try:
69 subprocess_run("git diff --quiet -- . ':!searx/settings.yml' ':!utils/brand.env'")
70 except subprocess.CalledProcessError as e:
71 if e.returncode == 1:
72 git_version += "+dirty"
73 else:
74 logger.warning('"%s" returns an unexpected return code %i', e.returncode, e.cmd)
75 docker_tag = git_version.replace("+", "-")
76 return git_version, tag_version, docker_tag
77
78

References searx.version.subprocess_run().

+ Here is the call graph for this function:

◆ subprocess_run()

searx.version.subprocess_run ( args,
** kwargs )
Call :py:func:`subprocess.run` and return (striped) stdout.  If returncode is
non-zero, raise a :py:func:`subprocess.CalledProcessError`.

Definition at line 26 of file version.py.

26def subprocess_run(args, **kwargs):
27 """Call :py:func:`subprocess.run` and return (striped) stdout. If returncode is
28 non-zero, raise a :py:func:`subprocess.CalledProcessError`.
29 """
30 if not isinstance(args, (list, tuple)):
31 args = shlex.split(args)
32
33 kwargs["env"] = kwargs.get("env", SUBPROCESS_RUN_ENV)
34 kwargs["encoding"] = kwargs.get("encoding", "utf-8")
35 kwargs["stdout"] = subprocess.PIPE
36 kwargs["stderr"] = subprocess.PIPE
37 # raise CalledProcessError if returncode is non-zero
38 kwargs["check"] = True
39 proc = subprocess.run(args, **kwargs) # pylint: disable=subprocess-run-check
40 return proc.stdout.strip()
41
42

Referenced by searx.version.get_git_url_and_branch(), and searx.version.get_git_version().

+ Here is the caller graph for this function:

Variable Documentation

◆ DOCKER_TAG

searx.version.DOCKER_TAG

Definition at line 81 of file version.py.

◆ encoding

searx.version.encoding

Definition at line 119 of file version.py.

◆ GIT_BRANCH

searx.version.GIT_BRANCH = "unknow"

Definition at line 15 of file version.py.

◆ GIT_URL

searx.version.GIT_URL = "unknow"

Definition at line 14 of file version.py.

◆ logger

searx.version.logger = logging.getLogger("searx")

Definition at line 17 of file version.py.

◆ python_code

str searx.version.python_code
Initial value:
1= f"""# SPDX-License-Identifier: AGPL-3.0-or-later
2# pylint: disable=missing-module-docstring
3# this file is generated automatically by searx/version.py
4
5VERSION_STRING = "{VERSION_STRING}"
6VERSION_TAG = "{VERSION_TAG}"
7DOCKER_TAG = "{DOCKER_TAG}"
8GIT_URL = "{GIT_URL}"
9GIT_BRANCH = "{GIT_BRANCH}"
10"""

Definition at line 109 of file version.py.

◆ shell_code

str searx.version.shell_code
Initial value:
1= f"""
2VERSION_STRING="{VERSION_STRING}"
3VERSION_TAG="{VERSION_TAG}"
4DOCKER_TAG="{DOCKER_TAG}"
5GIT_URL="{GIT_URL}"
6GIT_BRANCH="{GIT_BRANCH}"
7"""

Definition at line 125 of file version.py.

◆ SUBPROCESS_RUN_ENV

dict searx.version.SUBPROCESS_RUN_ENV
Initial value:
1= {
2 "PATH": os.environ["PATH"],
3 "LC_ALL": "C",
4 "LANGUAGE": "",
5}

Definition at line 19 of file version.py.

◆ VERSION_STRING

searx.version.VERSION_STRING = "1.0.0"

Definition at line 12 of file version.py.

◆ VERSION_TAG

searx.version.VERSION_TAG = "1.0.0"

Definition at line 13 of file version.py.

◆ vf

searx.version.vf = importlib.import_module('searx.version_frozen')

Definition at line 80 of file version.py.