Try to figure out how to get lxml to add the namespace

This commit is contained in:
Raoul Snyman 2019-04-25 15:12:10 -07:00
parent 10d421b619
commit 5e0a3a5a49
2 changed files with 10 additions and 11 deletions

View File

@ -103,7 +103,7 @@ from hashlib import md5
from shutil import copy, move, rmtree from shutil import copy, move, rmtree
from lxml.etree import fromstring, tostring from lxml.etree import fromstring, tostring
from lxml.builder import E from lxml.builder import E, ElementMaker
from builder import Builder from builder import Builder
@ -136,6 +136,8 @@ class WindowsBuilder(Builder):
element = E.DirectoryRef(Id='INSTALLDIR') element = E.DirectoryRef(Id='INSTALLDIR')
directories = {start_path: {'__dir__': element}} directories = {start_path: {'__dir__': element}}
components = [] components = []
FxE = ElementMaker(namespace='http://schemas.microsoft.com/wix/FirewallExtension',
nsmap={'fw': 'http://schemas.microsoft.com/wix/FirewallExtension'})
for root, _, files in os.walk(start_dir): for root, _, files in os.walk(start_dir):
parent = os.sep.join(root.replace(os.path.join(start_base, ''), '').split(os.sep)[:-1]) parent = os.sep.join(root.replace(os.path.join(start_base, ''), '').split(os.sep)[:-1])
@ -165,14 +167,12 @@ class WindowsBuilder(Builder):
if 'OpenLP.exe' in source: if 'OpenLP.exe' in source:
description = 'Firewall exception for OpenLP\'s remote interface (UDP)' description = 'Firewall exception for OpenLP\'s remote interface (UDP)'
program = '[#file_e368869eb54b01e2288a3359b1cf51f8]' program = '[#file_e368869eb54b01e2288a3359b1cf51f8]'
component.append(E.FirewallException('fw:FirewallException', component.append(FxE.FirewallException(Id='1797D56F-0AD4-81A6-6011-F8AE0B7CFB4F', Name='OpenLP',
Id='1797D56F-0AD4-81A6-6011-F8AE0B7CFB4F', Name='OpenLP', Description=description, IgnoreFailure='yes',
Description=description, IgnoreFailure='yes', Program=program, Protocol='tcp', Scope='any'))
Program=program, Protocol='tcp', Scope='any')) component.append(FxE.FirewallException(Id='183115E6-A080-964D-4A4F-43880083F189', Name='OpenLP',
component.append(E.FirewallException('fw:FirewallException', Description=description, IgnoreFailure='yes',
Id='183115E6-A080-964D-4A4F-43880083F189', Name='OpenLP', Program=program, Protocol='udp', Scope='any'))
Description=description, IgnoreFailure='yes',
Program=program, Protocol='udp', Scope='any'))
element.append(component) element.append(component)
components.append(component) components.append(component)

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
xmlns:fw="http://schemas.microsoft.com/wix/FirewallExtension">
<?define ProductName="OpenLP"?> <?define ProductName="OpenLP"?>
<?define ProductCode="*"?> <?define ProductCode="*"?>
<?define ProductVersion="%(version)s"?> <?define ProductVersion="%(version)s"?>