This commit is contained in:
annatisch 2017-05-22 14:24:50 -07:00
Родитель e7dde603ea
Коммит 998d464de5
3 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -182,7 +182,7 @@ class AzureBatchAssets(object):
for rule in maya.workspace(fileRuleList=True): for rule in maya.workspace(fileRuleList=True):
project_dir = maya.workspace(fileRuleEntry=rule) project_dir = maya.workspace(fileRuleEntry=rule)
remote_path = utils.get_remote_directory(maya.workspace(en=project_dir), os_flavor) remote_path = utils.get_remote_directory(maya.workspace(en=project_dir), os_flavor)
if os_flavor == 'Windows': if os_flavor == utils.OperatingSystem.windows:
full_remote_path = "X:\\\\" + remote_path full_remote_path = "X:\\\\" + remote_path
else: else:
full_remote_path = "/X/" + remote_path full_remote_path = "/X/" + remote_path
@ -211,7 +211,7 @@ class AzureBatchAssets(object):
handle.write("loadPlugin \"{}\";\n".format(plugin)) handle.write("loadPlugin \"{}\";\n".format(plugin))
handle.write("dirmap -en true;\n") handle.write("dirmap -en true;\n")
for local, remote in pathmap.items(): for local, remote in pathmap.items():
if os_flavor == 'Windows': if os_flavor == utils.OperatingSystem.windows:
full_remote_path = "X:\\\\" + remote(os_flavor) full_remote_path = "X:\\\\" + remote(os_flavor)
else: else:
full_remote_path = "/X/" + remote(os_flavor) full_remote_path = "/X/" + remote(os_flavor)

Просмотреть файл

@ -32,7 +32,7 @@ import json
from api import MayaAPI as maya from api import MayaAPI as maya
from api import MayaCallbacks as callback from api import MayaCallbacks as callback
import utils
from ui_environment import EnvironmentUI from ui_environment import EnvironmentUI
@ -154,16 +154,16 @@ class AzureBatchEnvironment(object):
windows_offers = [value['offer'] for value in MAYA_IMAGES.values() if 'windows' in value['node_sku_id']] windows_offers = [value['offer'] for value in MAYA_IMAGES.values() if 'windows' in value['node_sku_id']]
linux_offers = [value['offer'] for value in MAYA_IMAGES.values() if value['offer'] not in windows_offers] linux_offers = [value['offer'] for value in MAYA_IMAGES.values() if value['offer'] not in windows_offers]
if pool_image.offer in windows_offers: if pool_image.offer in windows_offers:
return 'Windows' return utils.OperatingSystem.windows
elif pool_image.offer in linux_offers: elif pool_image.offer in linux_offers:
return 'Linux' return utils.OperatingSystem.linux
else: else:
raise ValueError('Selected pool is not using a valid Maya image.') raise ValueError('Selected pool is not using a valid Maya image.')
if 'Windows' in self.ui.get_image(): if utils.OperatingSystem.windows.value in self.ui.get_image():
return 'Windows' return utils.OperatingSystem.windows
else: else:
return 'Linux' return utils.OperatingSystem.linux
def get_environment_settings(self): def get_environment_settings(self):
env_vars = self.ui.get_env_vars() env_vars = self.ui.get_env_vars()

Просмотреть файл

@ -26,12 +26,14 @@
# #
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
from api import MayaAPI as maya from enum import Enum
import os import os
import logging import logging
import platform import platform
import pathlib import pathlib
from api import MayaAPI as maya
from batch_extensions import _file_utils as file_utils from batch_extensions import _file_utils as file_utils
from exception import CancellationException, FileUploadException from exception import CancellationException, FileUploadException
@ -67,7 +69,7 @@ def get_remote_file_path(assetpath):
""" """
def generate_path(os_flavor, fullpath=assetpath): def generate_path(os_flavor, fullpath=assetpath):
local_sep = os.sep local_sep = os.sep
remote_sep = '\\' if os_flavor == 'Windows' else '/' remote_sep = '\\' if os_flavor == OperatingSystem.windows else '/'
path = shorten_path(*os.path.split(fullpath)) path = shorten_path(*os.path.split(fullpath))
if ':' in path: if ':' in path:
drive_letter, path = path.split(':', 1) drive_letter, path = path.split(':', 1)
@ -82,7 +84,7 @@ def get_remote_directory(dir_path, os_flavor):
path according to the remote OS. path according to the remote OS.
""" """
local_sep = os.sep local_sep = os.sep
remote_sep = '\\' if os_flavor == 'Windows' else '/' remote_sep = '\\' if os_flavor == OperatingSystem.windows else '/'
if ':' in dir_path: if ':' in dir_path:
drive_letter, dir_path = dir_path.split(':', 1) drive_letter, dir_path = dir_path.split(':', 1)
dir_path = drive_letter + local_sep + dir_path[1:] dir_path = drive_letter + local_sep + dir_path[1:]
@ -95,7 +97,7 @@ def format_scene_path(scene_file, os_flavor):
be on the render node. be on the render node.
""" """
scene_path = get_remote_file_path(scene_file)(os_flavor) scene_path = get_remote_file_path(scene_file)(os_flavor)
if os_flavor == 'Windows': if os_flavor == OperatingSystem.windows:
return "X:\\\\" + scene_path + '\\\\' + os.path.basename(scene_file) return "X:\\\\" + scene_path + '\\\\' + os.path.basename(scene_file)
else: else:
return "/X/" + scene_path + '/' + os.path.basename(scene_file) return "/X/" + scene_path + '/' + os.path.basename(scene_file)
@ -119,6 +121,12 @@ def get_os():
return platform.system() return platform.system()
class OperatingSystem(Enum):
windows = 'Windows'
linux = 'Linux'
darwin = 'Darwin'
class Row(object): class Row(object):
"""UI row class.""" """UI row class."""
@ -446,12 +454,12 @@ class JobWatcher(object):
self.job_watcher = os.path.join( self.job_watcher = os.path.join(
os.path.dirname(__file__), "tools", "job_watcher.py") os.path.dirname(__file__), "tools", "job_watcher.py")
platform = get_os() platform = get_os()
if platform == "Windows": if platform == OperatingSystem.windows:
self.proc_cmd = 'system("WMIC PROCESS where (Name=\'mayapy.exe\') get Commandline")' self.proc_cmd = 'system("WMIC PROCESS where (Name=\'mayapy.exe\') get Commandline")'
self.start_cmd = 'system("start mayapy {0}")' self.start_cmd = 'system("start mayapy {0}")'
self.quotes = '\\"' self.quotes = '\\"'
self.splitter = 'mayapy' self.splitter = 'mayapy'
elif platform == "Darwin": elif platform == OperatingSystem.darwin:
self.proc_cmd = 'system("ps -ef")' self.proc_cmd = 'system("ps -ef")'
self.start_cmd = 'system("osascript -e \'tell application \\"Terminal\\" to do script \\"python {0}\\"\'")' self.start_cmd = 'system("osascript -e \'tell application \\"Terminal\\" to do script \\"python {0}\\"\'")'
self.quotes = '\\\\\\"' self.quotes = '\\\\\\"'