Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试SD卡直到Python程序失败_Python_Automated Tests_Sd Card - Fatal编程技术网

测试SD卡直到Python程序失败

测试SD卡直到Python程序失败,python,automated-tests,sd-card,Python,Automated Tests,Sd Card,这里急需帮助 我一直在努力制定一个simpleish计划,该计划将承担以下任务: 不幸的是,我是一个完全的编程新手,我所做的最多的是一个基本的程序,所以无论如何,这是我目前为止所拥有的全部: import filecmp import os import shutil count = 0 while (count < 2): if os.listdir ("E:\\Test") ==[]: shutil.copy2("\\Users\Andrew\Desktop\T

这里急需帮助

我一直在努力制定一个simpleish计划,该计划将承担以下任务:

不幸的是,我是一个完全的编程新手,我所做的最多的是一个基本的程序,所以无论如何,这是我目前为止所拥有的全部:

import filecmp
import os
import shutil
count = 0
while (count < 2):
    if os.listdir ("E:\\Test") ==[]:
        shutil.copy2("\\Users\Andrew\Desktop\Test.txt","E:\Test\Test.txt")
        filecmp.cmp("\\Users\Andrew\Desktop\Test.txt","E:\Test\Test.txt")
        count = count + 1
        break
else:
    shutil.rmtree("E:\\Test")
    os.mkdir("E:\\Test")

我在没有While循环的情况下运行了它,但现在我完全困惑了,它只是无限循环。任何帮助都会很棒的,谢谢

对于那些感兴趣的人来说,这就是完成的程序的样子

import filecmp
import os
import shutil
from datetime import datetime
#Imported all of the neccessary items for running the script
count = 0
read = 0
write = 0
copys = 0
fail = 0
delete = 0
data = shutil.disk_usage("E:\\")
free = (data[2])
with open ("\\Users\\Andrew\\Desktop\\SD Card Testing\\Test.txt","wb") as fout:
    fout.write(os.urandom(int(free)))
file = os.path.getsize("\\Users\\Andrew\\Desktop\\SD Card Testing\\Test.txt")
start = datetime.now()
while (fail == 0):
#While the fail count is == 0 then do:
    if os.listdir ("E:\\Test") ==[]:
        read = read + 1
#Check if the Dir is empty
        shutil.copy2("\\Users\\Andrew\\Desktop\\SD Card Testing\\Test.txt","E:\Test\Test.txt")
        copys = copys + 1
        write = write + 1
        print ((file*copys)/(1048576*1024),"GB")
        if filecmp.cmp("\\Users\\Andrew\\Desktop\\SD Card Testing\\Test.txt","E:\Test\Test.txt",shallow=False) == True:
            print(filecmp.cmp("\\Users\\Andrew\\Desktop\\SD Card Testing\\Test.txt","E:\Test\Test.txt",shallow=False))
            read = read + 2
#If the result of the file check is true print
        else:
            fail = fail + 1
            print ("Fail:",fail)
#If the result of the file check is false fail and break
    else:
        shutil.rmtree("E:\\Test")
        delete = delete + 1
        os.mkdir("E:\\Test")
        write = write + 2
        print ("Deletes:",delete)
#If the folder is not empty then remove it and replace
    count = count + 1
    print (count)
    end = datetime.now()
    print ("Duration: {}".format(end-start))
#When the loop breaks print the number of read/writes
print ("Read:",read)
print ("Write:",write)

我相信人们会提供改进建议,但我目前有两套SD卡,大约2.5 TB的测试数据写入256 mB分区。

了解如何使用调试器,它将为您节省数小时的时间