Skip to content

Commit

Permalink
Add posibility to change settings path with env ZLM_SETTINGS_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasOuellet committed Oct 21, 2021
1 parent 4eb351e commit 082ae54
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dist/ZlmData/*
!dist/ZlmData/zlmOps.txt
!dist/ZlmData/zLayerUpdate.txt
!dist/ZlmData/app/*
*.zip
src/zscripts
**/__pycache__
**.zsc
Expand Down
6 changes: 5 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
if __name__ == '__main__':
root = Path('.').resolve()

os.chdir(root.joinpath('src').resolve())
src = root.joinpath('src').resolve()
os.chdir(src)

# add dll to path
print("add dll to path")
Expand Down Expand Up @@ -114,3 +115,6 @@
for f in zlmdata.joinpath("app").glob("**\\*.pyc"):
print(f"Delete {f}")
os.remove(f)

print("copying zlm_settings to Dist/ZlmData/app/zlm_core")
shutil.copy2(src.joinpath("zlm_settings.py"), zlmdata.joinpath('app', 'zlm_core', 'zlm_settings.py'))
4 changes: 2 additions & 2 deletions dist/ZlmData/app/maya/zlm/zlm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from maya import cmds

from zlm_core import ZlmSettings, communication
from zlm_core import ZlmSettings, zlm_com
from zlm.zlm_utils import load_obj_plugin, doWithNoUndo


Expand Down Expand Up @@ -45,7 +45,7 @@ def _export(objs, base=False):
if base:
args[0] = 'i_base'
args.pop(2)
communication.send_command(*args)
zlm_com.send_command(*args)

except Exception as e:
print "Error when exporting mesh: {}. {}".format(obj, str(e))
Expand Down
2 changes: 1 addition & 1 deletion dist/ZlmData/app/zlm_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

from zlm_core.zlm_settings import ZlmSettings
from zlm_core import zlm_com as communication
from zlm_core import zlm_com
3 changes: 1 addition & 2 deletions dist/ZlmData/app/zlm_core/zlm_com.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import tempfile
import os
from multiprocessing.connection import Listener, Client
from multiprocessing.connection import Client

from zlm_core import ZlmSettings

__all__ = [
'send_command'
Expand Down
11 changes: 9 additions & 2 deletions dist/ZlmData/app/zlm_core/zlm_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import json
import sys


class ZlmSettings(object):
Expand All @@ -10,6 +9,8 @@ class ZlmSettings(object):
def __init__(self, auto_load=True):
self.working_folder = os.path.join(self.getsettingfolder(), 'files')

self.check_for_updates = True

self.send_after_export = False
self.current_app = 'Maya'
self.app_settings = {
Expand All @@ -19,14 +20,20 @@ def __init__(self, auto_load=True):
}
}

self.additionnal_preset_dir = []

self.bigData = {}

if auto_load:
self.load()

@staticmethod
def getsettingfolder():
folder = os.path.expanduser(os.path.join('~', 'zLayerManager'))
try:
folder = os.environ["ZLM_SETTINGS_PATH"]
except:
folder = os.path.expanduser(os.path.join('~', 'zLayerManager'))

if not os.path.exists(folder):
os.makedirs(folder)

Expand Down
6 changes: 5 additions & 1 deletion src/zlm_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def __init__(self, auto_load=True):

@staticmethod
def getsettingfolder():
folder = os.path.expanduser(os.path.join('~', 'zLayerManager'))
try:
folder = os.environ["ZLM_SETTINGS_PATH"]
except:
folder = os.path.expanduser(os.path.join('~', 'zLayerManager'))

if not os.path.exists(folder):
os.makedirs(folder)

Expand Down

0 comments on commit 082ae54

Please sign in to comment.