Skip to content

Instantly share code, notes, and snippets.

@FredrikAugust
Created March 25, 2015 19:28
Show Gist options
  • Save FredrikAugust/80ffa3fa652d7577b22f to your computer and use it in GitHub Desktop.
Save FredrikAugust/80ffa3fa652d7577b22f to your computer and use it in GitHub Desktop.
Check for updated file - Linux GDrive
def fileUpdate(fileNameArray, callback): # I am plannig to have the fileNameArray also contain the full path to the file, as this would make it a lot easier
for fileName in fileNameArray:
os.system("stat {} > editedTime.log".format(fileName))
lastEdited = None
with open("editedTime.log", "r+") as file:
content = file.read()
lastEdited = re.search("(?P<edit>)", content, RE.VERBOSE) # Replace the regular expression with some RegEx that gets the date and time
lastEdited = lastEdited.group('edit')
lastEdited = # Parse the time to a datetime object here
if lastEdited > oldEdited: # Compare the dates using the datetime library, and get the olddate from the database containing info about the files
callback(fileName) # This will update and push the file in the DB and GDrive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment