|
1 | 1 | # ST2/ST3 compat |
2 | 2 | from __future__ import print_function |
3 | 3 |
|
4 | | -import os |
5 | 4 | import re |
6 | 5 | import sys |
7 | 6 | import time |
8 | 7 | import uuid |
9 | | -import errno |
10 | 8 | import socket |
11 | | -import os.path |
12 | 9 | import textwrap |
13 | 10 | import threading |
14 | 11 | import traceback |
@@ -92,11 +89,9 @@ def run(self, edit): |
92 | 89 | print('No Maya-Recognized Language Found') |
93 | 90 | return |
94 | 91 |
|
95 | | - isPython = (lang=='python') |
96 | | - |
97 | 92 | # Apparently ST3 doesn't always sync up its latest |
98 | 93 | # plugin settings? |
99 | | - if _settings['host'] is None: |
| 94 | + if not _settings['host']: |
100 | 95 | sync_settings() |
101 | 96 |
|
102 | 97 | # Check the current selection size to determine |
@@ -183,7 +178,7 @@ def _send_to_maya(cmd, lang='python', wrap=True, quiet=False): |
183 | 178 | """ |
184 | 179 | Send stringified Python code to Maya, to be executed. |
185 | 180 | """ |
186 | | - if _settings['host'] is None: |
| 181 | + if not _settings['host']: |
187 | 182 | sync_settings() |
188 | 183 |
|
189 | 184 | host = _settings['host'] |
@@ -250,14 +245,14 @@ def sync_settings(): |
250 | 245 | def _sync_settings(): |
251 | 246 | so = settings_obj() |
252 | 247 |
|
253 | | - _settings['host'] = so.get('maya_hostname') |
254 | | - _settings['py_port'] = so.get('python_command_port') |
255 | | - _settings['mel_port'] = so.get('mel_command_port') |
256 | | - _settings['strip_comments'] = so.get('strip_sending_comments') |
257 | | - _settings['no_collisions'] = so.get('no_collisions') |
258 | | - _settings['maya_output'] = so.get('receive_maya_output') |
259 | | - _settings['undo'] = so.get('create_undo') |
260 | | - |
| 248 | + _settings['host'] = so.get('maya_hostname', _settings['host']) |
| 249 | + _settings['py_port'] = so.get('python_command_port', _settings['py_port']) |
| 250 | + _settings['mel_port'] = so.get('mel_command_port', _settings['mel_port'] ) |
| 251 | + _settings['strip_comments'] = so.get('strip_sending_comments', _settings['strip_comments']) |
| 252 | + _settings['no_collisions'] = so.get('no_collisions', _settings['no_collisions']) |
| 253 | + _settings['maya_output'] = so.get('receive_maya_output', _settings['maya_output']) |
| 254 | + _settings['undo'] = so.get('create_undo', _settings['undo'] ) |
| 255 | + |
261 | 256 | MayaReader._st2_remove_reader() |
262 | 257 |
|
263 | 258 | if _settings['maya_output'] is not None: |
@@ -287,9 +282,17 @@ def _sync_settings(): |
287 | 282 |
|
288 | 283 | if {ns}: |
289 | 284 | namespace['__file__'] = {fp!r} |
290 | | - {xtype}({cmd!r}, namespace, namespace) |
291 | 285 | else: |
292 | | - {xtype}({cmd!r}, __main__.__dict__, __main__.__dict__) |
| 286 | + namespace = __main__.__dict__ |
| 287 | +
|
| 288 | + if {xtype!r} == "exec": |
| 289 | + exec({cmd!r}, namespace, namespace) |
| 290 | +
|
| 291 | + else: |
| 292 | + with open({fp!r}) as _fp: |
| 293 | + _code = compile(_fp.read(), {fp!r}, 'exec') |
| 294 | + exec(_code, namespace, namespace) |
| 295 | + |
293 | 296 | except: |
294 | 297 | traceback.print_exc() |
295 | 298 | finally: |
|
0 commit comments