Skip to content

Commit fdbfe48

Browse files
committed
Create entry and print version
1 parent e0a8c62 commit fdbfe48

4 files changed

Lines changed: 114 additions & 1 deletion

File tree

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
selenium >= 4.3.0
22
robotframework >= 4.1.3
3-
robotframework-pythonlibcore >= 3.0.0
3+
robotframework-pythonlibcore >= 4.4.1
4+
click >= 8.1.7
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2008-2011 Nokia Networks
2+
# Copyright 2011-2016 Ryan Tomac, Ed Manlove and contributors
3+
# Copyright 2016- Robot Framework Foundation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2008-2011 Nokia Networks
2+
# Copyright 2011-2016 Ryan Tomac, Ed Manlove and contributors
3+
# Copyright 2016- Robot Framework Foundation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
import click
17+
18+
from print_version import print_version
19+
20+
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
21+
22+
23+
@click.group(
24+
invoke_without_command=True, context_settings=CONTEXT_SETTINGS, no_args_is_help=True
25+
)
26+
@click.option(
27+
"--version",
28+
is_flag=True,
29+
help="Prints versions and exits",
30+
callback=print_version,
31+
expose_value=False,
32+
is_eager=True,
33+
)
34+
def cli():
35+
"""Robot Framework SeleniumLibrary command line tool.
36+
37+
Possible commands are:
38+
translation
39+
40+
41+
translation will generate detaul tranlsation json file from library keywords.
42+
43+
See each command argument help for more details what (optional) arguments that command supports.
44+
"""
45+
pass
46+
47+
48+
if __name__ == "__main__":
49+
cli()
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2008-2011 Nokia Networks
2+
# Copyright 2011-2016 Ryan Tomac, Ed Manlove and contributors
3+
# Copyright 2016- Robot Framework Foundation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
from pathlib import Path
17+
import re
18+
import subprocess
19+
import sys
20+
21+
from selenium import __version__
22+
23+
INSTALL_DIR = Path(__file__).parent.parent
24+
25+
26+
def get_rf_version() -> str:
27+
process = subprocess.run(
28+
[sys.executable, "-m", "robot", "--version"], capture_output=True, check=False
29+
)
30+
return process.stdout.decode("utf-8").split(" ")[2]
31+
32+
33+
def get_library_version() -> str:
34+
init_file = INSTALL_DIR / "__init__.py"
35+
with init_file.open("r") as file:
36+
data = file.read()
37+
return re.search('\n__version__ = "(.*)"', data).group(1)
38+
39+
40+
def print_version(ctx, param, value):
41+
"""Display Python, Robot Framework, SeleniumLibrary and selenium versions"""
42+
python_version = (
43+
f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
44+
)
45+
print(f"Used Python is: {sys.executable}\nVersion: {python_version}")
46+
print(f'Robot Framework version: "{get_rf_version()}"')
47+
print(f"Installed SeleniumLibrary version is: {get_library_version()}")
48+
print(f"Installed selenium version is: {__version__}")

0 commit comments

Comments
 (0)