我正在尝试将自定义错误页面添加到我的Web应用程序中.到目前为止,我已将此添加到我的web.config文件下的元素:
<customErrors mode="On" >
<error statusCode="404" redirect="~/404.aspx"/>
<error statusCode="500" redirect="~/500.aspx"/>
</customErrors>
Run Code Online (Sandbox Code Playgroud)
这适用于.NET触及的错误,例如包含.aspx扩展名的url.但是,我还希望为网址显示自定义错误,例如www.example.com/dasda
目前,当我请求上面的IIS 7.5这样的页面显示它自己的错误消息.我在元素下添加了这个:
<httpErrors >
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="~/404.aspx" responseMode="ExecuteURL" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" path="~/500.aspx" responseMode="ExecuteURL" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
我认为这会使IIS显示自定义错误页面而不是默认页面,但似乎并非如此.
我知道我可以在IIS中设置自定义错误页面,但对于我的情况来说,理想的解决方案是在web.config中配置它.
我曾尝试加入到这个在Page_Load事件我的自定义错误页的建议在这里:
Response.TrySkipIisCustomErrors = true;
Run Code Online (Sandbox Code Playgroud)
但是它并没有阻止默认的IIS页面显示代替我的自定义错误页面.我也试过这里建议的:
<httpErrors >
<remove statusCode="404" subStatusCode='-1' />
<error statusCode="404" path="~/404.aspx" prefixLanguageFilePath='' responseMode="Redirect" />
<remove statusCode="500" subStatusCode='-1' />
<error statusCode="500" path="~/500.aspx" prefixLanguageFilePath='' responseMode="Redirect" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
但这也没有奏效.
那么有没有办法通过配置web.config文件中的设置来阻止IIS显示默认错误页面?
我使用以下循环创建了一个堆叠的 keras 解码器模型:
# Create the encoder
# Define an input sequence.
encoder_inputs = keras.layers.Input(shape=(None, num_input_features))
# Create a list of RNN Cells, these are then concatenated into a single layer with the RNN layer.
encoder_cells = []
for hidden_neurons in hparams['encoder_hidden_layers']:
encoder_cells.append(keras.layers.GRUCell(hidden_neurons,
kernel_regularizer=regulariser,
recurrent_regularizer=regulariser,
bias_regularizer=regulariser))
encoder = keras.layers.RNN(encoder_cells, return_state=True)
encoder_outputs_and_states = encoder(encoder_inputs)
# Discard encoder outputs and only keep the states. The outputs are of no interest to us, the encoder's job is to create
# a state describing …Run Code Online (Sandbox Code Playgroud) python keras tensorflow recurrent-neural-network gated-recurrent-unit
我有一个简单的控制台应用程序,每天运行(由Windows任务调度程序调用),并依赖于每次运行应用程序时递增的值.为了保持这个值,我选择使用Settings.Settings文件.
所以我有一个带有Scope User的名为RunNumber的整数值,每次应用程序运行完毕时都会递增:
Properties.Settings.Default.RunNumber++;
Properties.Settings.Default.Save();
Run Code Online (Sandbox Code Playgroud)
我选择这个的部分原因是该值也被放入app.config文件中:
<setting name="RunNumber" serializeAs="String">
<value>0</value>
</setting>
Run Code Online (Sandbox Code Playgroud)
这意味着如果RunNumber必须意外增加,它可以在app.config中更改:
<setting name="RunNumber" serializeAs="String">
<value>10</value>
</setting>
Run Code Online (Sandbox Code Playgroud)
我的期望是,下次我的应用程序读取RunNumber的值时,它将采用app.config中设置的值(在本例中为10).这不会发生,而是在下次运行应用程序时,它将使用它最后修改的值,在这种情况下,运行编号将是1而不是我期望的10.
我的应用程序访问RunNumber的值,如下所示:
Properties.Settings.Default.RunNumber
Run Code Online (Sandbox Code Playgroud)
如何在不修改应用程序的情况下更改RunNumber的值?想法是,如果需要将其意外更改为值,我只需修改app.config中的值,而不必更改某些代码并重新部署应用程序.
我正在创建一个构建脚本来自动将我们的 Web 项目发布到测试机器。
我有一个成功执行此操作的 msbuild 脚本,但是当它运行时,它会为解决方案中的每个项目生成一个错误,指出“项目中不存在目标“_WPPCopyWebApplication””。
这是正确的,因为在我的每个项目文件中,我都没有导入包含此功能的相关 .targets 文件。
如果我确实更改了每个项目文件以导入 .targets 文件,那么我会收到每个项目的警告而不是错误,说明
MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets”无法再次导入。
它已经在“MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets (354,3)”中导入。这很可能是构建创作错误。此后续导入将被忽略。
目前,我在构建脚本的顶部导入了相关的 .targets 文件:
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project ="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"/>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets"/>
Run Code Online (Sandbox Code Playgroud)
有没有办法防止出现“_WPPCopyWebApplication”不存在于项目文件中的错误,而不生成警告,指出在我将其添加到每个项目文件后存在重复导入?
如果目标文件是在我的构建脚本顶部导入的,为什么项目需要导入它?
编辑:
我目前正在使用 _WPPCopyWebApplication 这样的:
<Target Name="Publish" >
<RemoveDir Directories="$(OutputFolder)" ContinueOnError="true" />
<MSBuild Projects="myproject.csproj;anotherproject.csproj" Targets="ResolveReferences;_WPPCopyWebApplication" Properties="WebProjectOutputDir=$(OutputFolder);OutDir=$(WebProjectOutputDir)\" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我目前正在尝试使用 statsmodels ARIMA 库实现直接和递归多步骤预测策略,它提出了一些问题。
递归多步预测策略将训练单步模型,预测下一个值,将预测值附加到输入预测方法的外生值的末尾并重复。这是我的递归实现:
def arima_forecast_recursive(history, horizon=1, config=None):
# make list so can add / remove elements
history = history.tolist()
model = ARIMA(history, order=config)
model_fit = model.fit(trend='nc', disp=0)
for i, x in enumerate(history):
yhat = model_fit.forecast(steps=1, exog=history[i:])
yhat.append(history)
return np.array(yhat)
def walk_forward_validation(dataframe, config=None):
n_train = 52 # Give a minimum of 2 forecasting periods to capture any seasonality
n_test = 26 # Test set should be the size of one forecasting horizon
n_records = len(dataframe)
tuple_list = []
for …Run Code Online (Sandbox Code Playgroud) 我想要与 pandas dataframe.fillna('ffill') 方法完全相同的行为,但我不想使用最后一个非 NaN 值,而是想自己选择该值,例如
[NaN, NaN, NaN, 1, 2, 3, 4, 5, NaN, NaN, NaN]
应该成为
[NaN, NaN, NaN, 1, 2, 3, 4, 5, 0, 0, 0]
Run Code Online (Sandbox Code Playgroud)
使用方法调用 df.fillnan(0, 'ffill')。
我可以通过迭代数据帧每行中的每个值来实现此目的,但想知道是否有更优化的方法?
我刚接触Ansible,并使用它来自动配置主从节点群集。
我有一个主机文件分为两个组:
[master]
masternode
[slaves]
slavenode0
slavenode1
Run Code Online (Sandbox Code Playgroud)
我要遍历slaves组,以便用slaves组中位置的索引更新远程计算机上文件中的一行。
当我尝试使用'with_items'或'with_indexed_items'进行此操作时,问题是该文件在slaves组中的每台计算机上都进行了更新,这与slaves组中slavenodes的数量相对应。这意味着每个从节点上的每个文件最终都会插入完全相同的行,只是该文件已更新x次。
所以我想要:
| slave node | filename | line in file |
| slave0 | test | slave index is 0 |
| slave1 | test | slave index is 1 |
Run Code Online (Sandbox Code Playgroud)
我得到的是:
| slave node | filename | line in file |
| slave0 | test | slave index is 1 |
| slave1 | test | slave index is 1 |
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我使用macports在笔记本电脑上安装软件包.我用它来设置和安装python环境(版本2.7).安装python27并使用macports设置python命令指向python27我能够在终端输入:
:~ python
Run Code Online (Sandbox Code Playgroud)
在我的终端会话中正确打开python环境,我可以在其中执行python命令.
当我按照相同的过程使用macports安装python 3.6环境并输入命令时:
:~ python3
Run Code Online (Sandbox Code Playgroud)
正确加载环境,但是如果我尝试在此环境中运行任何命令,例如:
>>> print('Hello')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
>>> print('Hello')
Python(24202,0x7fffc0d003c0) malloc: *** error for object 0x10a78f110:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
Run Code Online (Sandbox Code Playgroud)
这只发生在我使用终端python环境时.对于所有意图和目的,安装运行正常,我能够在我的系统上运行python 3程序和IPython之类的工作正常.这是我在使用macports安装后进入python3终端环境时的一个特定问题.
我想知道,是什么导致这种情况发生,有没有办法解决它?
我尝试过如下命令:
port diagnose
Run Code Online (Sandbox Code Playgroud)
并删除端口,所有相关的端口并重新安装,但我得到完全相同的错误.有没有其他人经历过这个或有解决方案?
我想用 for 循环的每次迭代中计算的值更新我的 matplotlibplot 。我的想法是,我可以实时查看计算了哪些值,并在脚本运行时逐次观察进度迭代。我不想首先迭代循环,存储值,然后执行绘图。
一些示例代码在这里:
from itertools import count
import random
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
def animate(i, x_vals, y_vals):
plt.cla()
plt.plot(x_vals, y_vals)
if __name__ == "__main__":
x_vals = []
y_vals = []
fig = plt.figure()
index = count()
for i in range(10):
print(i)
x_vals.append(next(index))
y_vals.append(random.randint(0, 10))
ani = FuncAnimation(fig, animate, fargs=(x_vals, y_vals))
plt.show()
Run Code Online (Sandbox Code Playgroud)
我在网上看到的大多数示例都处理动画的所有内容都是全局变量的情况,我想避免这种情况。当我使用调试器逐行单步执行代码时,该图形确实出现并且是动画的。当我在没有调试器的情况下运行脚本时,会显示图形,但没有绘制任何内容,并且我可以看到我的循环没有超过第一次迭代,首先等待图形窗口关闭,然后继续。
python ×5
.net ×2
c# ×2
ansible ×1
ansible-2.x ×1
forecast ×1
forecasting ×1
iis-7.5 ×1
keras ×1
macos ×1
macports ×1
matplotlib ×1
msbuild ×1
msbuild-4.0 ×1
msbuild-task ×1
pandas ×1
python-3.x ×1
statsmodels ×1
tensorflow ×1
terminal ×1
time-series ×1
webforms ×1