我正在使用killableprocess包(构建在子进程之上)来运行进程每当我在脚本中运行"killableprocess.Popen(command)"代码时,我都会收到以下错误:
File "killableprocess.py", line 157, in _execute_child
winprocess.AssignProcessToJobObject(self._job, hp)
File "winprocess.py", line 37, in ErrCheckBool
raise WinError()
WindowsError [error 5] Access is denied
Exception TypeError: "'NoneType' object is not callable" in <bound method AutoHANDLE.__del__ of <AutoHANDLE object at 0x025D42B0>> ignored
Run Code Online (Sandbox Code Playgroud)
但是当我从python交互式控制台(python 2.6)运行它时它工作正常.这可能意味着当我从脚本运行时存在权限问题,但我不知道如何解决它们.我尝试从我以管理员身份运行的cmd运行脚本,但它没有帮助.尝试寻找类似的帖子,但没有找到任何好的解决方案.希望在这里找到一些帮助我在Windows上运行,特别是Windows 7 Ultimate x64,如果有任何帮助的话.
谢谢
有重新创建文件夹的脚本:
# Remove folder (if exists) with all files
if os.path.isdir(str(os.path.realpath('..') + "\\my_folder")):
shutil.rmtree(os.path.realpath('..') + "\\my_folder", ignore_errors=True)
# Create new folder
os.mkdir(os.path.realpath('..') + "\\my_folder")
Run Code Online (Sandbox Code Playgroud)
这几乎总是有效,但在某些情况下(在创建步骤中),我得到了
WindowsError: [Error 5] Access is denied: 'C:\\Path\\To\\my_folder'
Run Code Online (Sandbox Code Playgroud)
什么可能导致此错误,我该如何避免?
我的代码简单如下:
file = 'C:\\Exe\\First Version\\filename.exe'
os.system(file)
Run Code Online (Sandbox Code Playgroud)
当我运行这个程序时,会引发windowserror,找不到指定的文件.我发现问题与"第一版"之间的空白有关.那么我能找到一种绕过这个问题的方法吗?
PS:如果变量'file'将作为arg传递到另一个func中怎么办?
尝试创建将文件夹添加到程序文件中的程序 - 收到此错误:
WindowsError: [Error 5] Access is denied 'C:\\Program Files\\IMP'
Run Code Online (Sandbox Code Playgroud)
这是我的代码
import os, sys, random
numb= 1
x=True
while x==True:
newpath = ((r'C:\Program Files\IMP\folder_%s') % (numb))
if not os.path.exists(newpath):
os.makedirs(newpath)
numb=numb+1
if numb==11:
x=False
Run Code Online (Sandbox Code Playgroud) 我正在研究一个测试用例,我为其创建了一些子目录.但是,我似乎没有权限删除它们.我的UA是管理员帐户(Windows XP).
我第一次尝试:
folder="c:/temp/"
for dir in os.listdir(folder):
os.remove(folder+dir)
Run Code Online (Sandbox Code Playgroud)
然后
folder="c:/temp/"
os.remove(folder+"New Folder")
Run Code Online (Sandbox Code Playgroud)
因为我确定"新文件夹"是空的.但是,在所有情况下,我得到:
Traceback (most recent call last):
File "<string>", line 3, in <module>
WindowsError: [Error 5] Access is denied: 'c:/temp/New Folder'
Run Code Online (Sandbox Code Playgroud)
有人知道出了什么问题吗?
我有一个应用程序托管一些不稳定的第三方代码,我无法在外部进程中控制,以保护我的主应用程序免受它所展示的令人讨厌的错误.我的父进程正在监视另一个进程,并在失败时执行"正确的事情(tm)".
我遇到的问题是,Watson博士仍在检测隔离进程中的崩溃,并在下行过程中附加到进程以进行崩溃转储.这有两个问题:1.显着减慢我检测故障所需的时间,因为在进行故障转储时进程保持活动状态.2.向用户显示恼人的弹出窗口,询问他们是否要将错误报告提交给Microsoft.
显然,我更愿意修复子进程中的错误,但鉴于它不是一个选项,我希望能够有选择地禁用Dr. Watson(以及Vista +中的Windows错误报告).
我在流程中运行了一些自己的代码,然后再转到不受信任的位,所以如果有一个我可以调用的API会影响当前进程,那就没问题了.
我知道:http://support.microsoft.com/default.aspx/kb/188296会禁用Dr.Watson整个机器.我不想这样做,因为它会让我成为一个糟糕的公民,无法在机器范围内进行设置.
我也知道Vista +中的WerSetFlags选项似乎会禁用当前进程的Windows错误报告,但我需要一些能够在早期操作系统版本上禁用Dr.Watson的东西.
我使用该multiprocessing
模块强制执行代码块的超时.看来,对于某些大小的输入,会引发以下错误:
WindowsError: [Error 5] Access is denied
Run Code Online (Sandbox Code Playgroud)
我可以使用以下代码复制此错误.请注意,代码以'467,912,040'完成,但不与'517,912,040'完成.
import multiprocessing, Queue
def wrapper(queue, lst):
lst.append(1)
queue.put(lst)
queue.close()
def timeout(timeout, lst):
q = multiprocessing.Queue(1)
proc = multiprocessing.Process(target=wrapper, args=(q, lst))
proc.start()
try:
result = q.get(True, timeout)
except Queue.Empty:
return None
finally:
proc.terminate()
return result
if __name__ == "__main__":
# lst = [0]*417912040 # this works fine
# lst = [0]*467912040 # this works fine
lst = [0] * 517912040 # this does not
print "List length:",len(lst)
timeout(60*30, lst)
Run Code Online (Sandbox Code Playgroud)
输出(包括错误):
List …
Run Code Online (Sandbox Code Playgroud) 以下是驻留在DLL中的C函数的原型:
extern "C" void__stdcall__declspec(dllexport) ReturnPulse(double*,double*,double*,double*,double*);
Run Code Online (Sandbox Code Playgroud)
在另一个线程中,我询问了如何正确创建并向此函数发送必要的参数.
这是一个主题: 如何用ctypes包装带有多个参数的C函数?
所以我在上面的线程中使用了很好的信息,但是现在我收到了这个错误:WindowsError:exception:access violation writing 0x00001001
我不确定如何继续.我在Windows XP上 - 如果我登录管理员帐户,那会解决问题吗?或者这是Python的内存对象不可变的问题?
谢谢大家!
使用相关Python编辑:
FROGPCGPMonitorDLL = windll.LoadLibrary('C:\Program Files\MesaPhotonics\VideoFROG 7.0\PCGPMonitor.dll')
#Function argument:double* pulse
sizePULSE = 2 ##Manual is super unclear here
pulse = c_double * sizePULSE
ptrpulse = pulse()
#Function argument:double* tdl
sizeTRACE = FROGPCGPMonitorDLL.GetSize()
if sizeTRACE == 0 :
sizeTRACE = 1 #Manually set size to 1 for testing purposes
print "Size of FROG trace is zero. Probably not right."
tdl = c_double*sizeTRACE
ptrtdl = tdl() …
Run Code Online (Sandbox Code Playgroud) 我有以下CostomAction
<Binary Id='ManualsBat' SourceFile='bin\Debug\test.bat' />
<CustomAction
Id="manuals"
BinaryKey="ManualsBat"
ExeCommand="[SourceDir]Manuals "[Agent]Manuals""
Execute="immediate"
Return="check" />
Run Code Online (Sandbox Code Playgroud)
test.bat包含以下几行:
@echo off
echo Hello this a test batch file
pause
mkdir %2
copy %1 %2
Run Code Online (Sandbox Code Playgroud)
基本上要执行的操作是,在运行安装程序时,需要执行批处理文件。批处理文件必须创建一个新目录“ [Agent] Manuals”,并且必须将所有文件从[SourceDir] Manuals复制到[Agent] Manuals。
当我构建.wxs时,当我运行.msi时它不会给出任何错误bur,然后它会在日志文件中抱怨以下内容
错误1721。Windows Installer软件包存在问题。无法完成该安装所需的程序。请与您的支持人员或包装供应商联系。操作:手册,位置:C:\ Windows \ Installer \ MSI1F50.tmp,命令:C:\ dev \ CD \ Agent \ pd \ components \ link \ source \ Link \ Installer \ WiX \ WiX \ bin \ Debug \ Manuals“ D:\ Cam \ city \ Agent \ Manuals
有没有人遇到过这种错误的经验。如果有人可以帮助我解决这个问题,那就太好了。
我正在编写一个脚本来将目录'./itunes和music/F14 /'中的所有.mp3,.m4a和.m4p文件更改为另一个标题.我能够获取文件名,并使用hsaudiotag我可以得到标题标签.但是,当我尝试将文件重命名为title标签时,它会给我错误:
WindowsError: [Error 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
from hsaudiotag import auto
import os
def main():
for filename in os.listdir('./itunes and music/F14/'):
print(filename)
os.rename(filename, filename[2:])
myfile = auto.File('./itunes and music/F14/'+filename)
print(myfile.title)
if filename.endswith(".mp3"):
print('3')
os.rename(filename, myfile.title+".mp3")
elif filename.endswith(".m4a"):
print('4a')
os.rename(filename, myfile.title+".m4a")
elif filename.endswith(".m4p"):
print('4p')
os.rename(filename, myfile.title+".m4p")
main()
Run Code Online (Sandbox Code Playgroud)
所有的打印语句都只是为了调试,它们都正常工作.它只是os.rename()函数.
windowserror ×10
python ×8
ctypes ×1
drwatson ×1
python-2.7 ×1
rename ×1
subprocess ×1
windows ×1
wix ×1