def moveTextSvg( x, y): e = d.elementXML xml = e.XML[e.pStart:e.pEnd] xml = XMLlib.replaceParm(xml, 'x', '%f' % x ) xml = XMLlib.replaceParm(xml, 'y', '%f' % y ) if e.parms.has_key('transform'): xml = XMLlib.replaceParm(xml, 'transform', "rotate(%s %f,%f)" % (d.textRotation,x,y) ) return e.XML[:e.pStart] + xml + e.XML[e.pEnd:]
def moveTextSvg( x, y, svgTag='g', svgParms=''): e = dimensioning.elementXML xml = e.XML[e.pStart:e.pEnd] xml = XMLlib.replaceParm(xml, 'x', '%f' % x ) xml = XMLlib.replaceParm(xml, 'y', '%f' % y ) if e.parms.has_key('transform'): xml = XMLlib.replaceParm(xml, 'transform', "rotate(%s %f,%f)" % (dimensioning.textRotation,x,y) ) if svgTag == 'g': #then for viewResult newXML = e.XML[:e.pStart] + xml + e.XML[e.pEnd:] else: newXML = u'''<%s %s > %s </%s> ''' % ( svgTag, svgParms, xml, svgTag ) return newXML
def MoveDimensionText( event, referer, elementXML, elementParms, elementViewObject ): d.dimToEdit = elementViewObject d.elementXML = elementXML debugPrint(2, 'moving %s' % elementViewObject.Name) if elementXML.parms.has_key('transform'): transform = elementXML.parms['transform'] t = transform[ XMLlib.findOffset(transform,'rotate(',0): ] d.textRotation = XMLlib.splitMultiSep(t, ', ')[0] debugPrint(3, 'd.textRotation %s' % d.textRotation) else: d.textRotation = None selectionOverlay.hideSelectionGraphicsItems() previewDimension.initializePreview( d, moveTextSvg, placeText )
def __post_steps(self, num): select = { 0: ["SUCCESS", "0", "BLUE"], 1: ["test1", "1", "YELLOW"], 2: ["test2", "2", "RED"] } name = XMLlib.find_nodes(self.tree, "runPostStepsIfResult/name") XMLlib.change_node_text(name, select[num][0]) ordinal = XMLlib.find_nodes(self.tree, "runPostStepsIfResult/ordinal") XMLlib.change_node_text(ordinal, select[num][1]) color = XMLlib.find_nodes(self.tree, "runPostStepsIfResult/color") XMLlib.change_node_text(color, select[num][2])
def write_job_shell(self, name, text, num = 0): ''' name: Job name, 'str' num: post steps num, 'int' text: Execute Shell Script, 'str' ''' xml = self.get_job_config(name) self.tree = XMLlib.read_xml_string(xml) #create add insert hudson node get_postbuilder = XMLlib.find_nodes(self.tree, "postbuilders") if XMLlib.find_nodes(self.tree, "postbuilders/hudson.tasks.Shell") == []: hudson_node = XMLlib.create_node("hudson.tasks.Shell", {}, "") XMLlib.add_child_node(get_postbuilder, hudson_node) #create add insert command node get_hudson = XMLlib.find_nodes(self.tree, "postbuilders/hudson.tasks.Shell") if XMLlib.find_nodes(self.tree, "postbuilders/hudson.tasks.Shell/command") == []: command_node = XMLlib.create_node("command", {}, text) XMLlib.add_child_node(get_hudson, command_node) else: command_node = XMLlib.find_nodes(self.tree, "postbuilders/hudson.tasks.Shell/command") XMLlib.change_node_text(command_node, text) self.__post_steps(num) reconf = XMLlib.print_xml(self.tree) self.reconfig_job(name, reconf.encode("utf-8"))