我写了一个简单的应用程序,它使用selenium来浏览页面并下载它们的源代码.现在我想让我的应用程序Windows可执行.
我的setup.py档案:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1,
"dll_excludes": ['w9xpopen.exe', 'MSVCP90.dll', 'mswsock.dll', 'powrprof.dll', 'MPR.dll', 'MSVCR100.dll', 'mfc90.dll'],
'compressed': True,"includes":["selenium"],
}
},
windows = [{'script': "main.py", "icon_resources": [(1, "hacker.ico")]}],
zipfile = None
)
Run Code Online (Sandbox Code Playgroud)
我的程序(main.py)(带setup.py文件)位于C:\Documents and Settings\student\Desktop.Py2exe构建我的exe C:\Documents and Settings\student\Desktop\dist.
我复制了两个webdriver.xpi和webdriver_prefs.json文件C:\Documents and Settings\student\Desktop\dist\selenium\webdriver\firefox\,但是在尝试启动我的应用程序时遇到错误:
Traceback (most recent call last):
File "main.py", line 73, in <module>
File "main.py", line 58, in …Run Code Online (Sandbox Code Playgroud) 我使用easy rsa(https://github.com/OpenVPN/easy-rsa)来构建我的小型ca及其客户端/服务器.由于它仅用于学习目的,我正在考虑进行一些自动化.通常我可以创建客户端输入所需的文件:
./easyrsa build-client-full client
但当我需要~500个不同的客户端文件时呢?cp这不是我想要的.
我试着写一个小的bash脚本来帮助自己:
#!/bin/bash
clients=3
pass=randompass
capass=castrongpassword
for i in `seq 1 $clients`
do
./easyrsa build-client-full test$i $pass $pass $capass
done
Run Code Online (Sandbox Code Playgroud)
但它只是"不起作用".当我在终端中构建我的客户端文件时,我必须提供2个客户端密码和ca密码.主要问题是我不知道在脚本中如何传递它 - 这可能吗?我的脚本给了我Ignoring unknown command option:输出.
我使用这一小段代码来了解我的Windows是32位还是64位:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
static int is64bitOS()
{
SYSTEM_INFO si;
GetSystemInfo(&si);
if((si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_IA64)||(si.wProcessorArchitecture & PROCESSOR_ARCHITECTURE_AMD64)==64)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
printf("%d\n", is64bitOS());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我购买并安装了64位版本的Windows 7 - 但是,上面的代码显示0表示我的操作系统是32位...如何处理它?
好吧,我的其他方法,基本上不能正常工作......在我的64位Windows 7上我只看到32位..
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
int getArchType1()
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
switch(sysInfo.wProcessorArchitecture)
{
case 6:
return 64;
case 9:
return 64;
case 0:
return 32;
default:
return -1;
}
}
static char *getArchType2() …Run Code Online (Sandbox Code Playgroud) 假设我有一串firstnames和lastnames,它们可以由两个lastnames组成,例如:
brian molko-olsdal stefan olsdal-molko等
我需要拆分姓氏,但是,我需要先将后一个大写,但我需要将' - '符号保持在合适的位置.现在,我有这样的事情:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == "__main__":
def normalize(name, sign) :
tmplist = []
if name.find(sign) != -1 :
tmp = name.split(sign)
for t in tmp :
t.lower()
for t in tmp :
t = t[0].upper() + t[1:]
tmplist.append(t)
return ' '.join(tmplist)
n1 = 'brian molko-olsdal stefan olsdal-molko'
print normalize(n1, '-')
print normalize(n1, ' ')
Run Code Online (Sandbox Code Playgroud)
生成的字符串应如下所示: Brian Molko-Olsdal Stefan Olsdal-Molko