예제 #1
0
 def install(self, vif):
     self.vif = vif
     # voodoo from http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb#Typical_Usage
     util.runcmd('ip link set %s up' % self.devname)
     try:
         util.runcmd('tc qdisc add dev %s ingress' % vif.dev)
     except util.PipeException, e:
         # check if error indicates that ingress qdisc
         # already exists on the vif. If so, ignore it.
         ignoreme = 'RTNETLINK answers: File exists'
         if ignoreme in str(e):
             pass
         else:
             raise e
예제 #2
0
def html2pdf(html_filename, output_filename=None, **options):
    """ Convert a HTML file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not prince_available:
        raise RuntimeError("The external PrinceXML converter isn't available")

    cmd_options = list()
    for k,v in options.items():
        if v is None:
            cmd_options.append('--%s ' % k)
        else:
            cmd_options.append('--%s="%s" ' % (k, v)) 

    if sys.platform == 'win32':
        raise NotImplementedError('No support for PrinceXML on Windows available')
    else:
        cmd = '%s "prince" "%s" %s -o "%s"' % \
              (execution_shell, html_filename, ' '.join(cmd_options), output_filename)
    
    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)
    return dict(output_filename=output_filename,
                status=status,
                output=output)
예제 #3
0
def html2pdf(html_filename, output_filename=None, **options):
    """ Convert a HTML file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not prince_available:
        raise RuntimeError("The external PrinceXML converter isn't available")

    cmd_options = list()
    for k, v in options.items():
        if v is None:
            cmd_options.append('--%s ' % k)
        else:
            cmd_options.append('--%s="%s" ' % (k, v))

    if sys.platform == 'win32':
        raise NotImplementedError(
            'No support for PrinceXML on Windows available')
    else:
        cmd = '%s "prince" "%s" %s -o "%s"' % \
              (execution_shell, html_filename, ' '.join(cmd_options), output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)
    return dict(output_filename=output_filename, status=status, output=output)
예제 #4
0
class IFBBuffer(Netbuf):
    """Capture packets arriving on a VIF using an ingress filter and tc
    mirred action to forward them to an IFB device.
    """

    @staticmethod
    def devclass():
        return 'ifb'

    def install(self, vif):
        self.vif = vif
        # voodoo from http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb#Typical_Usage
        util.runcmd('ip link set %s up' % self.devname)
        try:
            util.runcmd('tc qdisc add dev %s ingress' % vif.dev)
        except util.PipeException, e:
            # check if error indicates that ingress qdisc
            # already exists on the vif. If so, ignore it.
            ignoreme = 'RTNETLINK answers: File exists'
            if ignoreme in str(e):
                pass
            else:
                raise e
        util.runcmd('tc filter add dev %s parent ffff: proto ip pref 10 '
                    'u32 match u32 0 0 action mirred egress redirect '
                    'dev %s' % (vif.dev, self.devname))
예제 #5
0
def html2calibre(html_filename, output_filename=None, cmdopts='', **calibre_options):
    """ Convert a HTML file using calibre """
    
    if not html_filename.endswith('.html'):
        shutil.copy(html_filename, html_filename + '.html')
        html_filename += '.html'

    if not output_filename:
        output_filename = newTempfile(suffix='.epub')

    if not calibre_available:
        raise RuntimeError("The external calibre converter isn't available")

    options = list()
    for k,v in calibre_options.items():
        if v is None:
            options.append('--%s ' % k)
        else:
            options.append('--%s="%s" ' % (k, v)) 

    if sys.platform == 'win32':
        raise NotImplementedError('No support for using Calibre on Windows available')
    else:
        options = ' '.join(options)
        options = options + ' ' + cmdopts
        cmd = '"ebook-convert" "%s" "%s" %s' % (html_filename, output_filename, options)
    
    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)

    return dict(output_filename=output_filename,
                status=status,
                output=output)
예제 #6
0
    def install(self, vif):
        # stopgap hack to set up IMQ for an interface. Wrong in many ways.
        self.vif = vif

        for mod in ['imq', 'ebt_imq']:
            util.runcmd(['modprobe', mod])
        util.runcmd("ip link set %s up" % self.devname)
        util.runcmd("%s -F FORWARD" % self.imqebt)
        util.runcmd("%s -A FORWARD -i %s -j imq --todev %s" % (self.imqebt, vif.dev, self.devname))
예제 #7
0
    def getdevs(self):
        """find all available devices of our device type"""
        ifaces = []
        for line in util.runcmd('ifconfig -a -s').splitlines():
            iface = line.split()[0]
            if iface.startswith(self.netbufclass.devclass()):
                ifaces.append(iface)

        return ifaces
예제 #8
0
    def __init__(self, disk):
        # look up disk, make sure it is tap:buffer, and set up socket
        # to request commits.
        self.ctlfd = None
        self.msgfd = None
        self.is_drbd = False
        self.ackwait = False

        if disk.uname.startswith('tap:remus:') or disk.uname.startswith('tap:tapdisk:remus:'):
            fifo = re.match("tap:.*(remus.*)\|", disk.uname).group(1).replace(':', '_')
            absfifo = os.path.join(self.FIFODIR, fifo)
            absmsgfifo = absfifo + '.msg'

            self.installed = False
            self.ctlfd = open(absfifo, 'w+b')
            self.msgfd = open(absmsgfifo, 'r+b')
        elif disk.uname.startswith('drbd:'):
            #get the drbd device associated with this resource
            drbdres = re.match("drbd:(.*)", disk.uname).group(1)
            drbddev = util.runcmd("drbdadm sh-dev %s" % drbdres).rstrip()

            #check for remus supported drbd installation
            rconf = util.runcmd("drbdsetup %s show" % drbddev)
            if rconf.find('protocol D;') == -1:
                raise ReplicatedDiskException('Remus support for DRBD disks requires the '
                                              'resources to operate in protocol D. Please make '
                                              'sure that you have installed the remus supported DRBD '
                                              'version from git://aramis.nss.cs.ubc.ca/drbd-8.3-remus '
                                              'and enabled protocol D in the resource config')

            #check if resource is in connected state
            cstate = util.runcmd("drbdadm cstate %s" % drbdres).rstrip()
            if cstate != 'Connected':
                raise ReplicatedDiskException('DRBD resource %s is not in connected state!'
                                              % drbdres)

            #open a handle to the resource so that we could issue chkpt ioctls
            self.ctlfd = open(drbddev, 'r')
            self.is_drbd = True
        else:
            raise ReplicatedDiskException('Disk is not replicated: %s' %
                                        str(disk))
예제 #9
0
def html2pdf(html_filename, output_filename=None, **options):
    """ Convert a HTML file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    cmd = 'pisa --encoding utf-8 -d "%s" "%s"' % (html_filename,
                                                  output_filename)
    status, output = runcmd(cmd)

    return dict(output_filename=output_filename, status=0, output=output)
예제 #10
0
def html2pdf(html_filename, output_filename=None, **options):
    """ Convert a HTML file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    cmd = 'pisa --encoding utf-8 -d "%s" "%s"' % (html_filename, output_filename)
    status, output = runcmd(cmd)
    
    return dict(output_filename=output_filename,
                status=0,
                output=output)
예제 #11
0
    def convert(self, fo_filename, output_filename=None):

        if not output_filename:
            output_filename = newTempfile(suffix='.pdf')

        cmd = 'fop -fo "%s" -pdf "%s"' % (fo_filename, output_filename)

        status, output = runcmd(cmd)
        if status != 0:
            raise RuntimeError('Error executing: %s\n\n%s' % (cmd, output))
        log.info("\n")

        return output_filename
예제 #12
0
 def install(self, vif):
     self.vif = vif
     # voodoo from http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb#Typical_Usage
     util.runcmd('ip link set %s up' % self.devname)
     util.runcmd('tc qdisc add dev %s ingress' % vif.dev)
     util.runcmd('tc filter add dev %s parent ffff: proto ip pref 10 '
                 'u32 match u32 0 0 action mirred egress redirect '
                 'dev %s' % (vif.dev, self.devname))
예제 #13
0
def fo2pdf(fo_filename, output_filename=None):
    """ Convert a FO file to PDF using XINC """

    if not output_filename:
        output_filename = newTempfile(suffix=".pdf")

    if not xinc_available:
        raise RuntimeError("The external XINC converter isn't available")

    if sys.platform == "win32":
        cmd = '%s\\bin\\windows\\xinc.exe -fo "%s" -pdf "%s"' % (xinc_home, fo_filename, output_filename)
    else:
        cmd = '"%s/bin/unix/xinc" -fo "%s" -pdf "%s"' % (xinc_home, fo_filename, output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError("Error executing: %s" % cmd, output)
    return dict(output_filename=output_filename, status=status, output=output)
예제 #14
0
def html2pdf(html_filename, output_filename=None, **options):
    """ Convert a HTML file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not pdfreactor_available:
        raise RuntimeError("The external 'pdfreactor' converter isn't available")

    cmd = '%s "pdfreactor" "%s" "%s"' % \
          (execution_shell, html_filename, output_filename)
    
    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)
    return dict(output_filename=output_filename,
                status=status,
                output=output)
예제 #15
0
def fo2pdf(fo_filename, output_filename=None):
    """ Convert a FO file to PDF using XINC """

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not xinc_available:
        raise RuntimeError("The external XINC converter isn't available")

    if sys.platform == 'win32':
        cmd = '%s\\bin\\windows\\xinc.exe -fo "%s" -pdf "%s"' % (
            xinc_home, fo_filename, output_filename)
    else:
        cmd = '"%s/bin/unix/xinc" -fo "%s" -pdf "%s"' % (
            xinc_home, fo_filename, output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)
    return dict(output_filename=output_filename, status=status, output=output)
예제 #16
0
파일: xfc.py 프로젝트: zopyx/zopyx.convert2
def fo2xfc(fo_filename, format="rtf", output_filename=None):
    """ Convert a FO file to some format support 
        through XFC-4.0.
    """

    if not format in ("rtf", "docx", "wml", "odt"):
        raise ValueError("Unsupported format: %s" % format)

    if not output_filename:
        output_filename = newTempfile(suffix=".%s" % format)

    if sys.platform == "win32":
        cmd = '"%s\\fo2%s.bat"  "%s" "%s"' % (xfc_dir, format, fo_filename, output_filename)
    else:
        cmd = '"%s/fo2%s" "%s" "%s"' % (xfc_dir, format, fo_filename, output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError("Error executing: %s" % cmd, output)

    return dict(output_filename=output_filename, status=status, output=output)
예제 #17
0
def fo2pdf(fo_filename, output_filename=None):
    """ Convert a FO file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not fop_available:
        raise RuntimeError("The external FOP converter isn't available")

    if sys.platform == 'win32':
        cmd = '%s\\fop.bat -fo "%s" -pdf "%s"' % (fop_home, fo_filename,
                                                  output_filename)
    else:
        cmd = '%s "%s/fop" -fo "%s" -pdf "%s"' % \
              (execution_shell, fop_home, fo_filename, output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)

    return dict(output_filename=output_filename, status=status, output=output)
예제 #18
0
def fo2pdf(fo_filename, output_filename=None):
    """ Convert a FO file to PDF using FOP"""

    if not output_filename:
        output_filename = newTempfile(suffix='.pdf')

    if not fop_available:
        raise RuntimeError("The external FOP converter isn't available")

    if sys.platform == 'win32':
        cmd = '%s\\fop.bat -fo "%s" -pdf "%s"' % (fop_home, fo_filename, output_filename)
    else:
        cmd = '%s "%s/fop" -fo "%s" -pdf "%s"' % \
              (execution_shell, fop_home, fo_filename, output_filename)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)

    return dict(output_filename=output_filename,
                status=status,
                output=output)
예제 #19
0
def html2calibre(html_filename,
                 output_filename=None,
                 cmdopts='',
                 **calibre_options):
    """ Convert a HTML file using calibre """

    if not html_filename.endswith('.html'):
        shutil.copy(html_filename, html_filename + '.html')
        html_filename += '.html'

    if not output_filename:
        output_filename = newTempfile(suffix='.epub')

    if not calibre_available:
        raise RuntimeError("The external calibre converter isn't available")

    options = list()
    for k, v in calibre_options.items():
        if v is None:
            options.append('--%s ' % k)
        else:
            options.append('--%s="%s" ' % (k, v))

    if sys.platform == 'win32':
        raise NotImplementedError(
            'No support for using Calibre on Windows available')
    else:
        options = ' '.join(options)
        options = options + ' ' + cmdopts
        cmd = '"ebook-convert" "%s" "%s" %s' % (html_filename, output_filename,
                                                options)

    status, output = runcmd(cmd)
    if status != 0:
        raise ConversionError('Error executing: %s' % cmd, output)

    return dict(output_filename=output_filename, status=status, output=output)
예제 #20
0
    def convert(self,
                filename,
                encoding='utf-8',
                tidy=True,
                output_filename=None,
                **kw):
        """ Convert a HTML file stored as 'filename' to
            FO using CSS2XSLFO.
        """

        if tidy:
            filename = tidyhtml(filename,
                                encoding,
                                strip_base=kw.get('strip_base', False))

        if output_filename:
            fo_filename = output_filename
        else:
            fo_filename = newTempfile(suffix='.fo')

        csstoxslfo = os.path.abspath(
            os.path.join(dirname, 'lib', 'csstoxslfo', 'css2xslfo.jar'))
        if not os.path.exists(csstoxslfo):
            raise IOError('%s does not exist' % csstoxslfo)

        cmd = '"%s"' % java + \
              ' -Duser.language=en -Xms256m -Xmx256m -jar "%(csstoxslfo)s" "%(filename)s" -fo "%(fo_filename)s"' % vars()
        for k in kw:
            cmd += ' %s="%s"' % (k, kw[k])

        status, output = runcmd(cmd)
        if status != 0:
            raise ConversionError('Error executing: %s' % cmd, output)

        # remove tidy-ed file
        if tidy:
            os.unlink(filename)

        # remove some stuff from the generated FO file causing
        # some conversion trouble either with XINC or XFC

        E = parse(fo_filename)

        ids_seen = list()
        for node in E.getiterator():
            get = node.attrib.get

            # ensure that ID attributes are unique
            node_id = get('id')
            if node_id is not None:
                if node_id in ids_seen:
                    del node.attrib['id']
                ids_seen.append(node_id)

            for k, v in (('footnote', 'reset'), ('unicode-bidi', 'embed'),
                         ('writing-mode', 'lr-tb'), ('font-selection-strategy',
                                                     'character-by-character'),
                         ('line-height-shift-adjustment',
                          'disregard-shifts'), ('page-break-after', 'avoid'),
                         ('page-break-before', 'avoid'), ('page-break-inside',
                                                          'avoid')):

                value = get(k)
                if value == v:
                    del node.attrib[k]

            for attr in ('margin-left', 'margin-right', 'margin-top',
                         'margin-bottom', 'padding-left', 'padding-right',
                         'padding-top', 'padding-bottom'):

                value = get(attr)
                if value == '0':
                    node.attrib[attr] = '0em'

            if get('page-break-after') == 'always':
                del node.attrib['page-break-after']
                node.attrib['break-after'] = 'page'

            if get('text-transform'):
                del node.attrib['text-transform']

            value = get('white-space')
            if value == 'pre':
                del node.attrib['white-space']
                node.text = '\n' + node.text.lstrip()
                for k, v in {
                        'white-space-treatment': 'preserve',
                        'white-space-collapse': 'false',
                        'wrap-option': 'no-wrap',
                        'linefeed-treatment': 'preserve'
                }.items():
                    node.attrib[k] = v

        fo_text = tostring(E.getroot())
        fo_text = fo_text.replace(
            '<ns0:block ', '<ns0:block margin-top="0" margin-bottom="0" '
        )  # avoid a linebreak through <li><p> (XFC)
        #        fo_text = fo_text.replace('<ns0:block/>', '') # causes a crash with XINC
        fo_text = fo_text.replace(
            '<ns0:block margin-top="0" margin-bottom="0" />', '')

        file(fo_filename, 'wb').write(fo_text)
        return fo_filename
예제 #21
0
 def uninstall(self):
     util.runcmd("%s -F FORWARD" % self.imqebt)
     util.runcmd('ip link set %s down' % self.devname)
예제 #22
0
 def uninstall(self):
     try:
         util.runcmd('tc qdisc del dev %s ingress' % self.vif.dev)
     except util.PipeException, e:
         pass
예제 #23
0
파일: fo.py 프로젝트: zopyx/zopyx.convert2
    def convert(self, filename, encoding="utf-8", tidy=True, output_filename=None, **kw):
        """ Convert a HTML file stored as 'filename' to
            FO using CSS2XSLFO.
        """

        if tidy:
            filename = tidyhtml(filename, encoding, strip_base=kw.get("strip_base", False))

        if output_filename:
            fo_filename = output_filename
        else:
            fo_filename = newTempfile(suffix=".fo")

        csstoxslfo = os.path.abspath(os.path.join(dirname, "lib", "csstoxslfo", "css2xslfo.jar"))
        if not os.path.exists(csstoxslfo):
            raise IOError("%s does not exist" % csstoxslfo)

        cmd = (
            '"%s"' % java
            + ' -Duser.language=en -Xms256m -Xmx256m -jar "%(csstoxslfo)s" "%(filename)s" -fo "%(fo_filename)s"'
            % vars()
        )
        for k in kw:
            cmd += ' %s="%s"' % (k, kw[k])

        status, output = runcmd(cmd)
        if status != 0:
            raise ConversionError("Error executing: %s" % cmd, output)

        # remove tidy-ed file
        if tidy:
            os.unlink(filename)

        # remove some stuff from the generated FO file causing
        # some conversion trouble either with XINC or XFC

        E = parse(fo_filename)

        ids_seen = list()
        for node in E.getiterator():
            get = node.attrib.get

            # ensure that ID attributes are unique
            node_id = get("id")
            if node_id is not None:
                if node_id in ids_seen:
                    del node.attrib["id"]
                ids_seen.append(node_id)

            for k, v in (
                ("footnote", "reset"),
                ("unicode-bidi", "embed"),
                ("writing-mode", "lr-tb"),
                ("font-selection-strategy", "character-by-character"),
                ("line-height-shift-adjustment", "disregard-shifts"),
                ("page-break-after", "avoid"),
                ("page-break-before", "avoid"),
                ("page-break-inside", "avoid"),
            ):

                value = get(k)
                if value == v:
                    del node.attrib[k]

            for attr in (
                "margin-left",
                "margin-right",
                "margin-top",
                "margin-bottom",
                "padding-left",
                "padding-right",
                "padding-top",
                "padding-bottom",
            ):

                value = get(attr)
                if value == "0":
                    node.attrib[attr] = "0em"

            if get("page-break-after") == "always":
                del node.attrib["page-break-after"]
                node.attrib["break-after"] = "page"

            if get("text-transform"):
                del node.attrib["text-transform"]

            value = get("white-space")
            if value == "pre":
                del node.attrib["white-space"]
                node.text = "\n" + node.text.lstrip()
                for k, v in {
                    "white-space-treatment": "preserve",
                    "white-space-collapse": "false",
                    "wrap-option": "no-wrap",
                    "linefeed-treatment": "preserve",
                }.items():
                    node.attrib[k] = v

        fo_text = tostring(E.getroot())
        fo_text = fo_text.replace(
            "<ns0:block ", '<ns0:block margin-top="0" margin-bottom="0" '
        )  # avoid a linebreak through <li><p> (XFC)
        #        fo_text = fo_text.replace('<ns0:block/>', '') # causes a crash with XINC
        fo_text = fo_text.replace('<ns0:block margin-top="0" margin-bottom="0" />', "")

        file(fo_filename, "wb").write(fo_text)
        return fo_filename
예제 #24
0
            # already exists on the vif. If so, ignore it.
            ignoreme = 'RTNETLINK answers: File exists'
            if ignoreme in str(e):
                pass
            else:
                raise e
        util.runcmd('tc filter add dev %s parent ffff: proto ip pref 10 '
                    'u32 match u32 0 0 action mirred egress redirect '
                    'dev %s' % (vif.dev, self.devname))

    def uninstall(self):
        try:
            util.runcmd('tc qdisc del dev %s ingress' % self.vif.dev)
        except util.PipeException, e:
            pass
        util.runcmd('ip link set %s down' % self.devname)

class IMQBuffer(Netbuf):
    """Redirect packets coming in on vif to an IMQ device."""

    imqebt = '/usr/lib/xen/bin/imqebt'

    @staticmethod
    def devclass():
        return 'imq'

    def install(self, vif):
        # stopgap hack to set up IMQ for an interface. Wrong in many ways.
        self.vif = vif

        for mod in ['imq', 'ebt_imq']:
예제 #25
0
파일: fo.py 프로젝트: dnouri/zopyx.convert2
    def convert(self, filename, encoding='utf-8', tidy=True, output_filename=None, **kw):
        """ Convert a HTML file stored as 'filename' to
            FO using CSS2XSLFO.
        """

        if tidy:
            filename = tidyhtml(filename, encoding, strip_base=kw.get('strip_base', False))

        if output_filename:
            fo_filename = output_filename
        else:
            fo_filename = newTempfile(suffix='.fo')

        csstoxslfo = os.path.abspath(os.path.join(dirname, 'lib', 'csstoxslfo', 'css2xslfo.jar'))
        if not os.path.exists(csstoxslfo):
            raise IOError('%s does not exist' % csstoxslfo)
        
        cmd = '"%s"' % java + \
              ' -Duser.language=en -Xms256m -Xmx256m -jar "%(csstoxslfo)s" "%(filename)s" -fo "%(fo_filename)s"' % vars()
        for k in kw:
            cmd += ' %s="%s"' % (k, kw[k])

        status, output = runcmd(cmd)
        if status != 0:
            raise ConversionError('Error executing: %s' % cmd, output)

        # remove tidy-ed file
        if tidy:
            os.unlink(filename)

        # remove some stuff from the generated FO file causing
        # some conversion trouble either with XINC or XFC

        E = parse(fo_filename)

        ids_seen = list()
        for node in E.getiterator():
            get = node.attrib.get

            # ensure that ID attributes are unique
            node_id = get('id')
            if node_id is not None:
                if node_id in ids_seen:
                    del node.attrib['id']
                ids_seen.append(node_id)

            for k, v in (('footnote', 'reset'), 
                         ('unicode-bidi', 'embed'), 
                         ('writing-mode', 'lr-tb'), 
                         ('font-selection-strategy', 'character-by-character'), 
                         ('line-height-shift-adjustment', 'disregard-shifts'), 
                         ('page-break-after', 'avoid'), 
                         ('page-break-before', 'avoid'), 
                         ('page-break-inside', 'avoid')):

                value = get(k)
                if value == v:
                    del node.attrib[k]

            for attr in ('margin-left', 'margin-right', 'margin-top', 'margin-bottom',
                         'padding-left', 'padding-right', 'padding-top', 'padding-bottom'):

                value = get(attr)
                if value == '0':
                    node.attrib[attr] = '0em'

            if get('page-break-after') == 'always':
                del node.attrib['page-break-after']
                node.attrib['break-after'] = 'page'

            if get('text-transform'):
                del node.attrib['text-transform']

            value = get('white-space')
            if value == 'pre':
                del node.attrib['white-space']
                node.text = '\n' + node.text.lstrip()
                for k,v in  {'white-space-treatment' : 'preserve',
                             'white-space-collapse' : 'false',
                             'wrap-option' : 'no-wrap',
                             'linefeed-treatment' : 'preserve' }.items():
                    node.attrib[k] = v
                
        fo_text = tostring(E.getroot())
        fo_text = fo_text.replace('<ns0:block ' , '<ns0:block margin-top="0" margin-bottom="0" ')  # avoid a linebreak through <li><p> (XFC)
#        fo_text = fo_text.replace('<ns0:block/>', '') # causes a crash with XINC    
        fo_text = fo_text.replace('<ns0:block margin-top="0" margin-bottom="0" />', '') 

        file(fo_filename, 'wb').write(fo_text)
        return fo_filename
예제 #26
0
 def uninstall(self):
     util.runcmd('tc filter del dev %s parent ffff: proto ip pref 10 u32' \
                     % self.vif.dev)
     util.runcmd('tc qdisc del dev %s ingress' % self.vif.dev)
     util.runcmd('ip link set %s down' % self.devname)