我的C Win32应用程序应该允许为另一个程序传递一个完整的命令行,例如
myapp.exe /foo /bar "C:\Program Files\Some\App.exe" arg1 "arg 2"
Run Code Online (Sandbox Code Playgroud)
myapp.exe 可能看起来像
int main(int argc, char**argv)
{
int i;
for (i=1; i<argc; ++i) {
if (!strcmp(argv[i], "/foo") {
// handle /foo
} else if (!strcmp(argv[i], "/bar") {
// handle /bar
} else {
// not an option => start of a child command line
break;
}
}
// run the command
STARTUPINFO si;
PROCESS_INFORMATION pi;
// customize the above...
// I want this, but there is no such API! :( …Run Code Online (Sandbox Code Playgroud) 我有一个使用Tomcat 6编写的Web应用程序,我正在尝试使它与Tomcat 7一起工作.在启动期间,应用程序除了其他东西之外,还将其Web服务组件注册到某个远程目录.为此,它需要提供自己的URL.以下(有点天真)方法应该返回webservice URL:
import org.apache.catalina.ServerFactory;
import org.apache.catalina.connector.Connector;
.
.
.
private String getWsUrl(ServletContext context)
throws UnknownHostException, MalformedURLException {
String host = java.net.InetAddress.getLocalHost().getCanonicalHostName();
int port = -1;
for (Connector c : ServerFactory.getServer().findServices()[0].findConnectors()) {
if (c.getProtocol().contains("HTTP")) {
port = c.getPort();
break;
}
}
URL wsURL = new URL("http", host, port, context.getContextPath()
+ C.WEB_SERVICE_PATH /* this is just a constant string */ );
return wsURL.toString();
}
Run Code Online (Sandbox Code Playgroud)
ServerFactory.getServer()事实证明该部分存在问题:org.apache.catalina.ServerFactoryTomcat 7中没有类.有关如何为Tomcat 7重写此内容的任何建议吗?我也很乐意拥有更多可移植的非tomcat特定代码.
NumPy似乎缺乏对3字节和6字节类型的内置支持,aka uint24和uint48.我有一个使用这些类型的大型数据集,并希望将其提供给numpy.我目前做什么(对于uint24):
import numpy as np
dt = np.dtype([('head', '<u2'), ('data', '<u2', (3,))])
# I would like to be able to write
# dt = np.dtype([('head', '<u2'), ('data', '<u3', (2,))])
# dt = np.dtype([('head', '<u2'), ('data', '<u6')])
a = np.memmap("filename", mode='r', dtype=dt)
# convert 3 x 2byte data to 2 x 3byte
# w1 is LSB, w3 is MSB
w1, w2, w3 = a['data'].swapaxes(0,1)
a2 = np.ndarray((2,a.size), dtype='u4')
# 3 LSB
a2[0] = w2 % 256
a2[0] …Run Code Online (Sandbox Code Playgroud)