2014-12-24 2 views
0

여기에 도움이 필요합니다. 오류 파이썬 프로그램까지 SD 카드 테스트

나는 다음과 같은 수행하는 간단한 (흉내) 프로그램을 마련하기 위해 최선을 시도하고있다 :

https://docs.google.com/document/d/1COBL4P6vqf3aVDm4OTJJcq-VDQ8f0TGVwvifJrpqPpE/edit?usp=sharing

불행하게도 내가 프로그래밍과 완전 초보 걸, 내가했던 가장입니다

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 루프없이 실행했지만, 지금은 그냥 무한 루프를 완전히 어리둥절입니다 : 베이직 프로그램은 어쨌든이 모든 내가 지금까지 가지고있다. 모든 도움은 환상적인 감사 일 것입니다!

+0

디버거 사용 방법을 배우면 시간과 시간을 절약 할 수 있습니다. – reggaeguitar

답변

0

관심있는 사람들에게 이것이 완성 된 프로그램의 모습입니다.

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 카드 테스트의 두 세트에서 대략 256 메가 파티션에 기록 2.5 TB있다.