Skip to content

Commit

Permalink
Merge branch '36_py39_support'
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Sep 23, 2021
2 parents 7526198 + 5c93e48 commit 9379791
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.DS_Store
*.sublime-project
*.sublime-workspace
.idea/
*.iml
37 changes: 20 additions & 17 deletions MayaSublime.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# ST2/ST3 compat
from __future__ import print_function

import os
import re
import sys
import time
import uuid
import errno
import socket
import os.path
import textwrap
import threading
import traceback
Expand Down Expand Up @@ -92,11 +89,9 @@ def run(self, edit):
print('No Maya-Recognized Language Found')
return

isPython = (lang=='python')

# Apparently ST3 doesn't always sync up its latest
# plugin settings?
if _settings['host'] is None:
if not _settings['host']:
sync_settings()

# Check the current selection size to determine
Expand Down Expand Up @@ -183,7 +178,7 @@ def _send_to_maya(cmd, lang='python', wrap=True, quiet=False):
"""
Send stringified Python code to Maya, to be executed.
"""
if _settings['host'] is None:
if not _settings['host']:
sync_settings()

host = _settings['host']
Expand Down Expand Up @@ -250,14 +245,14 @@ def sync_settings():
def _sync_settings():
so = settings_obj()

_settings['host'] = so.get('maya_hostname')
_settings['py_port'] = so.get('python_command_port')
_settings['mel_port'] = so.get('mel_command_port')
_settings['strip_comments'] = so.get('strip_sending_comments')
_settings['no_collisions'] = so.get('no_collisions')
_settings['maya_output'] = so.get('receive_maya_output')
_settings['undo'] = so.get('create_undo')

_settings['host'] = so.get('maya_hostname', _settings['host'])
_settings['py_port'] = so.get('python_command_port', _settings['py_port'])
_settings['mel_port'] = so.get('mel_command_port', _settings['mel_port'] )
_settings['strip_comments'] = so.get('strip_sending_comments', _settings['strip_comments'])
_settings['no_collisions'] = so.get('no_collisions', _settings['no_collisions'])
_settings['maya_output'] = so.get('receive_maya_output', _settings['maya_output'])
_settings['undo'] = so.get('create_undo', _settings['undo'] )
MayaReader._st2_remove_reader()

if _settings['maya_output'] is not None:
Expand Down Expand Up @@ -287,9 +282,17 @@ def _sync_settings():
if {ns}:
namespace['__file__'] = {fp!r}
{xtype}({cmd!r}, namespace, namespace)
else:
{xtype}({cmd!r}, __main__.__dict__, __main__.__dict__)
namespace = __main__.__dict__
if {xtype!r} == "exec":
exec({cmd!r}, namespace, namespace)
else:
with open({fp!r}) as _fp:
_code = compile(_fp.read(), {fp!r}, 'exec')
exec(_code, namespace, namespace)
except:
traceback.print_exc()
finally:
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"3.0.1": "messages/3.0.1.md",
"3.0.2": "messages/3.0.2.md",
"3.0.3": "messages/3.0.3.md",
"3.0.4": "messages/3.0.4.md"
"3.0.4": "messages/3.0.4.md",
"3.1.0": "messages/3.1.0.md"
}
4 changes: 4 additions & 0 deletions messages/3.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MayaSublime 3.1.0 change log:

- [#36]: Update to support python >= 3.7 (refactor lack of `execfile`)
- Improve settings sync and handling of default values

0 comments on commit 9379791

Please sign in to comment.