예제 #1
0
def main(args):
    usage = "USAGE: checkin.py <search_type> <code> [context] <path>\n"
    usage += "example: python checkin.py beat Sc01.Bt01 .\\test\\image.png"

    context = "publish"

    # TODO: lots of assumptions here
    if len(args) == 2:
        # assume code and file path are equivalent
        code = args[1]
        file_path = args[1]
    elif len(args) == 3:
        code = args[1]
        file_path = args[2]
    elif len(args) == 4:
        code = args[1]
        context = args[2]
        file_path = args[3]
    else:
        print usage
        return

    search_type = args[0]

    server = TacticServerStub()

    # do the actual work
    server.start("Checked in file [%s] to [%s] - [%s]" %
                 (file_path, search_type, code))
    try:
        # query all of the search_types to simplify argument
        if search_type.find("/") == -1:
            columns = ["search_type"]
            results = server.query("sthpw/search_object", columns=columns)
            for result in results:
                test = result.get("search_type")
                if test.endswith("/%s" % search_type):
                    search_type = test
                    break
            else:
                raise Exception("Search type [%s] not found" % search_type)

        search_key = server.build_search_key(search_type, code)

        # upload the file
        server.upload_file(file_path)

        # checkin the uploaded file
        result = server.simple_checkin(search_key, context, file_path)
    except Exception as e:
        server.abort()
        print "ERROR: ", e.__str__()
    else:
        server.finish()
예제 #2
0
def main(args):
    usage = "USAGE: checkin.py <search_type> <code> [context] <path>\n"
    usage += "example: python checkin.py beat Sc01.Bt01 .\\test\\image.png"

    context = "publish"

    # TODO: lots of assumptions here
    if len(args) == 2:
        # assume code and file path are equivalent
        code = args[1]
        file_path = args[1]
    elif len(args) == 3:
        code = args[1]
        file_path = args[2]
    elif len(args) == 4:
        code = args[1]
        context = args[2]
        file_path = args[3]
    else:
        print usage
        return

    search_type = args[0]

    server = TacticServerStub()

    # do the actual work
    server.start("Checked in file [%s] to [%s] - [%s]" % (file_path, search_type, code) )
    try:
        # query all of the search_types to simplify argument
        if search_type.find("/") == -1:
            columns = ["search_type"]
            results = server.query("sthpw/search_object", columns=columns)
            for result in results:
                test = result.get("search_type")
                if test.endswith("/%s" % search_type):
                    search_type = test
                    break
            else:
                raise Exception("Search type [%s] not found" % search_type)

        search_key = server.build_search_key(search_type, code)

        # upload the file
        server.upload_file(file_path)

        # checkin the uploaded file
        result = server.simple_checkin(search_key, context, file_path)
    except Exception, e:
        server.abort()
        print "ERROR: ", e.__str__()
예제 #3
0
def main(args, login=None):
    # USAGE: checkin_shot.py <shot_code> <context> <path>
    shot_code = args[0]
    context = args[1]
    file_path = args[2]

    server = TacticServerStub(login)
    search_key = server.build_search_key(SEARCH_TYPE, shot_code)

    # do the actual work
    server.start("Checked in file [%s]" % file_path)
    try:
        # upload the file
        #server.upload_file(file_path)

        # checkin the uploaded file
        result = server.simple_checkin(search_key, context, file_path, mode='upload')
    except:
        server.abort()
        raise
    else:
        server.finish()
예제 #4
0
def main(args, login=None):
    # USAGE: checkin_shot.py <shot_code> <context> <path>
    shot_code = args[0]
    context = args[1]
    file_path = args[2]

    server = TacticServerStub(login)
    search_key = server.build_search_key(SEARCH_TYPE, shot_code)

    # do the actual work
    server.start("Checked in file [%s]" % file_path)
    try:
        # upload the file
        # server.upload_file(file_path)

        # checkin the uploaded file
        result = server.simple_checkin(search_key, context, file_path, mode="upload")
    except:
        server.abort()
        raise
    else:
        server.finish()
예제 #5
0
    def _test_create_submission(self):

        server = TacticServerStub()
        server.set_project("sample3d")

        # choose some arbitrary bin
        bin_id = 4
        filters = []

        # asset
        parent_type = "prod/asset"
        parent_code = "chr001"
        parent_key = server.build_search_key(parent_type, parent_code)
        parent = server.get_by_search_key(parent_key)
        parent_id = parent.get('id')

        # create a submission
        data = {
            'description': 'A test submission',
            'artist': 'joe',
            'context': 'model'
        }
        submission = server.insert("prod/submission",
                                   data,
                                   parent_key=parent_key)
        submission_key = submission.get('__search_key__')
        submission_id = submission.get('id')

        file_path = './miso_ramen.jpg'
        context = "publish"
        snapshot = server.simple_checkin(submission_key,
                                         context,
                                         file_path,
                                         mode="upload")

        # no connect to the bin with a connector
        data = {"bin_id": bin_id, 'submission_id': submission_id}
        server.insert("prod/submission_in_bin", data)
예제 #6
0
    def _test_create_submission(self):

        server = TacticServerStub()
        server.set_project("sample3d")

        # choose some arbitrary bin
        bin_id = 4
        filters = []


        # asset
        parent_type = "prod/asset"
        parent_code = "chr001"
        parent_key = server.build_search_key(parent_type, parent_code)
        parent = server.get_by_search_key(parent_key)
        parent_id = parent.get('id')

        # create a submission
        data = {
            'description': 'A test submission',
            'artist': 'joe',
            'context': 'model'
        }
        submission = server.insert("prod/submission", data, parent_key=parent_key)
        submission_key = submission.get('__search_key__')
        submission_id = submission.get('id')

        file_path = './miso_ramen.jpg'
        context = "publish"
        snapshot = server.simple_checkin(submission_key, context, file_path, mode="upload")

        # no connect to the bin with a connector
        data = {
            "bin_id": bin_id,
            'submission_id': submission_id
        }
        server.insert("prod/submission_in_bin", data)
예제 #7
0
def saveVrayVFB():
    username = os.environ.get("USERNAME")
    from tactic_client_lib import TacticServerStub
    server = TacticServerStub()
    #server.set_server("192.168.201.10")
    #server.set_project("simpleslot")
    ticket_files = os.listdir("c:/sthpw/etc/")
    ticket_file = "c:/sthpw/etc/" + username + ".tacticrc"

    if len(ticket_files) == 0:
        file_object = open(ticket_file, "w")
        ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "project=simpleslot"
        file_object.write(ticket_content)
        file_object.close()

    else:
        file_object = open(ticket_file)
        ticket_content = file_object.readlines()
        file_object.close()
        ticket = ticket_content[2].replace("ticket=", "").replace("\n", "")
        server.ticket = ticket
        server.set_server("192.168.201.10")
        server.set_project("simpleslot")

    rvname = jc.getNextFileName(1)

    rv_path = rvname[0]
    rv_filename = rvname[2]
    # base_scenename = rvname[1].

    project_name = rvname[3][0]
    item_name = rvname[3][1]
    process = rvname[3][2]
    # author = rvname[3][3]
    # reviewVersion = rvname[3][4]
    project_type = rvname[3][5]
    item_type = rvname[3][6]

    if project_type == "casino":
        stype = "3d"
    elif project_type == "assets":
        stype = "assets"
    elif project_type == "shot":
        stype = "shot"

    tactic_base_path = "//Art-1405260002/d/assets/simpleslot/"

    src_filename = rv_path + rv_filename
    dst_filename = tactic_base_path + project_name + "/" + project_type + "/" + process + "/" + rv_filename

    if os.path.isdir(tactic_base_path + project_name + "/" + project_type +
                     "/" + process + "/") is False:
        os.makedirs(tactic_base_path + project_name + "/" + project_type +
                    "/" + process + "/")

    cmd = "vfbControl #saveImage \"" + src_filename + ".exr\""
    MaxPlus.Core.EvalMAXScript(cmd)

    imageMagickCMD = "//Art-1405260002/d/assets/scripts/ImageMagick-6.9.0-6/convert.exe -quality 100 -colorspace RGB \"%s\" -colorspace sRGB \"%s\"" % (
        src_filename + ".exr", src_filename + ".jpg")
    subprocess.call(imageMagickCMD)

    # deleteEXRCMD = "del \"" + src_filename + ".exr\""
    # deleteEXRCMD = deleteEXRCMD.replace("/","\\")
    # subprocess.call(deleteEXRCMD)
    os.remove(src_filename + ".exr")

    shutil.copy2((src_filename + ".jpg"), (dst_filename + ".jpg"))

    expr = "@SOBJECT(simpleslot/game['name','" + project_name + "'].simpleslot/" + stype + "['name','" + item_name + "'].sthpw/task['process','" + process + "'])"
    task = server.eval(expr)

    sk = task[0].get("__search_key__")

    final_filename = "/mnt/hgfs/assets/simpleslot/" + project_name + "/" + project_type + "/" + process + "/" + rv_filename + ".jpg"

    server.simple_checkin(sk,
                          process,
                          final_filename,
                          description="VRAY",
                          mode="inplace")
    print "image uploaded"
예제 #8
0
def saveRV():
    username = os.environ.get("USERNAME")
    from tactic_client_lib import TacticServerStub
    server = TacticServerStub()
    #server.set_server("192.168.201.10")
    #server.set_project("simpleslot")
    ticket_files = os.listdir("c:/sthpw/etc/")
    ticket_file = "c:/sthpw/etc/" + username + ".tacticrc"

    if len(ticket_files) == 0:
        file_object = open(ticket_file, "w")
        ticket_content = "login="******"\n" + "server=192.168.201.10" + "\n" + "project=simpleslot"
        file_object.write(ticket_content)
        file_object.close()

    else:
        file_object = open(ticket_file)
        ticket_content = file_object.readlines()
        file_object.close()
        ticket = ticket_content[2].replace("ticket=", "").replace("\n", "")
        server.ticket = ticket
        server.set_server("192.168.201.10")
        server.set_project("simpleslot")

    rvname = jc.getNextFileName(1)
    rv_path = rvname[0]
    rv_filename = rvname[2]
    # base_scenename = rvname[1].

    project_name = rvname[3][0]
    item_name = rvname[3][1]
    process = rvname[3][2]
    # author = rvname[3][3]
    # reviewVersion = rvname[3][4]
    project_type = rvname[3][5]
    tactic_base_path = "//Art-1405260002/d/assets/simpleslot/"

    if project_type == "casino":
        stype = "3d"
    elif project_type == "assets":
        stype = "assets"
    elif project_type == "shot":
        stype = "shot"

    src_filename = rv_path + rv_filename
    dst_filename = tactic_base_path + project_name + "/" + project_type + "/" + process + "/" + rv_filename

    if os.path.isdir(tactic_base_path + project_name + "/" + project_type +
                     "/" + process + "/") is False:
        os.makedirs(tactic_base_path + project_name + "/" + project_type +
                    "/" + process + "/")

    if cmds.intScrollBar("scrollBar", q=1, v=1) == -1:
        cmds.renderWindowEditor("renderView", e=1, si=1)
        cmds.intScrollBar("scrollBar", e=1, v=0)

    orig_format = mel.eval('getAttr "defaultRenderGlobals.imageFormat";')
    mel.eval('setAttr "defaultRenderGlobals.imageFormat" 8;')
    cmds.renderWindowEditor("renderView", e=1, wi=src_filename)
    mel.eval('setAttr "defaultRenderGlobals.imageFormat" ' + str(orig_format) +
             ';')

    shutil.copy2((src_filename + ".jpg"), (dst_filename + ".jpg"))

    expr = "@SOBJECT(simpleslot/game['name','" + project_name + "'].simpleslot/" + stype + "['name','" + item_name + "'].sthpw/task['process','" + process + "'])"
    task = server.eval(expr)

    sk = task[0].get("__search_key__")

    final_filename = "/mnt/hgfs/assets/simpleslot/" + project_name + "/" + project_type + "/" + process + "/" + rv_filename + ".jpg"

    server.simple_checkin(sk,
                          process,
                          final_filename,
                          description="image",
                          mode="inplace")
    print "image uploaded"


#saveRV()
예제 #9
0
def main(args, src_snapshot_code=None, src_search_type=None, src_search_code=None, src_context=None, src_version=None,\
        tgt_context=None, tgt_version=None, file_path=None):

    if len(args) == 3:
        # assume code and file path are equivalent
        search_type = args[0]
        code = args[1]
        bin_info = args[2]
    elif len(args) == 4:
        search_type = args[0]
        code = args[1]
        bin_info = args[2]
        file_path = args[3]
    server = TacticServerStub()

    if file_path:
        description = "Dailies Submission [%s] to [%s] - [%s]" % (file_path, search_type, code)
    elif src_snapshot_code:
        description = "Dailies Submission internal reference [%s] to [%s] - [%s]" \
            % (src_snapshot_code, search_type, code)
    else:
        description = "Dailies Submission internal reference [%s|%s] to [%s] - [%s]" \
            % (src_search_type, src_search_code, search_type, code)
    server.start(title='Dailies Submission', description=description )
    try:
        parts = bin_info.split('|')
        if len(parts) == 3:
            bin_code, type, label = parts[0], parts[1], parts[2]
            bins = server.query('prod/bin', [('code', bin_code), ('label', label), ('type', type)])
        elif len(parts) == 2:
            bin_code, type = parts[0], parts[1]
            bins = server.query('prod/bin', [('code', bin_code), ('type', type)])
        if not bins:
            raise TacticApiException("Bin code [%s], type [%s], label [%s] not found in system " % (bin_code, type, label))
    
        
        search_key = server.build_search_key(search_type, code)
        sobject = server.query(search_type, [("code", code)])
        if not sobject:
            raise TacticApiException("SObject [%s] with code [%s] not found" %(search_type, code))

        sobject_id = sobject[0].get('id')
        # add a new submission
        full_search_type = server.build_search_type(search_type)
        submit_data = {'search_type': full_search_type,\
                        'search_id': sobject_id,\
                        'description': "Client Api Submission: [%s]" %code\
                        }
        if tgt_context and tgt_version != None:
            submit_data['context'] = tgt_context
            if tgt_version in ['0', 0 ,'-1', -1]:
                tgt_snapshot = server.get_snapshot(search_key, tgt_context, version=tgt_version)
                if not tgt_snapshot:
                    print "tgt_context [%s] and tgt_version [%s] for this sobject cannot be found" %(tgt_context, tgt_version)
                else: 
                    tgt_version = tgt_snapshot.get('version')
            submit_data['version'] = tgt_version

        src_snapshot = None
        if src_snapshot_code:
            src_snapshot = server.query('sthpw/snapshot',filters=[('code', src_snapshot_code)], single=True)
            submit_data['context'] = src_snapshot.get('context')
            submit_data['version'] = src_snapshot.get('version')

        submission = server.insert('prod/submission', submit_data)
        # add to bin
        submit_in_bin_data = { 'bin_id': bins[0].get('id'), \
                                'submission_id': submission.get('id')\
                                }
        server.insert('prod/submission_in_bin', submit_in_bin_data)
        
        print "New submission [%s] created for [%s].\n" %(submission.get('__search_key__'), full_search_type)
         
        if file_path:
            #NOTE: use the upload method instead of copy or move 
            server.simple_checkin(submission.get('__search_key__'), 'publish', file_path, \
                    snapshot_type='submission', description='Client API dailies submission', mode='upload')
        else:
            if src_snapshot:
               
                pass 
            elif src_search_type:
                src_search_key = server.build_search_key(src_search_type, src_search_code)
            else:
                src_search_key = search_key

            if not src_snapshot:
                src_snapshot = server.get_snapshot(src_search_key, context=src_context, version=src_version)
        
            if src_snapshot:
                snapshot_code = src_snapshot.get('code')
                
                # build a new snapshot
                
                submit_snapshot = server.create_snapshot(submission.get('__search_key__'), \
                        "publish", description='Client API dailies submission', \
                        snapshot_type='submission')

                # add dependency
                server.add_dependency_by_code(submit_snapshot.get('code'), snapshot_code)
            else:
                raise TacticApiException("No snapshot found for [%s] with context [%s] and version [%s]."\
                        %(src_search_key, src_context, src_version))
                return
        
        

    except Exception, e:
        server.abort()
        print "ERROR: ", e.__str__()