示例#1
0
    def execute(my):
        #protocol = 'xmlrpc'
        protocol = 'local'
        if protocol == 'local':
            server = TacticServerStub.get()
        else:
            server = TacticServerStub(protocol=protocol, setup=False)
            TacticServerStub.set(server)

            project = my.data.get("project")
            ticket = my.data.get("ticket")
            assert project
            assert ticket
            server.set_server("localhost")
            server.set_project(project)
            server.set_ticket(ticket)

        my.class_name = my.data.get('class_name')
        assert my.class_name

        # get the script to run
        script_code = my.data.get("script_code")
        if script_code:
            search_type = "config/custom_script"
            search_key = server.build_search_key(search_type, script_code)
            script_obj = server.get_by_search_key(search_key)
            script = script_obj.get('script')
            my.run_script(script)
        else:
            print "Nothing to run"
示例#2
0
    def execute(my):
        #protocol = 'xmlrpc'
        protocol = 'local'
        if protocol == 'local':
            server = TacticServerStub.get()
        else:
            server = TacticServerStub(protocol=protocol,setup=False)
            TacticServerStub.set(server)

            project = my.data.get("project")
            ticket = my.data.get("ticket")
            assert project
            assert ticket
            server.set_server("localhost")
            server.set_project(project)
            server.set_ticket(ticket)

        my.class_name = my.data.get('class_name')
        assert my.class_name

        # get the script to run
        script_code = my.data.get("script_code")
        if script_code:
            search_type = "config/custom_script"
            search_key = server.build_search_key(search_type, script_code)
            script_obj = server.get_by_search_key(search_key)
            script = script_obj.get('script')
            my.run_script(script)
        else:
            print "Nothing to run"
示例#3
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)
示例#4
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)
示例#5
0
class Sample3dTest(unittest.TestCase):

    def setUp(self):
        pass

    def test_all(self):
        print "Running Sample3d Test"

        from pyasm.security import Batch
        from pyasm.biz import Project
        Batch()
        Project.set_project("sample3d")


        #self.server = TacticServerStub(protocol="local")
        self.server = TacticServerStub(protocol="xmlrpc")
        project_code = "sample3d"
        self.server.set_project(project_code)


        self.server.start("Sample3d Test")
        try:
            self._test_create_search_type()
            self._test_create_submission()
            self._test_get_submission()
            self._test_shot_sequence_hierarchy()
            self._test_query_snapshots()
            #self._test_performance()
        except Exception:
            self.server.abort()
            raise
        self.server.abort()


        #try:
        #    self.server.query("prod/asset")
        #except Exception:
        #    self.server.abort()
        #    raise
        #self.server.abort()



    def _test_query_snapshots(self):
        filters = []
        filters.append( ['context', 'model'] )
        filters.append( ['search_type', 'prod/asset?project=sample3d'] )
        snapshots = self.server.query_snapshots(filters=filters, include_paths=True)

        import time
        start = time.time()
        for snapshot in snapshots:
            print snapshot.get('__search_key__')
            print snapshot.get('__paths__')
            print "parent: ", snapshot.get('__parent__')
        print time.time() - start




    def _test_create_search_type(self):
        search_type = 'test'
        search_type_obj = self.server.create_search_type(search_type)
        print search_type_obj




    def _test_performance(self):

        for i in range(0,1):
            assets = self.server.query("prod/asset")
            for asset in assets:
                asset_key = asset.get("__search_key__")
                snapshots = self.server.get_all_children(asset_key,'sthpw/snapshot')
                #snapshot = self.server.get_snapshot(asset_key,context='model', include_paths=True)
                #print snapshot.get('__paths__')


        




    def _test_get_submission(self):

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

        # choose some arbitrary bin
        bin_id = 4
        filters = []
        filters.append( ['bin_id', bin_id] )
        connectors = server.query("prod/submission_in_bin", filters)

        # get all of the submissions from the bin
        submission_ids = [x.get('submission_id') for x in connectors]
        filters = [ ['id', submission_ids] ]
        submissions = server.query("prod/submission", filters)


        # get all of the snapshots from the submissions
        for submission in submissions:
            search_key = submission.get('__search_key__')

            print "-"*20
            snapshot = server.get_snapshot(search_key, include_paths=True)

            paths = snapshot.get('__paths__')
            for path in paths:
                print path



    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)




    def _test_shot_sequence_hierarchy(self):
        shot_key = "prod/shot?project=sample3d&code=RC_001_001"
        shot = self.server.get_by_search_key(shot_key)
        
        parent = self.server.get_parent(shot_key)
        self.assertEquals("RC_001", parent.get("code") )
示例#6
0
class clinicaltags(object):
    """ Basic generic class to add and delete tags from TACTIC.

	TAGs can be associated with a Subject, a Series, or an Exam level contained in TACTIC.

	This class will give the ability to add, delete, update and get the TAGs from each level.

	Keep in mind TAGS are basically python dictionaries. 


	Parameters: 

	codetype: Code type can be one of the following.
				exam_code
				subject_code
				series_code
				search_key
	level: Level can be (based on our Tactic Schema).
				Subject
				Exam
				Series
	Project: Project name.
				default qin
	allowed: A dictionary containing all the allowed tags for the projects included inside tactic. Class should provide basic documentations for Allowed values and TAG names."""
    logger = logging.getLogger('TAGS')
    logger.setLevel(logging.INFO)
    # create file handler which logs even debug messages
    # create console handler with a higher log level
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
    # create formatter and add it to the handlers
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    ch.setFormatter(formatter)
    # add the handlers to the logger
    logger.addHandler(ch)
    logger.info('---------------------------------')
    logger.info('Date %s' % time.strftime("%d/%m/%Y"))
    logger.info('Time %s' % time.strftime("%H:%M:%S"))
    logger.info('---------------------------------')
    logger.info('Start ')
    ## This is a dictionary of the available TAGs in TACTIC
    allowed = {'Panos', 'test'}
    server = TacticServerStub()

    def __init__(self, name, value, code):
        self.name = name
        self.value = value
        self.code = code
        self.server = TacticServerStub()

    def getTag(self):
        if self.name in self.allowed:
            Subject1 = self.server.get_by_search_key(self.code)
            return Subject1.tags
        else:
            logger.info('The value %s is not allowed ' % self.vale)

    def delTag(self):
        Subject1 = self.server.get_by_search_key(self.code)
        Subject1[0].tagspop(self.name, None)
        Subject1[0].save()
        return 0

    def addTag(self):
        if self.name in self.allowed:
            Subject1 = server.get_by_search_key(self.code)
            Subject1[0].tags.update({self.name: self.value})
            Subject1[0].save()
        else:
            logger.info('The value %s is not allowed ' % self.vale)

    def updateTag(self):
        if self.name in self.allowed:
            Subject1 = server.get_by_search_key(self.code)
            Subject1[0].tags.update({self.name: self.value})
            Subject1[0].save()
            return 0
        else:
            logger.info('The value %s is not allowed ' % self.vale)
示例#7
0
class Sample3dTest(unittest.TestCase):
    def setUp(self):
        pass

    def test_all(self):
        print "Running Sample3d Test"

        from pyasm.security import Batch
        from pyasm.biz import Project
        Batch()
        Project.set_project("sample3d")

        #self.server = TacticServerStub(protocol="local")
        self.server = TacticServerStub(protocol="xmlrpc")
        project_code = "sample3d"
        self.server.set_project(project_code)

        self.server.start("Sample3d Test")
        try:
            self._test_create_search_type()
            self._test_create_submission()
            self._test_get_submission()
            self._test_shot_sequence_hierarchy()
            self._test_query_snapshots()
            #self._test_performance()
        except Exception:
            self.server.abort()
            raise
        self.server.abort()

        #try:
        #    self.server.query("prod/asset")
        #except Exception:
        #    self.server.abort()
        #    raise
        #self.server.abort()

    def _test_query_snapshots(self):
        filters = []
        filters.append(['context', 'model'])
        filters.append(['search_type', 'prod/asset?project=sample3d'])
        snapshots = self.server.query_snapshots(filters=filters,
                                                include_paths=True)

        import time
        start = time.time()
        for snapshot in snapshots:
            print snapshot.get('__search_key__')
            print snapshot.get('__paths__')
            print "parent: ", snapshot.get('__parent__')
        print time.time() - start

    def _test_create_search_type(self):
        search_type = 'test'
        search_type_obj = self.server.create_search_type(search_type)
        print search_type_obj

    def _test_performance(self):

        for i in range(0, 1):
            assets = self.server.query("prod/asset")
            for asset in assets:
                asset_key = asset.get("__search_key__")
                snapshots = self.server.get_all_children(
                    asset_key, 'sthpw/snapshot')
                #snapshot = self.server.get_snapshot(asset_key,context='model', include_paths=True)
                #print snapshot.get('__paths__')

    def _test_get_submission(self):

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

        # choose some arbitrary bin
        bin_id = 4
        filters = []
        filters.append(['bin_id', bin_id])
        connectors = server.query("prod/submission_in_bin", filters)

        # get all of the submissions from the bin
        submission_ids = [x.get('submission_id') for x in connectors]
        filters = [['id', submission_ids]]
        submissions = server.query("prod/submission", filters)

        # get all of the snapshots from the submissions
        for submission in submissions:
            search_key = submission.get('__search_key__')

            print "-" * 20
            snapshot = server.get_snapshot(search_key, include_paths=True)

            paths = snapshot.get('__paths__')
            for path in paths:
                print path

    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)

    def _test_shot_sequence_hierarchy(self):
        shot_key = "prod/shot?project=sample3d&code=RC_001_001"
        shot = self.server.get_by_search_key(shot_key)

        parent = self.server.get_parent(shot_key)
        self.assertEquals("RC_001", parent.get("code"))