Skip to content

Commit 635166c

Browse files
committed
Merge branch 'develop' of 192.168.1.19:vinman/xArm-Python-SDK into develop
2 parents d1e5b8b + fa16a17 commit 635166c

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

xarm/tools/blockly/_blockly_handler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __init__(self, xml_path):
2424
self._main_run_code_list = []
2525
self._is_main_run_code = True
2626
self._is_exec = False
27+
self._is_ide = False
2728

2829
self._listen_tgpio_digital = False
2930
self._listen_tgpio_analog = False
@@ -363,7 +364,7 @@ def _handle_app_studio_traj(self, block, indent=0, arg_map=None):
363364
def _handle_tool_message(self, block, indent=0, arg_map=None):
364365
fields = self._get_nodes('field', block)
365366
color = json.dumps(fields[0].text, ensure_ascii=False) if len(fields) > 1 else 'white'
366-
msg = json.dumps(fields[1].text if fields[-1].text is not None else '', ensure_ascii=False)
367+
msg = json.dumps(fields[2].text if fields[-1].text is not None else '', ensure_ascii=False)
367368
if self._highlight_callback is not None:
368369
self._append_main_code('print({}, color={})'.format(msg, color), indent + 2)
369370
else:
@@ -1116,7 +1117,7 @@ def _handle_python_code(self, block, indent=0, arg_map=None, **kwargs):
11161117
prev_is_empty = True
11171118
else:
11181119
prev_is_empty = False
1119-
if self._is_exec and code.strip():
1120+
if (self._is_exec or (not self._is_exec and not self._is_ide)) and code.strip():
11201121
code_indent = re.match('(\s*).*', code).group(1)
11211122
self._append_main_code(code_indent + 'if not self.is_alive:', indent + 2)
11221123
self._append_main_code(code_indent + 'return', indent + 3)

xarm/tools/blockly/_blockly_tool.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def codes(self):
2323
def to_python(self, path=None, arm=None, init=True, wait_seconds=1, mode=0, state=0, error_exit=True, stop_exit=True, **kwargs):
2424
if not self._is_converted:
2525
self._is_exec = kwargs.get('is_exec', False)
26+
self._is_ide = kwargs.get('is_ide', False)
2627
# highlight_callback: only use pack to run blockly in studio
2728
self._highlight_callback = kwargs.get('highlight_callback', None)
2829
# axis_type: Obtain the type of mechanical arm axis for end leveling use
@@ -451,9 +452,9 @@ def __define_check_code_func(self):
451452
self._append_main_init_code(' return self.is_alive\n')
452453

453454
def _init_main_codes(self, arm=None):
454-
# exec can not run main function, if run in exec(), the parameter is_exec must set True
455+
# exec can not run main function, if run in exec(), the parameter is_ide must set False
455456
self._append_main_code('\n', indent=-1)
456-
if not self._is_exec:
457+
if self._is_ide:
457458
self._append_main_code('if __name__ == \'__main__\':', indent=-1)
458459
indent = 0
459460
else:

xarm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.14.2'
1+
__version__ = '1.14.3'

xarm/x3/xarm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import os
1010
import math
11+
import sys
1112
import time
1213
import uuid
1314
import warnings
@@ -1454,13 +1455,13 @@ def run_blockly_app(self, path, **kwargs):
14541455
try:
14551456
if not os.path.exists(path):
14561457
dir_name = 'lite6' if self.axis == 6 and self.device_type == 9 else '850' if self.axis == 6 and self.device_type == 12 else 'xarm7T' if self.axis == 7 and self.device_type == 13 else 'xarm{}'.format(self.axis)
1457-
path = os.path.join(os.path.expanduser('~'), '.UFACTORY', 'projects', 'test', dir_name, 'app', 'myapp', path) # home/uf
1458+
path = os.path.join('/home/uf' if sys.platform.startswith('linux') else os.path.expanduser('~'), '.UFACTORY', 'projects', 'test', dir_name, 'app', 'myapp', path)
14581459
if os.path.isdir(path):
14591460
path = os.path.join(path, 'app.xml')
14601461
if not os.path.exists(path):
14611462
raise FileNotFoundError('{} is not found'.format(path))
14621463
blockly_tool = BlocklyTool(path)
1463-
succeed = blockly_tool.to_python(arm=self._api_instance, is_exec=True, **kwargs)
1464+
succeed = blockly_tool.to_python(arm=self._api_instance, **kwargs)
14641465
if succeed:
14651466
times = kwargs.get('times', 1)
14661467
highlight_callback = kwargs.get('highlight_callback', None)

0 commit comments

Comments
 (0)