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

Py3 support + changes for new RBFW and SeleniumLibrary by aaltat #231

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Robot.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions command_helper/get_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
idxn marked this conversation as resolved.
Show resolved Hide resolved

10 changes: 10 additions & 0 deletions commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
from .command_logging import LogCommands
from .index_open_tab import IndexOpenTabCommand
from .jump_to_keyword import JumpToKeyword
Expand All @@ -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',
Expand All @@ -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')
2 changes: 2 additions & 0 deletions commands/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions commands/scan_and_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions commands/scan_open_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion setting/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down