コード例 #1
0
ファイル: email_handler.py プロジェクト: CeltonMcGrath/TACTIC
 def _get_file_obj(my, snapshot, type='main'):
     if type:
         xpath = "snapshot/file[@type='%s']" %type
     else:
         xpath = "snapshot/file[@type]"
     xml = snapshot.get_xml_value('snapshot')
     node = xml.get_node(xpath)
     file = None
     if node is not None:
         file_code = Xml.get_attribute(node, "file_code")
         file = File.get_by_code(file_code)
     return file
コード例 #2
0
ファイル: email_handler.py プロジェクト: hellios78/TACTIC
 def _get_file_obj(my, snapshot, type='main'):
     if type:
         xpath = "snapshot/file[@type='%s']" % type
     else:
         xpath = "snapshot/file[@type]"
     xml = snapshot.get_xml_value('snapshot')
     node = xml.get_node(xpath)
     file = None
     if node is not None:
         file_code = Xml.get_attribute(node, "file_code")
         file = File.get_by_code(file_code)
     return file
コード例 #3
0
ファイル: dir_naming.py プロジェクト: davidsouthpaw/TACTIC
    def _init_file_object(my):
        '''initialize the file object. Some fields are still empty before checkin postprocess'''

        # if set externally already, skip and return
        if my._file_object:
            return
        file_type = my.get_file_type()
        if file_type and my.snapshot:
            # get the file_object
            file_code = my.snapshot.get_file_code_by_type(file_type)
            from pyasm.biz import File 
            my._file_object = File.get_by_code(file_code)
コード例 #4
0
    def _init_file_object(self):
        '''initialize the file object. Some fields are still empty before checkin postprocess'''

        # if set externally already, skip and return
        if self._file_object:
            return
        file_type = self.get_file_type()
        if file_type and self.snapshot:
            # get the file_object
            file_code = self.snapshot.get_file_code_by_type(file_type)
            from pyasm.biz import File 
            self._file_object = File.get_by_code(file_code)
コード例 #5
0
ファイル: checkin_test.py プロジェクト: zieglerm/TACTIC
    def _test_inplace_checkin(self):

        # create a new test.txt file
        tmp_dir = Environment.get_tmp_dir()
        dir = "%s/temp" % tmp_dir
        if not os.path.exists(dir):
            os.makedirs(dir)
        file_path = "%s/test_inplace.txt" % dir

        if os.path.exists(file_path):
            os.unlink(file_path)

        file = open(file_path, 'w')
        file.write("whatever")
        file.close()

        # inplace checkin: tell tactic that this is the correct path
        mode = "inplace"
        base_dir = tmp_dir
        context = "inplace"
        checkin = FileCheckin(self.person,
                              file_path,
                              context=context,
                              mode=mode)
        checkin.execute()
        snapshot = checkin.get_snapshot()

        file_code = snapshot.get_file_code_by_type("main")
        file_object = File.get_by_code(file_code)

        relative_dir = file_object.get_value("relative_dir")
        # The relative dir is empty if the file is outside the repository
        self.assertEquals("", relative_dir)

        lib_dir = snapshot.get_lib_dir(file_type="main")
        file_name = snapshot.get_file_name_by_type("main")
        lib_path = "%s/%s" % (lib_dir, file_name)
        self.assertEquals(True, os.path.exists(lib_path))
        self.assertEquals(file_path, lib_path)

        # check in a file alredy in the repository
        asset_dir = Config.get_value("checkin",
                                     "asset_base_dir",
                                     sub_key="default")
        file_path2 = "%s/unittest/text.txt" % asset_dir

        file = open(file_path2, 'w')
        file.write("whatever")
        file.close()

        checkin = FileCheckin(self.person,
                              file_path2,
                              context=context,
                              mode=mode)
        checkin.execute()
        snapshot = checkin.get_snapshot()

        file_code = snapshot.get_file_code_by_type("main")
        file_object = File.get_by_code(file_code)

        # check that the relative dir is as expected
        relative_dir = file_object.get_value("relative_dir")
        self.assertEquals(relative_dir, "unittest")

        # check that the path returned correctly
        lib_path = snapshot.get_path_by_type("main")
        self.assertEquals(file_path2, lib_path)

        if os.path.exists(file_path):
            os.unlink(file_path)
        if os.path.exists(file_path2):
            os.unlink(file_path2)
コード例 #6
0
    def init(self):

        WebContainer.register_cmd("pyasm.widget.AnnotateCbk")

        sobject = self.get_current_sobject()

        if not sobject:
            if not self.__dict__.has_key("search_type"):
                web = WebContainer.get_web()
                self.search_type = web.get_form_value("search_type")
                self.search_id = web.get_form_value("search_id")

            if not self.search_type:
                self.add("No search type")
                return

            search = Search(self.search_type)
            search.add_id_filter(self.search_id)
            sobject = search.get_sobject()

        snapshot = Snapshot.get_latest_by_sobject(sobject)

        # TODO:
        # this is a bit klunky
        snapshot_xml = snapshot.get_xml_value("snapshot")
        file_code = snapshot_xml.get_value(
            "snapshot/file[@type='web']/@file_code")
        file = File.get_by_code(file_code)
        web_dir = snapshot.get_web_dir()
        path = "%s/%s" % (web_dir, file.get_full_file_name())

        # add the annotate js object
        script = HtmlElement.script("annotate = new Annotate()")
        self.add(script)

        # add the image

        self.add("<h3>Image Annotations</h3>")

        width = 600
        img = HtmlElement.img(path)
        img.add_style("position: absolute")
        img.set_id("annotate_image")
        img.add_style("left: 0px")
        img.add_style("top: 0px")
        img.add_style("opacity: 1.0")
        img.add_style("z-index: 1")
        img.add_style("width", width)
        img.add_event("onmouseup", "annotate.add_new(event)")
        self.add(img)

        # test
        version = snapshot.get_value("version")
        if version != 1:
            last_version = version - 1
            snapshot = Snapshot.get_by_version( \
                self.search_type, self.search_id, version=last_version )

            snapshot_xml = snapshot.get_xml_value("snapshot")
            file_code = snapshot_xml.get_value(
                "snapshot/file[@type='web']/@file_code")
            file = File.get_by_code(file_code)
            web_dir = snapshot.get_web_dir()
            path = "%s/%s" % (web_dir, file.get_full_file_name())

            img = HtmlElement.img(path)
            img.set_id("annotate_image_alt")
            img.add_style("position: absolute")
            img.add_style("left: 0px")
            img.add_style("top: 0px")
            img.add_style("opacity: 1.0")
            img.add_style("z-index: 0")
            img.add_style("width", width)
            img.add_event("onmouseup", "annotate.add_new(event)")
            self.add(img)

            #script = HtmlElement.script("align_element('%s','%s')" % \
            #    ("annotate_image", "annotate_image_alt") )
            #self.add(script)

            div = DivWdg()
            div.add_style("position: absolute")
            div.add_style("left: 620")
            div.add_style("top: 300")
            self.add(div)

            button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
            button.add_event("onclick", "annotate.switch_alt()")
            div.add(button)

            button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
            button.add_event("onclick", "annotate.set_opacity()")
            div.add(button)

        # add the new annotation div
        new_annotation_div = DivWdg()
        new_annotation_div.set_id("annotate_msg")
        new_annotation_div.set_class("annotate_new")
        new_annotation_div.add_style("top: 0")
        new_annotation_div.add_style("left: 0")

        title = DivWdg("Enter Annotation:")
        title.add_style("background-color: #000000")
        title.add_style("color: #ffffff")
        new_annotation_div.add(title)

        text = TextAreaWdg("annotate_msg")
        text.set_attr("cols", "30")
        text.set_attr("rows", "3")
        new_annotation_div.add(text)
        new_annotation_div.add("<br/>")
        cancel = ButtonWdg("Cancel")
        cancel.add_style("float: right")
        cancel.add_event("onclick", "toggle_display('annotate_msg')")
        new_annotation_div.add(cancel)
        submit = SubmitWdg("Add Annotation")
        submit.add_style("float: right")

        new_annotation_div.add(submit)

        new_annotation_div.add_style("display: none")
        new_annotation_div.add_style("position: absolute")
        self.add(new_annotation_div)

        # get all of the stored annotations for this image
        search = Search("sthpw/annotation")
        search.add_order_by("login")
        search.add_filter("file_code", file_code)
        annotations = search.get_sobjects()

        # sort by user
        sorted_annotations = {}
        for annotation in annotations:
            user = annotation.get_value("login")

            if not sorted_annotations.has_key(user):
                sorted_annotations[user] = []

            sorted_annotations[user].append(annotation)

        buttons = []
        for user, annotations in sorted_annotations.items():

            button = IconButtonWdg(user, IconWdg.INSERT, True)
            button.add_event(
                "onclick", "annotate.show_marks('%s','%s')" %
                (user, len(annotations) - 1))
            buttons.append(button)

            count = 0
            for annotation in annotations:
                self.add(self.get_annotate_wdg(annotation, count))
                count += 1

        # add the user buttons
        table = Table()
        table.set_class("table")
        table.add_style("width: 0px")
        table.add_style("position: absolute")
        table.add_style("left: 620")
        table.add_style("top: 0")
        table.add_row()

        table.add_header("Annotations")
        for button in buttons:
            table.add_row()
            legend_wdg = DivWdg()
            legend_wdg.set_class("annotate_mark")
            legend_wdg.add_style("position: relative")
            legend_wdg.add("&nbsp;")

            table.add_cell(legend_wdg)

            table.add_cell(button)

        self.add(table)

        # add form elements
        hidden = HiddenWdg("mouse_xpos")
        self.add(hidden)
        hidden = HiddenWdg("mouse_ypos")
        self.add(hidden)
        hidden = HiddenWdg("file_code", file_code)
        self.add(hidden)

        # move the rest below
        self.add("<div style='height:300'>&nbsp</div>")
コード例 #7
0
ファイル: checkin_test.py プロジェクト: mincau/TACTIC
    def _test_inplace_checkin(self):

        # create a new test.txt file
        tmp_dir = Environment.get_tmp_dir()
        dir = "%s/temp" % tmp_dir
        if not os.path.exists(dir):
            os.makedirs(dir)
        file_path = "%s/test_inplace.txt" % dir

        if os.path.exists(file_path):
            os.unlink(file_path)

        file = open(file_path, 'w')
        file.write("whatever")
        file.close() 


        # inplace checkin: tell tactic that this is the correct path
        mode = "inplace"
        base_dir = tmp_dir
        context = "inplace"
        checkin = FileCheckin(self.person, file_path, context=context, mode=mode)
        checkin.execute()
        snapshot = checkin.get_snapshot()

        file_code = snapshot.get_file_code_by_type("main")
        file_object = File.get_by_code(file_code)

        relative_dir = file_object.get_value("relative_dir")
        # The relative dir is empty if the file is outside the repository
        self.assertEquals("", relative_dir)

        lib_dir = snapshot.get_lib_dir(file_type="main")
        file_name = snapshot.get_file_name_by_type("main")
        lib_path = "%s/%s" % (lib_dir, file_name)
        self.assertEquals( True, os.path.exists(lib_path) )
        self.assertEquals( file_path, lib_path)




        # check in a file alredy in the repository
        asset_dir = Config.get_value("checkin", "asset_base_dir", sub_key="default")
        file_path2 = "%s/unittest/text.txt" % asset_dir

        file = open(file_path2, 'w')
        file.write("whatever")
        file.close() 

        checkin = FileCheckin(self.person, file_path2, context=context, mode=mode)
        checkin.execute()
        snapshot = checkin.get_snapshot()

        file_code = snapshot.get_file_code_by_type("main")
        file_object = File.get_by_code(file_code)

        # check that the relative dir is as expected
        relative_dir = file_object.get_value("relative_dir")
        self.assertEquals( relative_dir, "unittest" )

        # check that the path returned correctly
        lib_path = snapshot.get_path_by_type("main")
        self.assertEquals( file_path2, lib_path )

        if os.path.exists(file_path):
            os.unlink(file_path)
        if os.path.exists(file_path2):
            os.unlink(file_path2)
コード例 #8
0
ファイル: annotate_wdg.py プロジェクト: 0-T-0/TACTIC
    def init(my):

        WebContainer.register_cmd("pyasm.widget.AnnotateCbk")

        sobject = my.get_current_sobject()

        if not sobject:
            if not my.__dict__.has_key("search_type"):
                web = WebContainer.get_web()
                my.search_type = web.get_form_value("search_type")
                my.search_id = web.get_form_value("search_id")

            if not my.search_type:
                my.add("No search type")
                return


            search = Search(my.search_type)
            search.add_id_filter(my.search_id)
            sobject = search.get_sobject()


        snapshot = Snapshot.get_latest_by_sobject(sobject)

        # TODO:
        # this is a bit klunky
        snapshot_xml = snapshot.get_xml_value("snapshot")
        file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
        file = File.get_by_code(file_code)
        web_dir = snapshot.get_web_dir()
        path = "%s/%s" % (web_dir, file.get_full_file_name() )


        # add the annotate js object
        script = HtmlElement.script("annotate = new Annotate()")
        my.add(script)


        # add the image

        my.add("<h3>Image Annotations</h3>")

        width = 600
        img = HtmlElement.img(path)
        img.add_style("position: absolute")
        img.set_id("annotate_image")
        img.add_style("left: 0px")
        img.add_style("top: 0px")
        img.add_style("opacity: 1.0")
        img.add_style("z-index: 1")
        img.add_style("width", width)
        img.add_event("onmouseup", "annotate.add_new(event)")
        my.add(img)



        # test 
        version = snapshot.get_value("version")
        if version != 1:
            last_version = version - 1
            snapshot = Snapshot.get_by_version( \
                my.search_type, my.search_id, version=last_version )

            snapshot_xml = snapshot.get_xml_value("snapshot")
            file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
            file = File.get_by_code(file_code)
            web_dir = snapshot.get_web_dir()
            path = "%s/%s" % (web_dir, file.get_full_file_name() )

            img = HtmlElement.img(path)
            img.set_id("annotate_image_alt")
            img.add_style("position: absolute")
            img.add_style("left: 0px")
            img.add_style("top: 0px")
            img.add_style("opacity: 1.0")
            img.add_style("z-index: 0")
            img.add_style("width", width)
            img.add_event("onmouseup", "annotate.add_new(event)")
            my.add(img)


            #script = HtmlElement.script("align_element('%s','%s')" % \
            #    ("annotate_image", "annotate_image_alt") )
            #my.add(script)

            div = DivWdg()
            div.add_style("position: absolute")
            div.add_style("left: 620")
            div.add_style("top: 300")
            my.add(div)

            button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
            button.add_event("onclick", "annotate.switch_alt()")
            div.add(button)

            button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
            button.add_event("onclick", "annotate.set_opacity()")
            div.add(button)







        # add the new annotation div
        new_annotation_div = DivWdg()
        new_annotation_div.set_id("annotate_msg")
        new_annotation_div.set_class("annotate_new")
        new_annotation_div.add_style("top: 0")
        new_annotation_div.add_style("left: 0")

        title = DivWdg("Enter Annotation:")
        title.add_style("background-color: #000000")
        title.add_style("color: #ffffff")
        new_annotation_div.add(title)

        text = TextAreaWdg("annotate_msg")
        text.set_attr("cols", "30")
        text.set_attr("rows", "3")
        new_annotation_div.add(text)
        new_annotation_div.add("<br/>")
        cancel = ButtonWdg("Cancel")
        cancel.add_style("float: right")
        cancel.add_event("onclick", "toggle_display('annotate_msg')")
        new_annotation_div.add( cancel )
        submit = SubmitWdg("Add Annotation")
        submit.add_style("float: right")

        new_annotation_div.add( submit )

        new_annotation_div.add_style("display: none")
        new_annotation_div.add_style("position: absolute")
        my.add(new_annotation_div)

        # get all of the stored annotations for this image
        search = Search("sthpw/annotation")
        search.add_order_by("login")
        search.add_filter("file_code", file_code)
        annotations = search.get_sobjects()


        # sort by user
        sorted_annotations = {}
        for annotation in annotations:
            user = annotation.get_value("login")

            if not sorted_annotations.has_key(user):
                sorted_annotations[user] = []

            sorted_annotations[user].append(annotation)


        buttons = []
        for user, annotations in sorted_annotations.items():

            button = IconButtonWdg(user, IconWdg.INSERT, True)
            button.add_event("onclick", "annotate.show_marks('%s','%s')" % (user, len(annotations)-1) )
            buttons.append(button)

            count = 0
            for annotation in annotations:
                my.add( my.get_annotate_wdg(annotation,count) )
                count += 1



        # add the user buttons
        table = Table()
        table.set_class("table")
        table.add_style("width: 0px")
        table.add_style("position: absolute")
        table.add_style("left: 620")
        table.add_style("top: 0")
        table.add_row()

        table.add_header("Annotations")
        for button in buttons:
            table.add_row()
            legend_wdg = DivWdg()
            legend_wdg.set_class("annotate_mark")
            legend_wdg.add_style("position: relative")
            legend_wdg.add("&nbsp;")

            table.add_cell(legend_wdg)

            table.add_cell(button)

        my.add(table)


        # add form elements
        hidden = HiddenWdg("mouse_xpos")
        my.add(hidden)
        hidden = HiddenWdg("mouse_ypos")
        my.add(hidden)
        hidden = HiddenWdg("file_code", file_code)
        my.add(hidden)

        # move the rest below
        my.add("<div style='height:300'>&nbsp</div>")