def main(testing_flag):
    config = ConfigParser.ConfigParser()
    config.read('config.ini')

    # Get credentials from config file
    user = config.get('credentials', 'user')
    password = config.get('credentials', 'password')
    project = config.get('credentials', 'project')

    # If the testing flag is passed, use the test server, otherwise use the live server
    if testing_flag:
        url = config.get('server', 'test')
    else:
        url = config.get('server', 'live')

    # Get a server object to perform queries
    server = TacticServerStub(server=url, project=project, user=user, password=password)

    territories_str = 'Afghanistan|Aland Islands|Albania|Algeria|American Samoa|Andorra|Angola|Anguilla|Antigua and Barbuda|Argentina|Armenia|Aruba|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bonaire|Bosnia and Herzegovina|Botswana|Bouvet Island|Brazil|Brunei Darussalam|Bulgaria|Burkina Faso|Burundi|Cambodia|Cameroon|Canada|Cantonese|Cape Verde|Cayman Islands|Central African Republic|Chad|Chile|China|Christmas Island|Cocos Islands|Colombia|Comoros|Congo|Dem. Rep. of Congo|Cook Islands|Costa Rica|Croatia|Cuba|Curacao|Cyprus|Czech|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|English|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Falkland Islands|Faroe Islands|Fiji|Finland|France|French Guiana|French Polynesia|Gabon|Gambia|Georgia|Germany|Ghana|Gibraltar|Greece|Greek|Greenland|Grenada|Guadeloupe|Guam|Guatemala|Guernsey|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hong Kong|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Isle of Man|Israel|Italy|Ivory Coast|Jamaica|Japan|Jersey|Jordan|Kazakhstan|Kenya|Kiribati|Kuwait|Kyrgyztan|Laos|Latin America|Latin Spanish|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luzembourg|Macao|Macedonia|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Martinique|Mauritania|Mauritius|Mayotte|Mexico|Micronesia|Moldova|Monaco|Mongolia|Montenegro|Montserrat|Morocco|Mozambique|Multi-language|Myanmar|Namibia|Nauru|Nepal|Netherlands|New Caledonia|New Zealand|Nicaragua|Niger|Nigeria|Niue|Norfolk Island|North Korea|Northern Mariana Islands|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Pan-Asia|Paraguay|Peru|Philippines|Pitcairn|Poland|Portugal|Puerto Rico|Qatar|Reunion|Romania|Russia|Russian|Rwanda|St Barthelemy|St Helena|St Kitts and Nevis|St Lucia|St Martin|St Pierre and Miquelo|St Vincent and Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Signapore|Sint Maarten|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Georgia and Swch Islands|South Korea|South Sudan|Spain|Sri Lanka|Sudan|Suriname|Svalbard|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thai|Thailand|Timor-Leste|Togo|Tokelau|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Turks and Caicos Islands|Tuvalu|Uganda|Ukraine|UAE|United Kingdom|United States|Uruguay|Uzbekistan|Vanuatu|Various|Vatican|Venezuela|Vietnam|Virgin Islands|Wallis and Futuna|West Indies|Western Sahara|Yemen|Zambia|Zimbabwe'
    territories = territories_str.split('|')

    for territory in territories:
        territory_search = server.eval("@SOBJECT(twog/territory['name', '{0}'])".format(territory))

        if not territory_search:
            # Territory does not exist yet, insert it
            server.insert('twog/territory', {'name': territory})
예제 #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
        my.kwargs = my.data.get('kwargs')
        if not my.kwargs:
            my.kwags = {}


        #trigger = eval("%s(**my.kwargs)" % my.class_name)
        trigger = Common.create_from_class_path(my.class_name, kwargs=my.kwargs)

        input_data = my.get_input_data()
        trigger.set_input(input_data)
        trigger.execute()
예제 #3
0
    def GET(my):
        method = my.kwargs.get("method")
        print my.kwargs
        print "method: ", method
        print "expression: ", my.kwargs.get("expression")


        # /rest/get_by_code/cars/CAR00009

        # /rest/query?search_type=sthpw/cars
        if method == "query":
            code = my.kwargs.get("data")
            from pyasm.search import Search
            sobject = Search.get_by_code(search_type, code)
            sobject_dict = sobject.get_sobject_dict()
            return sobject_dict

        # /rest/expression/@SOBJECT(sthpw/task)
        elif method == "expression":
            expression = my.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)

        # /rest/simple_checkin?search_key=dfadfdsas&data={}
        elif method == "expression":
            expression = my.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)


        return {}
예제 #4
0
 def search(cls, filters=[]):
     SubjectInfo.logger.debug("Search with cls: %s" % cls)
     server = TacticServerStub()
     objects = server.query(cls.stype, filters=filters)
     # Here we do something different
     si = SubjectInfo(objects)
     return si
예제 #5
0
파일: get_ticket.py 프로젝트: 0-T-0/TACTIC
def main(args):

    server = TacticServerStub(setup=False)
    server.get_info_from_user(force=True)
    return

    """
예제 #6
0
    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()
예제 #7
0
    def GET(self):
        method = self.kwargs.get("method")
        print self.kwargs
        print "method: ", method
        print "expression: ", self.kwargs.get("expression")

        # /rest/get_by_code/cars/CAR00009

        # /rest/query?search_type=sthpw/cars
        if method == "query":
            code = self.kwargs.get("data")
            from pyasm.search import Search
            sobject = Search.get_by_code(search_type, code)
            sobject_dict = sobject.get_sobject_dict()
            return sobject_dict

        # /rest/expression/@SOBJECT(sthpw/task)
        elif method == "expression":
            expression = self.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)

        # /rest/simple_checkin?search_key=dfadfdsas&data={}
        elif method == "expression":
            expression = self.kwargs.get("expression")
            server = TacticServerStub.get()
            return server.eval(expression)

        return {}
예제 #8
0
    def _execute(self):

        # get the server name
        server_name = self.get_option("server_name")
        if not server_name:
            raise ClientCallbackException(
                "No [server_name] option delivered to callback")
        server_name = server_name[0]

        # get the project
        project_code = self.get_option("project_code")
        if not project_code:
            raise ClientCallbackException(
                "No [project_code] option delivered to callback")
        project_code = project_code[0]

        # the entire pipeline is run in a TacticServer Transaction
        from tactic_client_lib import TacticServerStub
        self.server = TacticServerStub()
        self.server.set_server(server_name)
        self.server.set_ticket(self.ticket)
        self.server.set_project(project_code)

        self.server.start("Pipeline checkin")
        try:
            self.execute()

        except Exception, e:
            self.server.abort()
            raise
예제 #9
0
def main():
    # get an instance of the stub
    server = TacticServerStub()

    # start the transaction
    server.start("Set query")
    try:

        # define the search type we are searching for
        search_type = "prod/asset"
          
        # define a filter
        filters = [] 
        filters.append( ("asset_library", "chr") )
          
        # do the query
        assets = server.query(search_type, filters)

        # show number found
        print("found [%s] assets" % len(assets) )
          
        # go through the asset and print the code
        for asset in assets:
            code = asset.get("code")  
            print(code)


    except:
        # in the case of an exception, abort all of the interactions
        server.abort()
        raise
    else:
        # otherwise, finish the transaction
        server.finish()
    def post(self):
        json_data = request.get_json()

        ticket = json_data.get('token')
        element_evaluation_data = json_data.get('element_evaluation')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        server.insert('twog/element_evaluation', element_evaluation_data)

        return jsonify({'status': 200})
    def post(self):
        json_data = request.get_json()

        ticket = json_data.get('token')
        element_evaluation_data = json_data.get('element_evaluation')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        server.insert('twog/element_evaluation', element_evaluation_data)

        return jsonify({'status': 200})
    def get_element_eval_from_tactic_one(element_eval_code, username, password):
        server = TacticServerStub(server='http://tactic01.2gdigital.com', project='twog', user=username,
                                  password=password)

        element_eval = server.eval("@SOBJECT(twog/element_eval['code', '{0}'])".format(element_eval_code))
        element_eval_lines = server.eval("@SOBJECT(twog/element_eval_lines['element_eval_code', '{0}'])".format(element_eval_code))
        element_eval_audio_lines = server.eval("@SOBJECT(twog/element_eval_audio['element_eval_code', '{0}'])".format(element_eval_code))

        print(element_eval)
        print(element_eval_lines)
        print(element_eval_audio_lines)
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('token', required=True)
        args = parser.parse_args()

        ticket = args.get('token')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        element_evaluations = server.eval("@SOBJECT(twog/element_evaluation)")

        return jsonify({'element_evaluations': element_evaluations})
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('token', required=True)
        args = parser.parse_args()

        ticket = args.get('token')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        element_evaluations = server.eval("@SOBJECT(twog/element_evaluation)")

        return jsonify({'element_evaluations': element_evaluations})
예제 #15
0
def bootstrap_get_tactic_server_stub( tactic_server_str, project_code, login, password ):

    conn = httplib.HTTPConnection(tactic_server_str)
    conn.request("GET", "/context/VERSION.txt")

    response = conn.getresponse()
    # print response.status, response.reason

    data = response.read()
    tactic_version = data.strip()

    conn.close()

    print
    print "> Found TACTIC version '%s' running on server %s ..." % (tactic_version, tactic_server_str)
    print

    client_lib_install_path = "C:/sthpw/client_api/tactic-%s/client" % tactic_version

    print "  ... attempting to import 'TacticServerStub' from 'tactic_client_lib' located in:"
    print
    print "         %s" % client_lib_install_path
    print

    try:
        sys.path.append( client_lib_install_path )
        from tactic_client_lib import TacticServerStub
        if not login or not password:
            print
            print "> Warning: login/password not provided, assuming the use of .tacticrc ticket ..."
            print
            tactic_server = TacticServerStub(server=tactic_server_str, project=project_code)
        else:
            tactic_server = TacticServerStub(
                                server=tactic_server_str,
                                project=project_code,
                                user=login,
                                password=password
                            )
    except:
        print "  ERROR: unable to access TACTIC client API for server version '%s'" % (tactic_version)
        if not login or not password:
            print "           (likely there is no .tacticrc ticket that exists)"

        print
        print "Exception found:"
        print '-'*60
        traceback.print_exc(file=sys.stdout)
        print '-'*60
        print
        tactic_server = None

    return tactic_server
예제 #16
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__()
    def get(self, name):
        parser = reqparse.RequestParser()
        parser.add_argument('token', required=True)
        args = parser.parse_args()

        ticket = args.get('token')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        element_evaluations = server.eval("@SOBJECT(twog/element_evaluation['name', '{0}'])".format(name))

        if element_evaluations:
            return jsonify({'exists': True})
        else:
            return jsonify({'exists': False})
예제 #18
0
파일: project.py 프로젝트: hellios78/TACTIC
    def get_server(my):
        # do a query for the search
        from tactic_client_lib import TacticServerStub
        if my.protocol == 'xmlrpc':
            stub = TacticServerStub(setup=False, protocol=my.protocol)
            stub.set_server(my.host)
            stub.set_project(my.project_code)
            stub.set_ticket(my.ticket)
        else:
            stub = TacticServerStub.get()

        return stub
예제 #19
0
    def update_related(self, login_group, prev_login_group):
        '''Update related table login_in_group'''

        search = Search('sthpw/login_in_group')
        search.add_filter('login_group', prev_login_group)
        login_in_groups = search.get_sobjects()

        if login_in_groups:

            server = TacticServerStub.get()
            login_in_group_dict = {}

            data = {"login_group": login_group}

            for login_in_group in login_in_groups:
                login_in_group_code = login_in_group.get("code")
                login_in_group_sk = server.build_search_key(
                    "sthpw/login_in_group", login_in_group_code)
                login_in_group_dict[login_in_group_sk] = data

            try:
                server.update_multiple(login_in_group_dict)
            except Exception, e:
                raise TacticException('Error updating login_in_group %s' %
                                      e.str())
예제 #20
0
    def execute(self):
        Container.put("TestApiHandler", "test_api_handler")
        
        # test that you can run the client api from here
        server = TacticServerStub.get()
        server.start("Api Trigger test")
        try:
            test = server.ping()
            Container.put("TestApiHandler/ping", test)

            # do some more tests
            search_type = "unittest/person"
            code = "jack"
            search_key = server.build_search_key(search_type, code)

            Container.put("TestApiHandler/search_key", search_key)
            # insert
            data = { 'code': code }
            server.insert(search_type, data)
            # query
            sobject = server.get_by_search_key(search_key)
            Container.put("TestApiHandler/code", sobject.get('code'))

        finally:
            server.abort()
예제 #21
0
    def get_to(my):
        from tactic_client_lib import TacticServerStub
        from pyasm.common import Environment
        recipients = set()
        to = '*****@*****.**'
        login_obj = Environment.get_login()
        login = login_obj.get_login()
        server = TacticServerStub.get()
        eq = my.sobject
        wo_code = eq.get_value('work_order_code')
        
        if wo_code not in [None,'']:
            wo = server.eval("@SOBJECT(twog/work_order['code','%s'])" % wo_code)
            if wo:
                wo = wo[0]
                if wo.get('login') != login:
                    the_obj = Login.get_by_code(wo.get('login'))
                    if the_obj:
                        recipients.add(the_obj)
#                    creator_login_obj = server.eval("@SOBJECT(sthpw/login['login','%s'])" % wo.get('login'))
#                    if creator_login_obj:
#                        creator_login_obj = creator_login_obj[0]
#                        #to = creator_login_obj.get('email')
#                        to = creator_login_obj
        print "RETURN Recipients: %s" % recipients        
        return recipients
예제 #22
0
    def execute(self):
        # ensure that the protocol is "local"
        server = TacticServerStub.get()
        if server.get_protocol() != "local":
            raise Exception("TacticServerStub protocol is not 'local'")

        # test some inputs
        is_insert = self.get_input_value("is_insert")
        if is_insert != True:
            raise Exception("is_insert != True")

        is_insert = self.get_input_value("is_insert")
        if is_insert != True:
            raise Exception("is_insert != True")

        search_key = self.get_input_value('search_key')
        if search_key != 'unittest/person?project=unittest&code=fred':
            raise Exception(
                "search_key != 'unittest/person?project=unittest&code=fred'")

        prev_data = self.get_input_value('prev_data')
        if prev_data.get('code') != None:
            raise Exception("prev_data['code'] != None")

        prev_data = self.get_input_value('update_data')
        if prev_data.get('code') != 'fred':
            raise Exception("update_data['code'] != 'fred'")
예제 #23
0
    def update_related(self, login_group, prev_login_group):
        '''Update related table login_in_group''' 

        search = Search('sthpw/login_in_group')
        search.add_filter('login_group', prev_login_group)
        login_in_groups = search.get_sobjects()

        if login_in_groups:

            server = TacticServerStub.get()
            login_in_group_dict = {}
            
            data = {
                "login_group": login_group
            }

            for login_in_group in login_in_groups:
                login_in_group_code = login_in_group.get("code")
                login_in_group_sk = server.build_search_key("sthpw/login_in_group", login_in_group_code)
                login_in_group_dict[login_in_group_sk] = data

            try:
                server.update_multiple(login_in_group_dict)
            except Exception, e:
                raise TacticException('Error updating login_in_group %s' % e.str())
예제 #24
0
def accesshandler(request):

    cookies = Cookie.get_cookies(request)

    # if login ticket cookie does not exist, then deny
    if not cookies.has_key('login_ticket'):
        # just refuse access
        return apache.HTTP_FORBIDDEN

    ticket = cookies['login_ticket'].value
    if not ticket:
        return apache.HTTP_FORBIDDEN

    server = TacticServerStub.get(protocol='local')
    expr = "@SOBJECT(sthpw/ticket['ticket','%s'])" % ticket
    sobject = server.eval(expr, single=True)
    now = SPTDate.now()
    expiry = sobject.get("expiry")
    if expiry and expiry < str(now):
        return apache.HTTP_FORBIDDEN

    request.add_common_vars()
    path = str(request.subprocess_env['REQUEST_URI'])
    if path == None:
        return apache.HTTP_FORBIDDEN

    # FIXME: find some mechanism which is more acceptable ... like /icons
    #if path.find("_icon_") != -1:
    #    return apache.OK

    return apache.OK
예제 #25
0
def main(server=None, input_data=None):
    if not input_data:
        input_data = {}

    if not server:
        server = TacticServerStub.get()

    input_sobject = input_data.get('sobject')

    order_code = input_sobject.get('code')
    priority = input_sobject.get('priority')

    component_search = Search('twog/component')
    component_search.add_filter('order_code', order_code)
    component_sobjects = component_search.get_sobjects()

    for component_sobject in component_sobjects:
        tasks = get_task_sobjects_from_component_sobject(component_sobject)

        data_to_insert = {}

        for task in tasks:
            task_search_key = server.build_search_key('sthpw/task', task.get_code(), project_code='twog')

            data_to_insert[task_search_key] = {'priority': priority}

        server.update_multiple(data_to_insert)
예제 #26
0
def main(args):
    # USAGE: create_project.py <project_code> <project_title> <project_type> 
    project_code = args[0]
    project_title = args[1]
    project_type = args[2]

    assert project_type in ['prod','flash','simple','unittest']
    assert project_title

    regexs = '^\d|\W'
    m = re.search(r'%s' % regexs, project_code) 
    if m:
        raise TacticApiException('<project_code> cannot contain special characters or start with a number.')

    server = TacticServerStub.get();
    # do the actual work
    server.start("Create Project", "Project creation for [%s] of type [%s]" % (project_code, project_type))
    try:
        args = {
        'project_code': project_code,
        'project_title': project_title,
        'project_type': project_type}
    
    
        
        class_name = "tactic.command.CreateProjectCmd";
        ret_val = server.execute_cmd(class_name, args=args);
        print ret_val
    except:
        server.abort()
        raise
    else:
        server.finish()
예제 #27
0
 def init(my):
     from client.tactic_client_lib import TacticServerStub
     from pyasm.common import Environment
     my.server = TacticServerStub.get()
     my.login = Environment.get_login()
     my.user = my.login.get_login()
     my.movement_code = my.kwargs.get('movement_code')
예제 #28
0
    def _execute(self):

        # get the server name
        server_name = self.get_option("server_name")
        if not server_name:
            raise ClientCallbackException("No [server_name] option delivered to callback")
        server_name = server_name[0]

        # get the project
        project_code = self.get_option("project_code")
        if not project_code:
            raise ClientCallbackException("No [project_code] option delivered to callback")
        project_code = project_code[0]

        # the entire pipeline is run in a TacticServer Transaction
        from tactic_client_lib import TacticServerStub
        self.server = TacticServerStub()
        self.server.set_server(server_name)
        self.server.set_ticket(self.ticket)
        self.server.set_project(project_code)


        self.server.start("Pipeline checkin")
        try:
            self.execute()

        except Exception, e:
            self.server.abort()
            raise
예제 #29
0
파일: workflow.py 프로젝트: jayvdb/TACTIC
    def log_message(my, sobject, process, status):

        # need to use API for now
        key = "%s|%s|status" % (sobject.get_search_key(), process)
        from tactic_client_lib import TacticServerStub
        server = TacticServerStub.get()
        server.log_message(key, status)
예제 #30
0
    def execute(self):
        # ensure that the protocol is "local"
        server = TacticServerStub.get()
        if server.get_protocol() != "local":
            raise Exception("TacticServerStub protocol is not 'local'")

        # test some inputs
        is_insert = self.get_input_value("is_insert")
        if is_insert != True:
            raise Exception("is_insert != True")

        is_insert = self.get_input_value("is_insert")
        if is_insert != True:
            raise Exception("is_insert != True")

        search_key = self.get_input_value('search_key')
        if search_key != 'unittest/person?project=unittest&code=fred':
            raise Exception("search_key != 'unittest/person?project=unittest&code=fred'")

        prev_data = self.get_input_value('prev_data')
        if prev_data.get('code') != None:
            raise Exception("prev_data['code'] != None")

        prev_data = self.get_input_value('update_data')
        if prev_data.get('code') != 'fred':
            raise Exception("update_data['code'] != 'fred'")
예제 #31
0
    def get_input_state(self, sobject, process):

        pipeline = Pipeline.get_by_sobject(sobject)

        # use the first input process
        input_processes = pipeline.get_input_processes(process)
        if not input_processes:
            return {}

        # get the first process for now
        p = input_processes[0]

        process_name = p.get_name()

        key = self.get_state_key(sobject, process_name)

        from tactic_client_lib import TacticServerStub
        server = TacticServerStub.get()

        from pyasm.common import jsonloads
        message = server.get_message(key)
        message = message.get("message")
        if not message:
            state = {}
        else:
            state = jsonloads(message)

        return state
예제 #32
0
    def execute(self):
        Container.put("TestApiHandler", "test_api_handler")

        # test that you can run the client api from here
        server = TacticServerStub.get()
        server.start("Api Trigger test")
        try:
            test = server.ping()
            Container.put("TestApiHandler/ping", test)

            # do some more tests
            search_type = "unittest/person"
            code = "jack"
            search_key = server.build_search_key(search_type, code)

            Container.put("TestApiHandler/search_key", search_key)
            # insert
            data = {'code': code}
            server.insert(search_type, data)
            # query
            sobject = server.get_by_search_key(search_key)
            Container.put("TestApiHandler/code", sobject.get('code'))

        finally:
            server.abort()
예제 #33
0
 def get_display(my):
     from tactic_client_lib import TacticServerStub
     server = TacticServerStub.get()
     print "MY.KWARGS = %s" % my.kwargs
     title_codes = my.kwargs.get('title_codes').split('|')
     order_titles = {}
     for title_code in title_codes:
         title = server.eval("@SOBJECT(twog/title['code','%s'])" % title_code)
         if title:
             title = title[0]
             order_code = title.get('order_code')
             if order_code not in order_titles.keys():
                 order = server.eval("@SOBJECT(twog/order['code','%s'])" % order_code)[0]
                 order_titles[order_code] = {'order': order, 'titles': []}
             order_titles[order_code]['titles'].append(title)
     widget = DivWdg()
     table = Table()
     for order_code in order_titles.keys():
         table.add_row()
         table.add_cell('ORDER: %s' % order_titles[order_code]['order'].get('name'))
         for title in order_titles[order_code]['titles']:
             table.add_row() 
             title_name = title.get('title')
             if title.get('episode') not in [None,'']:
                 title_name = '%s: %s' % (title_name, title.get('episode'))
             table.add_cell('TITLE: %s' % title_name)
             
     widget.add(table)
     return widget
예제 #34
0
 def get_subject(my):
     from tactic_client_lib import TacticServerStub
     server = TacticServerStub.get()
     eq = my.sobject
     equipment_name = eq.get_value('name')
     work_order_code = eq.get_value('work_order_code')
     work_order = None
     proj = None
     title = None
     order = None
     if work_order_code not in [None,'']:
         work_order = server.eval("@SOBJECT(twog/work_order['code','%s'])" % work_order_code)[0]
         proj = server.eval("@SOBJECT(twog/proj['code','%s'])" % work_order.get('proj_code'))[0]
         title = server.eval("@SOBJECT(twog/title['code','%s'])" % proj.get('title_code'))[0]
         order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0]
     po_number = ''
     order_name = ''
     title_title = ''
     title_episode = ''
     proj_code = ''
     if order: 
         po_number = order.get('po_number')
         order_name = order.get('name')
     if title:
         title_title = title.get('title')
         title_episode = title.get('episode')
     if proj:
         proj_code = proj.get('code')
  
     subject = 'Equipment Added by Operator in %s (%s), to %s: %s-%s-%s ' % (order_name, po_number, title_title, title_episode, proj_code, work_order_code)
     return subject
    def get(self, name):
        parser = reqparse.RequestParser()
        parser.add_argument('token', required=True)
        args = parser.parse_args()

        ticket = args.get('token')

        server = TacticServerStub(server=url, project=project, ticket=ticket)

        element_evaluations = server.eval(
            "@SOBJECT(twog/element_evaluation['name', '{0}'])".format(name))

        if element_evaluations:
            return jsonify({'exists': True})
        else:
            return jsonify({'exists': False})
예제 #36
0
def get_client_img(client_code):
    img_path = ''
    client_search = Search("twog/client")
    client_search.add_filter('code', client_code)
    client_search_object = client_search.get_sobject()

    if client_search_object:
        client_id = client_search_object.get_id()

        snaps_s = Search("sthpw/snapshot")
        snaps_s.add_filter('search_id', client_id)
        snaps_s.add_filter('search_type', 'twog/client?project=twog')
        snaps_s.add_filter('is_current', '1')
        snaps_s.add_filter('version', '0', op='>')
        snaps_s.add_where("\"context\" in ('publish','icon','MISC')")
        snaps_s.add_order_by('timestamp desc')
        snaps = snaps_s.get_sobjects()

        if len(snaps) > 0:
            server = TacticServerStub.get()
            snap = snaps[0]
            img_path = server.get_path_from_snapshot(snap.get_code(), mode="web")

            if img_path:
                img_path = 'http://' + server.get_server_name() + img_path
        return img_path
    else:
        return None
예제 #37
0
    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()
예제 #38
0
def accesshandler(request):

    cookies = Cookie.get_cookies(request)

    # if login ticket cookie does not exist, then deny
    if not cookies.has_key('login_ticket'):
        # just refuse access
        return apache.HTTP_FORBIDDEN

    ticket = cookies['login_ticket'].value
    if not ticket:
        return apache.HTTP_FORBIDDEN

    server = TacticServerStub.get(protocol='local')
    expr = "@SOBJECT(sthpw/ticket['ticket','%s'])" % ticket
    sobject = server.eval(expr, single=True)
    now = SPTDate.now()
    expiry = sobject.get("expiry")
    if expiry and expiry < str(now):
        return apache.HTTP_FORBIDDEN

    request.add_common_vars()
    path = str(request.subprocess_env['REQUEST_URI'])
    if path == None:
        return apache.HTTP_FORBIDDEN


    # FIXME: find some mechanism which is more acceptable ... like /icons
    #if path.find("_icon_") != -1:
    #    return apache.OK

    return apache.OK
예제 #39
0
def main():
    # get an instance of the stub
    server = TacticServerStub()

    # start the transaction
    server.start("Ping Test")
    try:
        # ping the server
        print server.ping()
    except:
        # in the case of an exception, abort all of the interactions
        server.abort()
        raise
    else:
        # otherwise, finish the transaction
        server.finish()
예제 #40
0
    def execute(my):
        server = TacticServerStub.get()
        server.start("Starting city insert trigger",
                     "On inserting seoul, insert incheon")

        try:

            city_key = my.get_input_value("search_key")
            mode = my.get_input_value("mode")
            if mode == 'delete':
                return
            city = server.get_by_search_key(city_key)
            if city.get('code') == 'seoul':
                # make sure triggers=False to avoid infinite loop
                server.insert('unittest/city', {
                    'code': 'incheon',
                    'country_code': 'korea'
                },
                              triggers=False)

            if city.get('code') == 'incheon':
                raise TacticException(
                    'Should not have reached this point and fired this trigger.'
                )

        except:
            server.abort()
            raise
        else:
            server.finish()
예제 #41
0
 def init(my):
     from client.tactic_client_lib import TacticServerStub
     from pyasm.common import Environment
     my.server = TacticServerStub.get()
     my.sk = ''
     my.code = ''
     my.name = ''
    def add_task_to_component(self, process, component_code, login):
        server = TacticServerStub.get()

        component_search = Search('twog/component')
        component_search.add_code_filter(component_code)
        component = component_search.get_sobject()

        server.insert('sthpw/task', {'process': process, 'login': login}, parent_key=component.get_search_key())
예제 #43
0
    def __init__(self, data, server=None):
        if not data:
            raise "Must set data for the exam"
        self.server = server or TacticServerStub()

        self.data = data
        self.__dict__.update(data)
        self._tags = None
예제 #44
0
    def init(self):
        """
        The special tactic init.

        :return: None
        """
        super(SobjectEditLauncherWdg, self).init()
        self.server = TacticServerStub.get()
예제 #45
0
파일: rsync.py 프로젝트: mincau/TACTIC
 def __init__(self, **kwargs):
     from tactic_client_lib import TacticServerStub
     self.server = TacticServerStub.get()
     self.message_key = kwargs.get("message_key")
     self.paths = kwargs.get("paths")
     self.paths_sizes = kwargs.get("paths_sizes")
     if not self.paths:
         self.paths = []
예제 #46
0
 def __init__(my, **kwargs):
     from tactic_client_lib import TacticServerStub
     my.server = TacticServerStub.get()
     my.message_key = kwargs.get("message_key")
     my.paths = kwargs.get("paths")
     my.paths_sizes = kwargs.get("paths_sizes")
     if not my.paths:
         my.paths = []
예제 #47
0
    def test_all(self):

        self.server = TacticServerStub()
        project_code = "unittest"
        self.server.set_project(project_code)

        self.server.start("Expression Test")
        try:
            self._setup()

            self._test_expression()

        except:
            self.server.abort()
            raise
        else:
            self.server.abort()
예제 #48
0
 def init(my):
     from client.tactic_client_lib import TacticServerStub
     from pyasm.common import Environment
     my.server = TacticServerStub.get()
     my.sk = ''
     my.user = ''
     my.groups = ''
     my.login_group_rates = {}
예제 #49
0
    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
예제 #50
0
    def execute(my):
        base_dir = my.kwargs.get("base_dir")
        relative_dir = my.kwargs.get("relative_dir")
        file_name = my.kwargs.get("file_name")
        to_path = my.kwargs.get("to_path")

        from_path = "%s/./%s/%s" % (base_dir, relative_dir, file_name)

        tries = 1
        success = False
        value = ""
        start = time.time()

        message_key = my.kwargs.get("message_key")

        while 1:
            try:
                value = my.sync_paths(from_path, to_path)
                success = True
                break
            except RSyncConnectionException, e:
                time.sleep(60)

                from tactic_client_lib import TacticServerStub
                server = TacticServerStub.get()
                server.log_message(message_key, {"message": str(e)}, "error_retry")
                continue

            except Exception, e:
                print "Failed on try [%s]..." % tries
                raise

                # ping the server to see

                if message_key:
                    from tactic_client_lib import TacticServerStub
                    server = TacticServerStub.get()
                    server.log_message(message_key, {"message": str(e)}, "error_retry")

                time.sleep(tries)
                if tries == 3:
                    break

                tries += 1
예제 #51
0
    def get_display(self):

        class_name = self.kwargs.get("class_name")
        server_name = self.kwargs.get("server")
        kwargs = self.kwargs.get("kwargs")

        server = TacticServerStub.get(protocol='xmlrpc')
        server.set_server(server_name)
        widget = server.get_widget(class_name, kwargs)
        return widget
예제 #52
0
    def __init__(self):
        self.xml = None
        self.doc = None
        self.root = None

        from tactic_client_lib import TacticServerStub
        self.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        self.util = TacticNodeUtil()
        self.app = Application.get()
예제 #53
0
    def get_display(my):

        alias = my.kwargs.get("alias")

        my.rel_path = my.kwargs.get("rel_path")
        if not my.rel_path:
            from tactic_client_lib import TacticServerStub
            server = TacticServerStub.get(protocol='local')
            my.rel_path = server.get_doc_link(alias)

        if not my.rel_path or my.rel_path == 'none_found':
            #raise TacticException("Help alias [%s] does not exist" % alias)
            layout = DivWdg()
            layout.add(HelpCreateWdg(alias=alias))
            layout.add(HelpDocFilterWdg(alias='main'))
            return layout

        # special condition for plugins path
        if my.rel_path.startswith("/plugins/"):
            plugin_dir = Environment.get_plugin_dir()
            rel_path = my.rel_path.replace("/plugins/", "")
            path = "%s/%s" % (plugin_dir, rel_path)
        elif my.rel_path.startswith("/builtin_plugins/"):
            plugin_dir = Environment.get_builtin_plugin_dir()
            rel_path = my.rel_path.replace("/builtin_plugins/", "")
            path = "%s/%s" % (plugin_dir, rel_path)
        elif my.rel_path.startswith("/assets/"):
            asset_dir = Environment.get_asset_dir()
            rel_path = my.rel_path.replace("/assets/", "")
            path = "%s/%s" % (asset_dir, rel_path)
        else:

            # see if there is an override
            doc_dir = os.environ.get("TACTIC_DOC_DIR")
            if not doc_dir:
                doc_dir = Config.get_value("install", "doc_dir")
            if not doc_dir:
                install_dir = Environment.get_install_dir()
                doc_dir = "%s/doc" % install_dir

            path = "%s/%s" % (doc_dir, my.rel_path)

        html = []
        try:
            f = open(path, 'r')
            count = 0
            for line in f:
                line = my.filter_line(line, count)
                html.append(line)
                count += 1
            f.close()
        except Exception, e:
            print "Error processing: ", e
            html.append("Error processing document: %s<br/><br/>" % str(e))
예제 #54
0
    def __init__(my):
        my.xml = None
        my.doc = None
        my.root = None

        from tactic_client_lib import TacticServerStub
        my.server = TacticServerStub.get()

        # TODO: pull this out of here!!!
        my.util = TacticNodeUtil()
        my.app = Application.get()
예제 #55
0
    def _test_insert_trigger(self):

        # create a db trigger
        sobject = Search.eval(
            "@SOBJECT(sthpw/trigger['event','insert|unittest/person'])",
            single=True)
        if sobject:
            raise Exception(
                'Please delete the insert|unittest/person trigger in sthpw first'
            )
        trigger_sobj = SearchType.create("sthpw/trigger")
        trigger_sobj.set_value("event", "insert|unittest/person")
        trigger_sobj.set_value("class_name",
                               "pyasm.command.command_test.TestInsertHandler")
        trigger_sobj.set_value("description", "Unittest Test Api Handler")
        trigger_sobj.commit()

        search = Search("sthpw/trigger")
        count = search.get_count()

        # use the client api to insert that trigger
        server = TacticServerStub(protocol='xmlrpc')

        server.start("insert trigger test")
        try:
            # create a new person
            search_type = "unittest/person"
            code = "fred"
            search_key = server.build_search_key(search_type, code)

            Container.put("TestApiHandler/search_key", search_key)
            # insert
            data = {'code': code}

            # insert test: if the trigger fails then an exception should be
            # raised ...?
            server.insert(search_type, data)
        finally:
            server.abort()

        trigger_sobj.delete()

        search = Search('sthpw/trigger')
        search.add_filter('event', 'insert|unittest/person')
        trig = search.get_sobject()
        self.assertEquals(trig, None)
예제 #56
0
        def on_update(my, path, data):
            from tactic_client_lib import TacticServerStub
            server = TacticServerStub.get()
            data['path'] = path

            bytes = data.get("bytes")
            my.total_sent += bytes

            print "path: ", path
            print "total: ", my.total_sent

            server.log_message("wow", data)