Merge branch 'ascii-codec-fix' into 'master'
BOM Ascii codec fix See merge request !1
Showing
3 changed files
with
235 additions
and
6 deletions
src/examples/Web.config.xml
0 → 100644
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <!-- | ||
| 4 | For more information on how to configure your ASP.NET application, please visit | ||
| 5 | http://go.microsoft.com/fwlink/?LinkId=169433 | ||
| 6 | --> | ||
| 7 | |||
| 8 | <configuration> | ||
| 9 | <configSections> | ||
| 10 | <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> | ||
| 11 | </configSections> | ||
| 12 | <system.web> | ||
| 13 | <customErrors mode="Off" /> | ||
| 14 | <compilation debug="true" targetFramework="4.0" /> | ||
| 15 | <httpModules> | ||
| 16 | <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> | ||
| 17 | </httpModules> | ||
| 18 | <httpHandlers> | ||
| 19 | <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" /> | ||
| 20 | </httpHandlers> | ||
| 21 | </system.web> | ||
| 22 | <appSettings> | ||
| 23 | <add key="ConfigurationService:Url" value="[[{ConfigurationServiceUrl}]]" /> | ||
| 24 | <add key="Service:Name" value="ServiceProvider:AdsDeliveryPublisherMakesAndModelsMapping" /> | ||
| 25 | <add key="Service:ClientName" value="ServiceClient:AdsDeliveryPublisherMakesAndModelsMapping" /> | ||
| 26 | <add key="ClientSettingsProvider.ServiceUri" value="" /> | ||
| 27 | <add key="Service:TimeOut" value="4000" /> | ||
| 28 | <add key="Service:ThreadPool" value="5" /> | ||
| 29 | <add key="Logger:Revision" value="0" /> | ||
| 30 | <add key="ConfigurationService:LocalConfigurationPath" value="[[{APP_HOME}]]/configurations/" /> | ||
| 31 | </appSettings> | ||
| 32 | <nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 33 | <!-- FOR DEBUGGING internalLogToConsole="true" internalLogLevel="Debug" throwExceptions="true" --> | ||
| 34 | <variable name="logdir" value="/var/log" /> | ||
| 35 | <!--variable name="logdir" value="/home/ubuntu/logs/"/--> | ||
| 36 | <targets> | ||
| 37 | <target xsi:type="File" name="fileLogError" fileName="${logdir}/errors.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/errors.{#}.log" /> | ||
| 38 | <target xsi:type="File" name="fileLogDebug" fileName="${logdir}/debug.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/debug.{#}.log" /> | ||
| 39 | <target xsi:type="File" name="fileLogInfo" fileName="${logdir}/access.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/access.{#}.log" /> | ||
| 40 | <target xsi:type="File" name="standardOutputSource" fileName="${logdir}/stdout.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyyMMddHH" archiveFileName="${logdir}/stdout.{#}.log" keepFileOpen="True" concurrentWrites="False" /> | ||
| 41 | </targets> | ||
| 42 | <rules> | ||
| 43 | <logger name="logs" level="Error" writeTo="fileLogError" /> | ||
| 44 | <logger name="logs" level="Debug" writeTo="fileLogDebug" /> | ||
| 45 | <logger name="logs" level="Info" writeTo="fileLogInfo" /> | ||
| 46 | <logger name="standardOutputLog" level="Error" writeTo="standardOutputSource" /> | ||
| 47 | </rules> | ||
| 48 | </nlog> | ||
| 49 | <system.webServer> | ||
| 50 | <validation validateIntegratedModeConfiguration="false" /> | ||
| 51 | <modules> | ||
| 52 | <remove name="ApplicationInsightsWebTracking" /> | ||
| 53 | <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> | ||
| 54 | </modules> | ||
| 55 | <handlers> | ||
| 56 | <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /> | ||
| 57 | </handlers> | ||
| 58 | </system.webServer> | ||
| 59 | |||
| 60 | <runtime> | ||
| 61 | |||
| 62 | <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
| 63 | |||
| 64 | <dependentAssembly> | ||
| 65 | |||
| 66 | <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
| 67 | |||
| 68 | <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" /> | ||
| 69 | |||
| 70 | </dependentAssembly> | ||
| 71 | |||
| 72 | <dependentAssembly> | ||
| 73 | |||
| 74 | <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
| 75 | |||
| 76 | <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" /> | ||
| 77 | |||
| 78 | </dependentAssembly> | ||
| 79 | |||
| 80 | <dependentAssembly> | ||
| 81 | |||
| 82 | <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> | ||
| 83 | |||
| 84 | <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" /> | ||
| 85 | |||
| 86 | </dependentAssembly> | ||
| 87 | |||
| 88 | <dependentAssembly> | ||
| 89 | |||
| 90 | <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> | ||
| 91 | |||
| 92 | <bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" /> | ||
| 93 | |||
| 94 | </dependentAssembly> | ||
| 95 | |||
| 96 | <dependentAssembly> | ||
| 97 | |||
| 98 | <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" /> | ||
| 99 | |||
| 100 | <bindingRedirect oldVersion="0.0.0.0-2.0.0.668" newVersion="2.0.0.668" /> | ||
| 101 | |||
| 102 | </dependentAssembly> | ||
| 103 | |||
| 104 | </assemblyBinding> | ||
| 105 | |||
| 106 | </runtime> | ||
| 107 | |||
| 108 | <system.data> | ||
| 109 | <DbProviderFactories> | ||
| 110 | <remove invariant="MySql.Data.MySqlClient" /> | ||
| 111 | <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> | ||
| 112 | </DbProviderFactories> | ||
| 113 | </system.data></configuration> | 
src/examples/Web.win.config.xml
0 → 100644
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <!-- | ||
| 4 | For more information on how to configure your ASP.NET application, please visit | ||
| 5 | http://go.microsoft.com/fwlink/?LinkId=169433 | ||
| 6 | --> | ||
| 7 | |||
| 8 | <configuration> | ||
| 9 | <configSections> | ||
| 10 | <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" /> | ||
| 11 | </configSections> | ||
| 12 | <system.web> | ||
| 13 | <customErrors mode="Off" /> | ||
| 14 | <compilation debug="true" targetFramework="4.0" /> | ||
| 15 | <httpModules> | ||
| 16 | <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> | ||
| 17 | </httpModules> | ||
| 18 | <httpHandlers> | ||
| 19 | <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" /> | ||
| 20 | </httpHandlers> | ||
| 21 | </system.web> | ||
| 22 | <appSettings> | ||
| 23 | <add key="ConfigurationService:Url" value="[[{ConfigurationServiceUrl}]]" /> | ||
| 24 | <add key="Service:Name" value="ServiceProvider:AdsDeliveryPublisherMakesAndModelsMapping" /> | ||
| 25 | <add key="Service:ClientName" value="ServiceClient:AdsDeliveryPublisherMakesAndModelsMapping" /> | ||
| 26 | <add key="ClientSettingsProvider.ServiceUri" value="" /> | ||
| 27 | <add key="Service:TimeOut" value="4000" /> | ||
| 28 | <add key="Service:ThreadPool" value="5" /> | ||
| 29 | <add key="Logger:Revision" value="0" /> | ||
| 30 | <add key="ConfigurationService:LocalConfigurationPath" value="[[{APP_HOME}]]/configurations/" /> | ||
| 31 | </appSettings> | ||
| 32 | <nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 33 | <!-- FOR DEBUGGING internalLogToConsole="true" internalLogLevel="Debug" throwExceptions="true" --> | ||
| 34 | <variable name="logdir" value="/var/log" /> | ||
| 35 | <!--variable name="logdir" value="/home/ubuntu/logs/"/--> | ||
| 36 | <targets> | ||
| 37 | <target xsi:type="File" name="fileLogError" fileName="${logdir}/errors.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/errors.{#}.log" /> | ||
| 38 | <target xsi:type="File" name="fileLogDebug" fileName="${logdir}/debug.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/debug.{#}.log" /> | ||
| 39 | <target xsi:type="File" name="fileLogInfo" fileName="${logdir}/access.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-hh" archiveFileName="${logdir}/access.{#}.log" /> | ||
| 40 | <target xsi:type="File" name="standardOutputSource" fileName="${logdir}/stdout.log" layout="${message}$$" archiveEvery="Hour" archiveNumbering="Date" archiveDateFormat="yyyyMMddHH" archiveFileName="${logdir}/stdout.{#}.log" keepFileOpen="True" concurrentWrites="False" /> | ||
| 41 | </targets> | ||
| 42 | <rules> | ||
| 43 | <logger name="logs" level="Error" writeTo="fileLogError" /> | ||
| 44 | <logger name="logs" level="Debug" writeTo="fileLogDebug" /> | ||
| 45 | <logger name="logs" level="Info" writeTo="fileLogInfo" /> | ||
| 46 | <logger name="standardOutputLog" level="Error" writeTo="standardOutputSource" /> | ||
| 47 | </rules> | ||
| 48 | </nlog> | ||
| 49 | <system.webServer> | ||
| 50 | <validation validateIntegratedModeConfiguration="false" /> | ||
| 51 | <modules> | ||
| 52 | <remove name="ApplicationInsightsWebTracking" /> | ||
| 53 | <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> | ||
| 54 | </modules> | ||
| 55 | <handlers> | ||
| 56 | <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /> | ||
| 57 | </handlers> | ||
| 58 | </system.webServer> | ||
| 59 | |||
| 60 | <runtime> | ||
| 61 | |||
| 62 | <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
| 63 | |||
| 64 | <dependentAssembly> | ||
| 65 | |||
| 66 | <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
| 67 | |||
| 68 | <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" /> | ||
| 69 | |||
| 70 | </dependentAssembly> | ||
| 71 | |||
| 72 | <dependentAssembly> | ||
| 73 | |||
| 74 | <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | ||
| 75 | |||
| 76 | <bindingRedirect oldVersion="0.0.0.0-2.6.10.0" newVersion="2.6.10.0" /> | ||
| 77 | |||
| 78 | </dependentAssembly> | ||
| 79 | |||
| 80 | <dependentAssembly> | ||
| 81 | |||
| 82 | <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> | ||
| 83 | |||
| 84 | <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" /> | ||
| 85 | |||
| 86 | </dependentAssembly> | ||
| 87 | |||
| 88 | <dependentAssembly> | ||
| 89 | |||
| 90 | <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> | ||
| 91 | |||
| 92 | <bindingRedirect oldVersion="0.0.0.0-6.9.9.0" newVersion="6.9.9.0" /> | ||
| 93 | |||
| 94 | </dependentAssembly> | ||
| 95 | |||
| 96 | <dependentAssembly> | ||
| 97 | |||
| 98 | <assemblyIdentity name="protobuf-net" publicKeyToken="257b51d87d2e4d67" culture="neutral" /> | ||
| 99 | |||
| 100 | <bindingRedirect oldVersion="0.0.0.0-2.0.0.668" newVersion="2.0.0.668" /> | ||
| 101 | |||
| 102 | </dependentAssembly> | ||
| 103 | |||
| 104 | </assemblyBinding> | ||
| 105 | |||
| 106 | </runtime> | ||
| 107 | |||
| 108 | <system.data> | ||
| 109 | <DbProviderFactories> | ||
| 110 | <remove invariant="MySql.Data.MySqlClient" /> | ||
| 111 | <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> | ||
| 112 | </DbProviderFactories> | ||
| 113 | </system.data></configuration> | 
| ... | @@ -58,23 +58,26 @@ def engine(ifile,ofile,vars): | ... | @@ -58,23 +58,26 @@ def engine(ifile,ofile,vars): | 
| 58 | template_content = open(ifile, "r").read() | 58 | template_content = open(ifile, "r").read() | 
| 59 | template= MyTemplate(template_content) | 59 | template= MyTemplate(template_content) | 
| 60 | 60 | ||
| 61 | #print 'MATCHES:', t.pattern.findall(t.template) | 61 | #print 'MATCHES:', template.pattern.findall(template.template) | 
| 62 | 62 | ||
| 63 | matches = template.pattern.findall(template.template) | 63 | matches = template.pattern.findall(template.template) | 
| 64 | 64 | ||
| 65 | if len(matches): | 65 | if len(matches): | 
| 66 | #print '[ MATCHES ] - ', matches | ||
| 67 | outputText = template.safe_substitute(vars) | 66 | outputText = template.safe_substitute(vars) | 
| 68 | #print "[ TEMPLATING ] - %s "%ifile | 67 | try: | 
| 69 | |||
| 70 | if printit: | 68 | if printit: | 
| 71 | #print "AFTER TEMPLATE:" | ||
| 72 | #print outputText | ||
| 73 | print outputText.encode('ascii', 'ignore') | 69 | print outputText.encode('ascii', 'ignore') | 
| 74 | else: | 70 | else: | 
| 75 | f = open(ofile,'w') | 71 | f = open(ofile,'w') | 
| 76 | f.write(outputText.encode('ascii', 'ignore')) | 72 | f.write(outputText.encode('ascii', 'ignore')) | 
| 77 | f.close() | 73 | f.close() | 
| 74 | except UnicodeDecodeError: | ||
| 75 | if printit: | ||
| 76 | print str(outputText) | ||
| 77 | else: | ||
| 78 | f = open(ofile,'w') | ||
| 79 | f.write(str(outputText)) | ||
| 80 | f.close() | ||
| 78 | 81 | ||
| 79 | 82 | ||
| 80 | 83 | ... | ... | 
- 
Please register or sign in to post a comment
