Exemplo n.º 1
0
    def save(self):

        if self.filename == "":
            dump(self.svgelem)
        else:
            print "Creating ", self.filename
            ElementTree.ElementTree(self.svgelem).write(self.filename)
Exemplo n.º 2
0
	def show_xml_tree(self):
		dump(self.xmltree)
Exemplo n.º 3
0
permissions = SubElement(module, "permissions")
permissions.set("clearance","")
p_owner     = SubElement(permissions, "owner").text = "7"
p_everyone  = SubElement(permissions, "everyone")
p_group     = SubElement(permissions, "group")
p_groupname = SubElement(permissions, "groupname")

methodName  = SubElement(module, "methodName").text = mod_name
createdBy   = SubElement(module, "createdBy").text = uname
dateCreated = SubElement(module, "dateCreated").text = runtime
data        = SubElement(module, "data").text = data
lab         = SubElement(module, "lab"). text = labname.split(".")[1]

indent(module)
#dump(module)
mod_str = dump(module)
#ElementTree(module).write(filename, encoding="UTF-8", xml_declaration=True)
#Put file in users s3 bucket. BOOM.

c = boto.connect_s3()
bucket = "cs.user."+uname+".modules"
b = c.create_bucket(bucket)
k = Key(b)
k.key = filename
k.set_contents_from_string(tostring(module, encoding="UTF-8"))

b = c.create_bucket("cloudsuite.data.warehouse")
k = Key(b)
k.key = data
k.set_contents_from_string(mod_data)
logfile.write("bucket == " + bucket +"\n")
Exemplo n.º 4
0
from elementtree.ElementTree import Element, dump

note = Element("note")
to = Element("to")
to.text = "Tove"

note.append(to)
dump(note)
Exemplo n.º 5
0
fieldset    = SubElement(module, "fieldset")
f_legend    = SubElement(fieldset, "legend")

f_element = SubElement(fieldset, "element")
e_type     = SubElement(f_element, "type")
e_name     = SubElement(f_element, "name")
e_value    = SubElement(f_element, "value")
e_desc     = SubElement(f_element, "description")
e_input    = SubElement(f_element, "input")
e_output   = SubElement(f_element, "output")
e_required = SubElement(f_element, "required")
e_default  = SubElement(f_element, "default")
e_selected = SubElement(f_element, "selected")

permissions = SubElement(module, "permissions")
p_owner     = SubElement(permissions, "owner").text = "7"
p_everyone  = SubElement(permissions, "everyone")
p_group     = SubElement(permissions, "group")
p_groupname = SubElement(permissions, "everyone")

methodName  = SubElement(module, "methodName")
createdBy   = SubElement(module, "createdBy")
dateCreated = SubElement(module, "dateCreated")
data        = SubElement(module, "data").text = mod_data

indent(module)
dump(module)
ElementTree(module).write(mod_name+".xml", xml_declaration=True)
#Put file in users s3 bucket. BOOM.

Exemplo n.º 6
0
def process(directory, option, file_out, use_file_out, xml_file, group, verbose, recurse, progress):
    if verbose: print "Inside process..."

    col = commands.getoutput("echo \"$COLUMNS\"")
    try:
        columns = int(col)
    except:
        columns = 60
    pb = progress_bar.pb("Progress: ", "-", columns, sys.stderr)

    tree = ElementTree(file=xml_file)
    elem = tree.getroot()

    if verbose: print "Getting rpm_names"

    rpm_names = get_names_from_dir(directory, recurse, pb, progress)

    if verbose: print "Processing names"

    if option == comps_opt.ERASE:
        """ Handle the ERASE operations """
        for subelem in elem:
            for subsub in subelem:
                p = 0.0
                for subsubsub in subsub:
                    p = p + 1.0
                    if progress:
                        percentage = p / len(subsub)
                        pb.progress(percentage)

                    if subsubsub.tag == 'packagereq' and subsubsub.text in rpm_names:
                        subsub.remove(subsubsub)
                        if verbose: print "Found %s, removing" % subsubsub.text
    elif option == comps_opt.ADD:
        """ Handle the ADD operations """
        text = "<group>\n"
        text += "<id>%s</id>\n" % group
        text += "<name>%s</name>\n" % group
        text += "<packagelist>\n"

        p = 0.0
        for name in rpm_names:
            p = p + 1.0
            if progress:
                percentage = p / len(rpm_names)
                pb.progress(percentage)

            text += "<packagereq type=\"mandatory\">%s</packagereq>\n" % name

        text += "</packagelist>\n"
        text += "</group>\n"
        node = fromstring(text)
        elem.append(node)
    else:
        die("Some unknown error has occured. Neither 'ADD' nor 'ERASE' was specified, somehow")

    if progress: pb.clear()

    if verbose: print "Ending, outputing XML"

    if use_file_out:
        ElementTree(tree).write(file_out)
    else:
        dump(tree)
Exemplo n.º 7
0
 def dump(self):
     print self.response.status_code
     print self.response.content
     if self.et:
         dump(self.et)
Exemplo n.º 8
0
 def show_xml_tree(self):
     dump(self.xmltree)