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()
Exemple #2
0
    def handle_base_dir(my, base_dir):

        #md5 = my.get_folder_md5(base_dir)
        #print md5
        #if my.last_md5 != None and md5 != my.last_md5:
        #    print "There is a change"
        #my.last_md5 = md5

        diff = my.get_new_dirs(base_dir)
        if not diff:
            return

        # FIXME: there is a memory growth issue.  Batch cleans it up.
        Batch()

        for dirname in diff:

            transaction_code = dirname

            # see if this is encrypted
            if dirname.endswith(".enc") or dirname.endswith(".zip"):
                my.handle_encrypted(base_dir, transaction_code, dirname)

            else:
                my.handle_transaction(base_dir, transaction_code, dirname)
Exemple #3
0
    def test_all(self):
        '''entry point function'''
        self.description = "Checkin unit test"
        self.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()
        self.transaction = Transaction.get(create=True)

        Project.set_project("unittest")

        try:
            #Command.execute_cmd(self)

            # undo the command
            #undo = UndoCmd()
            #undo.execute()
            self.execute()

        finally:
            self.transaction.rollback()
            test_env.delete()
Exemple #4
0
    def test_all(my):
        '''entry point function'''
        my.description = "Checkin unit test"
        my.errors = []

        Batch()

        # FIXME: this is needed for the triggers to be registerd. These
        # triggers have nothing to do with the web
        from pyasm.web import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()

        Project.set_project("unittest")

        try:
            Command.execute_cmd(my)

            # undo the command
            undo = UndoCmd()
            undo.execute()

        finally:
            test_env.delete()
    def test_all(self):
        '''entry point function'''

        Batch(site="demo")

        # Allows for triggers
        from pyasm.web import WebInit
        WebInit().execute()

        # Set up test environment
        from pyasm.unittest import Sample3dEnvironment
        test_env = Sample3dEnvironment(project_code='sample3d')
        Project.set_project("sample3d")
        test_env.create()
        
        # Commit environment setup transaction 
        #transaction = Transaction.get()
        #transaction.commit()
   
        # Get updates - creates shots and tasks
        self.updates = self._get_updates()
        
        try:
            self._test_no_updates()
            self._test_insert()
            self._test_status_change()
            self._test_compare()
            self._test_empty_update()
            #self._test_time()
        finally:
            test_env.delete()
    def test_all(my):
        Batch(project_code='unittest')
        my.security = Environment.get_security()

        my._test_succeed()
        my._test_fail()

        my._test_autocreate()
        my._test_cache()
Exemple #7
0
    def __init__(my, **kwargs):
        my.kwargs = kwargs
        user = my.kwargs.get('user')
        project = my.kwargs.get('project')
        if user and project:
            from pyasm.security import Batch
            Batch(login_code=user, project_code=project)

        my.security = Environment.get_security()
Exemple #8
0
    def index(my):
        Batch()
        # clear the buffer
        #WebContainer.clear_buffer()
        #search = Search("sthpw/queue")
        #table = TableWdg("sthpw/queue")
        #table.set_search(search)
        #return table.get_buffer_display()

        return "Tactic Queue Slave"
Exemple #9
0
    def test_all(my):
        Batch()
        from pyasm.web.web_init import WebInit

        test_env = UnittestEnvironment()
        test_env.create()

        try:
            my._test_complete_trigger()
        finally:
            test_env.delete()
Exemple #10
0
def run_batch(kwargs):
    command = k.get("command")
    kwargs = k.get("kwargs")
    login = k.get("login")
    project_code = k.get("project_code")

    from pyasm.security import Batch
    Batch(project_code=project_code, login_code=login)

    cmd = Common.create_from_class_path(command, kwargs=kwargs)
    Command.execute_cmd(cmd)
Exemple #11
0
    def run(my):

        Batch()
        try:
            my._run()
        finally:
            task = my.kwargs.get("task")
            paths = task.get_paths()
            for path in paths:
                checkin_path = "%s.lock" % path
                if os.path.exists(checkin_path):
                    os.unlink(checkin_path)
Exemple #12
0
def main(site=None):
    #print "Starting Job Queue ..."
    from pyasm.security import Batch
    Batch(site=site)

    JobTask.start(check_interval=0.1, max_jobs_completed=50)
    while 1:
        try:
            time.sleep(1)
        except (KeyboardInterrupt, SystemExit), e:
            print "Exiting ..."
            raise
Exemple #13
0
    def test_all(my):
        Batch()
        from pyasm.web.web_init import WebInit
        WebInit().execute()

        test_env = UnittestEnvironment()
        test_env.create()
        my.transaction = Transaction.get(create=True)
        try:
            my._test_multiple_schema()
        finally:
            my.transaction.rollback()
            Project.set_project('unittest')

            test_env.delete()
Exemple #14
0
    def __init__(my, **kwargs):
        my.kwargs = kwargs
        user = my.kwargs.get('user')
        project = my.kwargs.get('project')

        my.site = my.kwargs.get('site')
        if not my.site:
            # if not explicitly set, keep the site that is current
            my.site = Site.get_site()

        if user and project:
            from pyasm.security import Batch
            Batch(site=my.site, login_code=user, project_code=project)

        my.security = Environment.get_security()
Exemple #15
0
    def run(self):

        task = self.kwargs.get("task")
        site = task.site
        project_code = task.project_code
        Batch(site=site, project_code=project_code)
        try:
            self._run()
        finally:
            task = self.kwargs.get("task")
            paths = task.get_paths()
            task.set_clean(True)
            for path in paths:
                lock_path = "%s.lock" % path
                if os.path.exists(lock_path):
                    os.unlink(lock_path)
            task.set_clean(False)
Exemple #16
0
def main():
    from pyasm.security import Batch
    batch = Batch(login_code='admin')
    scheduler = Scheduler.get()

    task = TestTask(name="cow")
    scheduler.add_interval_task(task, 30)

    task = SystemTask(name="wowowow", command='ls', mode='forked')
    scheduler.add_single_task(task, 5)

    task = SystemTask(name="wowowow", command='ls', mode='forked')
    scheduler.add_single_task(task, 13)

    task = TestTask2(name="cow2")
    time = datetime.time(22,00)
    scheduler.add_daily_task(task, time, weekdays=range(4,7))

    scheduler.start_thread()

    import time
    """
    try:
        time.sleep(5)

        task = TestTask(name="horse")
        scheduler.add_interval_task(task, 5)

        time.sleep(30)

    except KeyboardInterrupt, e:
        print 'stopping'
        #scheduler.stop()
    else:
        scheduler.stop()

    """
    while 1:
        try:
            time.sleep(15)
        except (KeyboardInterrupt, SystemExit), e:
            scheduler.stop()
            break
        else:
            scheduler.stop()
Exemple #17
0
    def _start(name, i):

        Batch()

        # loop continuously
        while 1:

            queue = Queue.get_next_job()

            if queue:
                queue.execute()

            else:
                print "Queue: No jobs available"

                # go to sleep for a while
                DbContainer.remove("sthpw")
                time.sleep(SLEEP_TIME)
    def execute(my):
        Batch()


        # get all of the file servers
        search = Search("sthpw/sync_server")
        search.add_filter("state", "online")
        search.add_filter("sync_mode", "file")
        my.servers = search.get_sobjects()

        my.tasks = []
        for server in my.servers:
            base_dir = server.get_value("base_dir")
            if not base_dir:
                continue

            transaction_dir = "%s/transactions" % base_dir

            ticket = server.get_value("ticket")
            task = WatchFolderTask(base_dir=transaction_dir, ticket=ticket)
            my.tasks.append(task)


        # close all the database connections
        DbContainer.close_all()


        count = 0
        while 1:
            #start = time.time()

            for task in my.tasks:
                try:
                    task.execute()
                except Exception, e:
                    print "WARNING: error executing task:"
                    print "Reported Error: ", str(e)


            #print time.time() - start
            # catch a breather?
            time.sleep(2)
            count += 1
Exemple #19
0
def main():
    from pyasm.security import Batch
    Batch()

    # start up the sync system ...
    print "Starting Transaction Sync Service ..."
    from tactic.command import TransactionQueueManager
    TransactionQueueManager.start()

    # start up the sync system ...
    print "Starting Watch Folder Service ..."
    from tactic.command import WatchServerFolderTask
    WatchServerFolderTask.start()

    while 1:
        try:
            time.sleep(1)
        except (KeyboardInterrupt, SystemExit), e:
            print "Exiting ..."
            raise
Exemple #20
0
def main(options, site=None):
    #print "Starting Job Queue ..."
    from pyasm.security import Batch
    Batch(site=site)

    idx = 0
    if 'index' in options:
        idx = options['index']
        options.pop('index')
    write_pid(idx)


    JobTask.start(
            check_interval=0.1,
            max_jobs_completed=50
    )

    while 1:
        try:
            time.sleep(1)
        except (KeyboardInterrupt, SystemExit), e:
            #print "Exiting ..."
            raise
Exemple #21
0
    def test_all(self):
        Batch()
        from pyasm.web.web_init import WebInit

        test_env = UnittestEnvironment()
        test_env.create()

        try:
            self._test_complete_trigger()
        finally:
            test_env.delete()

            search = Search("sthpw/pipeline")
            search.add_filter("project_code", "unittest")
            pipelines = search.get_sobjects()
            for pipeline in pipelines:
                pipeline.delete()

            search = Search("sthpw/message")
            search.add_filter("project_code", "unittest")
            sobjects = search.get_sobjects()
            for sobject in sobjects:
                sobject.delete()
Exemple #22
0
        for search_key in src_search_keys:
            sobject = SearchKey.get_by_search_key(search_key)

            node = manifest.create_element("sobject")

            # For now, a plugin must contain project specfic entries
            search_type = sobject.get_base_search_type()
            code = sobject.get_value("code")
            manifest.set_attribute(node, "search_type", search_type)
            manifest.set_attribute(node, "code", code)

            #search_key = SearchKey.get_by_sobject(sobject)
            #manifest.set_attribute(node, "search_key", search_key)

            manifest.append_child(top_node, node)

        plugin.set_value("manifest", manifest.to_string() )
        plugin.commit()


if __name__ == '__main__':
    from pyasm.security import Batch
    Batch(project_code='japan')

    mode = 'install'
    main(mode)




Exemple #23
0
    def start(cls):

        print "Running Watch Folder ..."

        # Check whether the user define the drop folder path.
        # Default dop folder path: /tmp/drop
        parser = OptionParser()
        parser.add_option("-p",
                          "--project",
                          dest="project",
                          help="Define the project_name.")
        parser.add_option("-d",
                          "--drop_path",
                          dest="drop_path",
                          help="Define drop folder path")
        parser.add_option("-s",
                          "--search_type",
                          dest="search_type",
                          help="Define search_type.")
        parser.add_option("-P",
                          "--process",
                          dest="process",
                          help="Define process.")
        parser.add_option("-S",
                          "--script_path",
                          dest="script_path",
                          help="Define script_path.")
        parser.add_option(
            "-w",
            "--watch_folder_code",
            dest="watch_folder_code",
            help=
            "Define watch folder code. If no code is used, then it assumed that this process \
				is managed in a standalone script.")
        parser.add_option("-x", "--site", dest="site", help="Define site.")

        parser.add_option("-c",
                          "--handler",
                          dest="handler",
                          help="Define Custom Handler Class.")
        (options, args) = parser.parse_args()

        if options.project != None:
            project_code = options.project
        else:
            raise Exception("No project specified")

        if options.drop_path != None:
            drop_path = options.drop_path
        else:
            tmp_dir = Environment.get_tmp_dir()
            drop_path = "%s/drop" % tmp_dir
        print "    using [%s]" % drop_path
        if not os.path.exists(drop_path):
            os.makedirs(drop_path)

        if options.search_type != None:
            search_type = options.search_type
        else:
            search_type = None

        if options.process != None:
            process = options.process
        else:
            process = 'publish'

        if options.script_path != None:
            script_path = options.script_path
        else:
            script_path = None

        if options.site != None:
            site = options.site
        else:
            site = None

        if options.handler != None:
            handler = options.handler
        else:
            handler = None

        if options.watch_folder_code != None:
            watch_folder_code = options.watch_folder_code
        else:
            watch_folder_code = None
        if watch_folder_code:
            # record pid in watch folder pid file
            pid = os.getpid()
            pid_file = "%s/log/watch_folder.%s" % (Environment.get_tmp_dir(),
                                                   watch_folder_code)
            f = open(pid_file, "w")
            f.write(str(pid))
            f.close()

        Batch(project_code=project_code, site=site)

        task = WatchDropFolderTask(base_dir=drop_path,
                                   site=site,
                                   project_code=project_code,
                                   search_type=search_type,
                                   process=process,
                                   script_path=script_path,
                                   handler=handler,
                                   watch_folder_code=watch_folder_code)

        scheduler = Scheduler.get()
        scheduler.add_single_task(task, delay=1)
        scheduler.start_thread()
        return scheduler
Exemple #24
0
        # create the project
        create_cmd = CreateProjectCmd(
            project_code=my.project_code,
            project_title="Sample 3D")  #, project_type="unittest")
        create_cmd.execute()

        # install the unittest plugin
        installer = PluginInstaller(relative_dir="TACTIC/internal/sample3d",
                                    verbose=False)
        installer.execute()

        # add 30 shots
        for x in xrange(30):
            shot = SearchType.create("prod/shot")
            shot.set_value('name', 'shot%s' % x)
            shot.set_value('sequence_code', 'SEQ_01')
            shot.commit(triggers=False)

        seq = SearchType.create("prod/sequence")
        seq.set_value('code', 'SEQ_01')
        seq.commit(triggers=False)


if __name__ == '__main__':
    Batch(project_code="unittest")

    cmd = UnittestEnvironment()
    cmd.create()

    #cmd.delete()
    sobj.set_value('process', 'TEST')
    sobj.set_value('note', '123')
    sobj.commit()

    sobj.set_value('note', 'new note')
    sobj.commit()

    # check change_timestamp
    change_t = Search.eval(
        "@SOBJECT(sthpw/change_timestamp['search_type','sthpw/note']['search_code','%s'])"
        % sobj.get_code(),
        single=True)
    if change_t:
        change_t_timestamp = change_t.get('timestamp')
        change_t_timestamp = parser.parse(change_t_timestamp)

        from pyasm.common import SPTDate
        now = SPTDate.now()

        diff = now - change_t_timestamp
        # should be roughly the same minute, not hours apart
        print "Change timestamp diff is ", diff.seconds


if __name__ == '__main__':
    from pyasm.security import Batch
    Batch(site="vfx_test", project_code="vfx")

    main()
    #test_time()
Exemple #26
0
import tacticenv

from pyasm.security import Batch

Batch(project_code='admin')

from pyasm.common import Config
from pyasm.search import Search
from pyasm.command import Command


class RemapCodesCmd(Command):
    def execute(my):

        server = Config.get_value("install", "server")

        search_types = ['sthpw/note', 'sthpw/task']
        prefixes = ["NOTE", "TASK"]

        for j, search_type in enumerate(search_types):

            search = Search(search_type)
            search.add_column("id")
            search.add_column("code")
            sobjects = search.get_sobjects()
            num = len(sobjects)
            print "Found [%s] of %s" % (num, search_type)

            for i, sobject in enumerate(sobjects):
                code = sobject.get_code()
                if code.startswith(server):
Exemple #27
0
 def setUp(self):
     Batch()
     Project.set_project("unittest")
Exemple #28
0
            bin = bins[0]
            code = bin.get_code()
            type = bin.get_value("type")
            label = bin.get_value("label")

            for path in paths:
                if not os.path.exists(path):
                    print "WARNING: path '%s' does not exist" % path
                    continue

                dirname = os.path.dirname(path)
                basename = os.path.basename(path)

                new_dirname = "%s/%s/%s/%s" % (dirname, type, label, code)
                if not os.path.exists(new_dirname):
                    os.makedirs(new_dirname)

                new_path = "%s/%s" % (new_dirname, basename)

                print new_path
                FileUndo.move(path, new_path)


if __name__ == '__main__':

    Batch(login_code="admin")
    Project.set_project("bar")

    cmd = MoveSubmissionCmd()
    Command.execute_cmd(cmd)
Exemple #29
0
                shot.commit()
                count += 1
            else:
                print "[%s] already exists." %shot_code
        print "%d shot(s) created." %count
       
class Usage(Exception):
    def __init__(self, msg):
        self.msg = msg



if __name__ == '__main__':
    
    my_login = '******'
    batch = Batch(login_code=my_login)
    Project.set_project('flash')

    project_code = Project.get_project_code()
    args = sys.argv[1:]

    try:
        if len(args) != 1:
            raise Usage("A single episode code is expected.")
        seq = Episode.get_by_code(args[0])
        if not seq:
            raise Usage("The episode code [%s] has not been registered for "\
                "project [%s] in TACTIC. Please Insert it in the Episodes tab first." %(args[0], project_code))
    except Usage, e:
        print e.msg
        sys.exit(2)
Exemple #30
0
 def setUp(self):
     # start batch environment
     Batch()