Created
June 17, 2014 18:29
-
-
Save naitsric/a554f13f40c52bbf0a25 to your computer and use it in GitHub Desktop.
Checker 2 version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlrd, xlwt | |
import time | |
import datetime, time | |
from time import gmtime, strftime | |
import os, sys | |
from xlutils.copy import copy | |
import socket | |
target = "lol.xlsx" | |
result = "lol.xls" | |
av = sys.argv | |
own = "OK" | |
if len(av) > 1: | |
own = av[1].upper() | |
class Backup: | |
def __init__(self, path_excel, own): | |
self.path_excel = path_excel | |
self.own = own | |
self.create_paths_folders() | |
def create_paths_folders(self): | |
try: | |
target = open("logErrores", 'a') | |
workbook = xlrd.open_workbook(self.path_excel) | |
Wtworkbook = copy(workbook) | |
today = datetime.datetime.now() | |
target.write("----------------------------------------------------------------------------------------------\n") | |
target.write("Date revision: "+strftime("%Y%m%d %I %M %S", gmtime())+"\n") | |
target.write("Host revision: "+str(socket.gethostname())+"\n") | |
worksheet = workbook.sheet_by_index(int(today.strftime('%m'))-1) | |
Wtworksheet = Wtworkbook.get_sheet(int(today.strftime('%m'))-1) | |
num_rows = worksheet.nrows | |
for row in range(3,num_rows): | |
file = worksheet.cell_value(row,1).replace("\\","/")+"/"+worksheet.cell_value(row,3) | |
if os.path.isfile(file): | |
if strftime("%Y%m%d", gmtime(os.path.getmtime(file))) == strftime("%Y%m%d", gmtime()): | |
Wtworksheet.write(row,3+int(strftime("%d", gmtime())),self.own) | |
print "Okey: file "+file+str(row)+str(3+int(strftime("%d", gmtime()))) | |
else: | |
Wtworksheet.write(row,3+int(strftime("%d", gmtime())),"OLD") | |
print "Fail: old file "+file | |
target.write("Fail: old file "+file+"\n") | |
else: | |
Wtworksheet.write(row,3+int(strftime("%d", gmtime())),"NO EXIST") | |
print "Fail: file doesn't match "+file | |
target.write("Fail: file doesn't match "+file+"\n") | |
workbook.release_resources() | |
Wtworkbook.save(result) | |
target.close() | |
except Exception, e: | |
print e | |
print "Arranca la verificacion del Backup" | |
Backup(target,own) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment