Skip to content
This repository was archived by the owner on Nov 2, 2020. It is now read-only.

Commit d671b0a

Browse files
author
Tanakiat Srisaranyakul
committed
Raise an error message dialog if python with RBFW package is not python 3
1 parent 7d5f6e7 commit d671b0a

File tree

7 files changed

+20
-7
lines changed

7 files changed

+20
-7
lines changed

Robot.sublime-settings

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
and in Windows this could be like: C:\\Python27\\python.exe
7575
*/
7676

77-
"path_to_python3": "/usr/bin/python",
77+
"path_to_python": "/usr/bin/python",
7878

7979
/*
8080
Module search path defines a list of paths where the

command_helper/get_keyword.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,5 @@ def rf_data(self, file_path):
161161
return None
162162

163163
def is_string(self, str_):
164-
if version_info.major > 2:
165-
status = isinstance(str_, str)
166-
else:
167-
raise RuntimeError('Plugin only works with python 3')
168-
return status
164+
return isinstance(str_, str)
165+

commands/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import subprocess
12
from .command_logging import LogCommands
23
from .index_open_tab import IndexOpenTabCommand
34
from .jump_to_keyword import JumpToKeyword
@@ -11,6 +12,7 @@
1112
from .setting_import_helper import InsertImport
1213
from .setting_import_helper import SettingImporter
1314
from .show_documentation import ShowKeywordDocumentation
15+
from sublime import error_message
1416

1517
__all__ = [
1618
'IndexOpenTabCommand',
@@ -27,3 +29,11 @@
2729
'SettingImporter',
2830
'ShowKeywordDocumentation'
2931
]
32+
33+
def check_binary_version(python_binary):
34+
result = subprocess.check_output([python_binary,"-c", "import sys;print(sys.version_info.major)"])
35+
version = int(result.decode('utf-8').strip())
36+
if version < 3:
37+
error_message('RobotFrameworkAssistant\n' +
38+
'***********************************\n' +
39+
'Plugin fully support on python 3\n')

commands/scan.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
from platform import system
55
from os import path, makedirs
6+
from . import check_binary_version
67
from ..setting.setting import get_setting
78
from ..setting.setting import SettingObject
89

@@ -34,6 +35,7 @@ def run(self, edit):
3435
Also all imports, from found files, will be iterated and
3536
table is created also from imports.
3637
"""
38+
check_binary_version(get_setting(SettingObject.python_binary))
3739
log_file = get_setting(SettingObject.log_file)
3840
makedirs(path.dirname(log_file), exist_ok=True)
3941
file_ = open(log_file, 'a')

commands/scan_and_index.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from os import path, makedirs
66
from hashlib import md5
77
import json
8+
from . import check_binary_version
89
from ..setting.setting import get_setting
910
from ..setting.setting import SettingObject
1011
from ..setting.db_json_settings import DBJsonSetting
@@ -45,6 +46,7 @@ def add_builtin_vars(db_path):
4546
class ScanIndexCommand(sublime_plugin.TextCommand):
4647

4748
def run(self, edit):
49+
check_binary_version(get_setting(SettingObject.python_binary))
4850
log_file = get_setting(SettingObject.log_file)
4951
db_dir = get_setting(SettingObject.table_dir)
5052
makedirs(path.dirname(log_file), exist_ok=True)

commands/scan_open_tab.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
from platform import system
55
from os import path, makedirs
6+
from . import check_binary_version
67
from ..setting.setting import get_setting
78
from ..setting.setting import SettingObject
89
from .scan import scan_popen_arg_parser
@@ -16,6 +17,7 @@ def run(self, edit):
1617
Purpose of the command is scan and create the db table
1718
from the currently open tab.
1819
"""
20+
check_binary_version(get_setting(SettingObject.python_binary))
1921
log_file = get_setting(SettingObject.log_file)
2022
makedirs(path.dirname(log_file), exist_ok=True)
2123
open_tab = self.view.file_name()

setting/setting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SettingObject(object):
5151
scanner_runner = 'scanner_runner'
5252
index_runner = 'index_runner'
5353
log_file = 'log_file'
54-
python_binary = 'path_to_python3'
54+
python_binary = 'path_to_python'
5555
workspace = 'robot_framework_workspace'
5656
extension = 'robot_framework_extension'
5757
builtin_variables = 'robot_framework_builtin_variables'

0 commit comments

Comments
 (0)