This repository was archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathscan.py
More file actions
65 lines (56 loc) · 2.32 KB
/
Copy pathscan.py
File metadata and controls
65 lines (56 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import subprocess
from platform import system
from os import path, makedirs
import sublime_plugin
import sublime
from RobotFrameworkAssistant.setting import get_setting, SettingObject
def scan_popen_arg_parser(mode):
arg_list = []
arg_list.append(get_setting(SettingObject.python_binary))
arg_list.append(get_setting(SettingObject.scanner_runner))
arg_list.append(mode)
arg_list.append('--db_path')
arg_list.append(get_setting(SettingObject.table_dir))
arg_list.append('--extension')
arg_list.append(get_setting(SettingObject.extension))
arg_list.append('--path_to_lib_in_xml')
arg_list.append(get_setting(SettingObject.lib_in_xml))
arg_list.append('--module_search_path')
for module in get_setting(SettingObject.module_search_path):
arg_list.append(module)
return arg_list
class ScanCommand(sublime_plugin.TextCommand):
def run(self, edit):
"""Command to scan RF files and create database tables
Purpose of the command is iterate over the files found from
the robot_framework_workspace and create database tables.
Also all imports, from found files, will be iterated and
table is created also from imports.
"""
log_file = get_setting(SettingObject.log_file)
makedirs(path.dirname(log_file), exist_ok=True)
file_ = open(log_file, 'a')
sublime.set_timeout_async(self.run_scan(file_), 0)
file_.close()
def run_scan(self, log_file):
startupinfo = None
if system() == 'Windows':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
p_args = scan_popen_arg_parser('all')
p_args.append('--workspace')
p_args.append(get_setting(SettingObject.workspace))
print(p_args)
p = subprocess.Popen(
p_args,
stderr=subprocess.STDOUT,
stdout=log_file,
startupinfo=startupinfo
)
rc = p.wait()
if rc != 0:
print('See log file from database directory for details')
raise ValueError('Error in scanning result code: {0}'.format(rc))
message = 'Scaning done with rc: {0}'.format(rc)
sublime.status_message(message)
print(message)