Indent problem - python

0

Sorry for the silly average consultation. How do I solve the indentation problem on line 54? I know it's a spacing problem, but I can not get that error out. link

import os
from threading import Timer
from os.path import isfile, join, exists
import shutil
import MySQLdb
import time
import datetime
import logging

logging.basicConfig(filename='C:\Users\BetaBrawler\Downloads\Informe\Informe.txt', level=logging.DEBUG,
                    format='%(asctime)s:%(levelname)s:%(message)s')

PATH_TO_WATCH = "C:\Users\BetaBrawler\Downloads"

class FileReader:

    def __init__(self, path = None):
        self.path = path
        self.running = False
        self.timer = None

    def printFilesData(self, files):
        if self.path:
            timestamp = time.strftime("%d-%m-%Y-%H-%M-%S")
            destination = join(self.path, timestamp)
            for index, file in enumerate(files):
             if isfile(join(self.path, file)):
              try:
               conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="watcherservice")
               cur = conn.concusor()
               cur.execute("INSERT INTO detalles (timestamp) VALUES (?)", (timestamp))

    def readAndMoveFile(self, fileData):

        logging.debug("Archivo:%s%s" % (fileData["name"], fileData["data"].read()))

        #El archivo debe ser cerrado para que se mueve
        fileData["data"].close()

        if not exists(fileData["dest"]):
            os.makedirs(fileData["dest"])
        try:
            shutil.move(join(self.path, fileData["name"]), fileData["dest"])
            logging.debug("Archivo \"%s\" movido  \"%s\" ." % (fileData["name"], fileData["dest"]))
        except WindowsError as e:
            logging.warning(e)

    def listFiles(self):
        if self.path:
            return [file for file in os.listdir(self.path)]
        return None

    def stopWatching(self):
        logging.warning("Not watching.")
        self.timer.cancel()

    def complete(self):
        after = self.listFiles()
        added = [file for file in after if not file in self.lock]
        self.printFilesData(added)
        self.lock = after
        self.timer = Timer(5.0, self.complete)
        self.timer.start()

    def startWatching(self):
        if(self.path):
            self.lock = self.listFiles()
            logging.debug("Directorio que se esta observando %s..." % self.path)
            self.printFilesData(self.lock)
            self.timer = Timer(5.0, self.complete)
            self.timer.start()
        else: logging.warning("Ruta sin definir.")

class Main():
    def __init__(self):
        self.reader = FileReader("C:\Users\BetaBrawler\Downloads")
        self.reader.startWatching()

if __name__ == '__main__':

    Main()

    #Debug: Seguimiento mas acusioso
    #Info: Informacion
    #Warning
    #Critical
    
asked by Beta 10.01.2018 в 22:24
source

1 answer

1

If you look from line 46 this is "indented":

def printFilesData(self, files):
    if self.path:
        timestamp = time.strftime("%d-%m-%Y-%H-%M-%S")
        destination = join(self.path, timestamp)
        for index, file in enumerate(files):
            if isfile(join(self.path, file)):
                try:
                    conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="watcherservice")
                    cur = conn.concusor()
                    cur.execute("INSERT INTO detalles (timestamp) VALUES (?)", (timestamp))

    
answered by 12.01.2018 в 01:49