Exemplo n.º 1
0
def execute(mayapath, maya, script, **kwargs):
    '''
        maya = '/usr/autodesk/maya2018/bin/mayapy'
        maya = '/venture/shows/batman/batman_0.0.3.mb'
        script = resource.getScriptPath() + '/find_assetids.py'
        data = read(mayapy, maya, script)
    '''
    mayapy = os.path.join(mayapath, 'bin/mayapy')
    popen = subprocess.Popen(
        [mayapy, '-s', script, maya, str(kwargs)],
        shell=False,
        stdout=subprocess.PIPE)

    popen_result = popen.stdout.readlines()
    communicate = popen.communicate()
    if not popen_result:
        return False, 'failed'
    spack_return = None
    identity_key = resource.getIdentityKey()
    for each in popen_result:
        if identity_key in each:
            spack_return = each.split(identity_key)[-1]
            continue
        print each.replace('\n', '')
    if not spack_return:
        return False, 'failed'
    result = ast.literal_eval(spack_return.strip())
    return result, 'success'
Exemplo n.º 2
0
 def create_bin_show_application(self,
                                 current_show,
                                 application,
                                 application_path,
                                 force=False):
     application_template = resource.getApplicationTemplatePath()
     if not os.path.isfile(application_template):
         print '#warnings: not found application template <%s>' % application_template
         return False
     bin_path = resource.getBinApplicationPath(current_show, application)
     valid = True
     if os.path.isfile(bin_path):
         if not force:
             print '#warnings: already found <%s>' % application
             return False
         try:
             os.chmod(bin_path, 0777)
             os.remove(bin_path)
             valid = True
         except Exception as error:
             valid = False
             print '#error: ', error
     if not valid:
         return False
     input_data = resource.getData(application_template)
     search = 'echo \'application.exe %s\'' % resource.getIdentityKey()
     if search not in input_data:
         print '\n', application_template
         print '#warnings: not found identity key word <%s>' % search
         return False
     replaced_data = input_data.replace(search, application_path)
     if not os.path.isdir(os.path.dirname(bin_path)):
         os.makedirs(os.path.dirname(bin_path))
     with open(bin_path, 'w') as file:
         data = file.write(replaced_data)
         os.chmod(bin_path, 0o777)
         print '#info: successfully registered studio pipe application <%s>' % application
         return True
     return False
Exemplo n.º 3
0
def returncode(values):
    if isinstance(values, str):
        values = [values]
    print resource.getIdentityKey(), values
    return values