operating system enum
This commit is contained in:
Родитель
e7dde603ea
Коммит
998d464de5
|
@ -182,7 +182,7 @@ class AzureBatchAssets(object):
|
|||
for rule in maya.workspace(fileRuleList=True):
|
||||
project_dir = maya.workspace(fileRuleEntry=rule)
|
||||
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
|
||||
else:
|
||||
full_remote_path = "/X/" + remote_path
|
||||
|
@ -211,7 +211,7 @@ class AzureBatchAssets(object):
|
|||
handle.write("loadPlugin \"{}\";\n".format(plugin))
|
||||
handle.write("dirmap -en true;\n")
|
||||
for local, remote in pathmap.items():
|
||||
if os_flavor == 'Windows':
|
||||
if os_flavor == utils.OperatingSystem.windows:
|
||||
full_remote_path = "X:\\\\" + remote(os_flavor)
|
||||
else:
|
||||
full_remote_path = "/X/" + remote(os_flavor)
|
||||
|
|
|
@ -32,7 +32,7 @@ import json
|
|||
|
||||
from api import MayaAPI as maya
|
||||
from api import MayaCallbacks as callback
|
||||
|
||||
import utils
|
||||
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']]
|
||||
linux_offers = [value['offer'] for value in MAYA_IMAGES.values() if value['offer'] not in windows_offers]
|
||||
if pool_image.offer in windows_offers:
|
||||
return 'Windows'
|
||||
return utils.OperatingSystem.windows
|
||||
elif pool_image.offer in linux_offers:
|
||||
return 'Linux'
|
||||
return utils.OperatingSystem.linux
|
||||
else:
|
||||
raise ValueError('Selected pool is not using a valid Maya image.')
|
||||
|
||||
if 'Windows' in self.ui.get_image():
|
||||
return 'Windows'
|
||||
if utils.OperatingSystem.windows.value in self.ui.get_image():
|
||||
return utils.OperatingSystem.windows
|
||||
else:
|
||||
return 'Linux'
|
||||
return utils.OperatingSystem.linux
|
||||
|
||||
def get_environment_settings(self):
|
||||
env_vars = self.ui.get_env_vars()
|
||||
|
|
|
@ -26,12 +26,14 @@
|
|||
#
|
||||
#--------------------------------------------------------------------------
|
||||
|
||||
from api import MayaAPI as maya
|
||||
from enum import Enum
|
||||
import os
|
||||
import logging
|
||||
import platform
|
||||
import pathlib
|
||||
|
||||
from api import MayaAPI as maya
|
||||
|
||||
from batch_extensions import _file_utils as file_utils
|
||||
from exception import CancellationException, FileUploadException
|
||||
|
||||
|
@ -67,7 +69,7 @@ def get_remote_file_path(assetpath):
|
|||
"""
|
||||
def generate_path(os_flavor, fullpath=assetpath):
|
||||
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))
|
||||
if ':' in path:
|
||||
drive_letter, path = path.split(':', 1)
|
||||
|
@ -82,7 +84,7 @@ def get_remote_directory(dir_path, os_flavor):
|
|||
path according to the remote OS.
|
||||
"""
|
||||
local_sep = os.sep
|
||||
remote_sep = '\\' if os_flavor == 'Windows' else '/'
|
||||
remote_sep = '\\' if os_flavor == OperatingSystem.windows else '/'
|
||||
if ':' in dir_path:
|
||||
drive_letter, dir_path = dir_path.split(':', 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.
|
||||
"""
|
||||
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)
|
||||
else:
|
||||
return "/X/" + scene_path + '/' + os.path.basename(scene_file)
|
||||
|
@ -119,6 +121,12 @@ def get_os():
|
|||
return platform.system()
|
||||
|
||||
|
||||
class OperatingSystem(Enum):
|
||||
windows = 'Windows'
|
||||
linux = 'Linux'
|
||||
darwin = 'Darwin'
|
||||
|
||||
|
||||
class Row(object):
|
||||
"""UI row class."""
|
||||
|
||||
|
@ -446,12 +454,12 @@ class JobWatcher(object):
|
|||
self.job_watcher = os.path.join(
|
||||
os.path.dirname(__file__), "tools", "job_watcher.py")
|
||||
platform = get_os()
|
||||
if platform == "Windows":
|
||||
if platform == OperatingSystem.windows:
|
||||
self.proc_cmd = 'system("WMIC PROCESS where (Name=\'mayapy.exe\') get Commandline")'
|
||||
self.start_cmd = 'system("start mayapy {0}")'
|
||||
self.quotes = '\\"'
|
||||
self.splitter = 'mayapy'
|
||||
elif platform == "Darwin":
|
||||
elif platform == OperatingSystem.darwin:
|
||||
self.proc_cmd = 'system("ps -ef")'
|
||||
self.start_cmd = 'system("osascript -e \'tell application \\"Terminal\\" to do script \\"python {0}\\"\'")'
|
||||
self.quotes = '\\\\\\"'
|
||||
|
|
Загрузка…
Ссылка в новой задаче