diff --git a/Robot.sublime-settings b/Robot.sublime-settings index 3c3a72a..afd6d94 100644 --- a/Robot.sublime-settings +++ b/Robot.sublime-settings @@ -74,7 +74,7 @@ and in Windows this could be like: C:\\Python27\\python.exe */ - "path_to_python3": "/usr/bin/python", + "path_to_python": "/usr/bin/python", /* Module search path defines a list of paths where the diff --git a/command_helper/get_keyword.py b/command_helper/get_keyword.py index 330eecb..c18bb15 100644 --- a/command_helper/get_keyword.py +++ b/command_helper/get_keyword.py @@ -161,8 +161,5 @@ def rf_data(self, file_path): return None def is_string(self, str_): - if version_info.major > 2: - status = isinstance(str_, str) - else: - raise RuntimeError('Plugin only works with python 3') - return status + return isinstance(str_, str) + diff --git a/commands/__init__.py b/commands/__init__.py index bfe5bd9..18bbf43 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -1,3 +1,4 @@ +import subprocess from .command_logging import LogCommands from .index_open_tab import IndexOpenTabCommand from .jump_to_keyword import JumpToKeyword @@ -11,6 +12,7 @@ from .setting_import_helper import InsertImport from .setting_import_helper import SettingImporter from .show_documentation import ShowKeywordDocumentation +from sublime import error_message __all__ = [ 'IndexOpenTabCommand', @@ -27,3 +29,11 @@ 'SettingImporter', 'ShowKeywordDocumentation' ] + +def check_binary_version(python_binary): + result = subprocess.check_output([python_binary,"-c", "import sys;print(sys.version_info.major)"]) + version = int(result.decode('utf-8').strip()) + if version < 3: + error_message('RobotFrameworkAssistant\n' + + '***********************************\n' + + 'Plugin fully support on python 3\n') \ No newline at end of file diff --git a/commands/scan.py b/commands/scan.py index 516c076..407af93 100644 --- a/commands/scan.py +++ b/commands/scan.py @@ -3,6 +3,7 @@ import subprocess from platform import system from os import path, makedirs +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject @@ -34,6 +35,7 @@ def run(self, edit): Also all imports, from found files, will be iterated and table is created also from imports. """ + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) file_ = open(log_file, 'a') diff --git a/commands/scan_and_index.py b/commands/scan_and_index.py index a8200cf..d78c256 100644 --- a/commands/scan_and_index.py +++ b/commands/scan_and_index.py @@ -5,6 +5,7 @@ from os import path, makedirs from hashlib import md5 import json +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from ..setting.db_json_settings import DBJsonSetting @@ -45,6 +46,7 @@ def add_builtin_vars(db_path): class ScanIndexCommand(sublime_plugin.TextCommand): def run(self, edit): + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) db_dir = get_setting(SettingObject.table_dir) makedirs(path.dirname(log_file), exist_ok=True) diff --git a/commands/scan_open_tab.py b/commands/scan_open_tab.py index 6ed5866..8bde1f1 100644 --- a/commands/scan_open_tab.py +++ b/commands/scan_open_tab.py @@ -3,6 +3,7 @@ import subprocess from platform import system from os import path, makedirs +from . import check_binary_version from ..setting.setting import get_setting from ..setting.setting import SettingObject from .scan import scan_popen_arg_parser @@ -16,6 +17,7 @@ def run(self, edit): Purpose of the command is scan and create the db table from the currently open tab. """ + check_binary_version(get_setting(SettingObject.python_binary)) log_file = get_setting(SettingObject.log_file) makedirs(path.dirname(log_file), exist_ok=True) open_tab = self.view.file_name() diff --git a/setting/setting.py b/setting/setting.py index 78cface..cb53397 100644 --- a/setting/setting.py +++ b/setting/setting.py @@ -51,7 +51,7 @@ class SettingObject(object): scanner_runner = 'scanner_runner' index_runner = 'index_runner' log_file = 'log_file' - python_binary = 'path_to_python3' + python_binary = 'path_to_python' workspace = 'robot_framework_workspace' extension = 'robot_framework_extension' builtin_variables = 'robot_framework_builtin_variables'