From: gigaslayer131890 Date: Sun, 14 Feb 2016 23:15:22 +0000 (+0000) Subject: Modified the removeOldHostsFile() function to keep backups of the old hosts file. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=df45003106ce429f42e85d7802ddb6c513f75e16;p=stevenblack-hosts.git Modified the removeOldHostsFile() function to keep backups of the old hosts file. --- diff --git a/updateHostsFile.py b/updateHostsFile.py index 717c0b6b8..89801c42e 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -15,10 +15,12 @@ from __future__ import absolute_import, division, print_function, unicode_litera import os import platform import re +import shutil import string import subprocess import sys import tempfile +import time import glob import argparse # zip files are not used actually, support deleted @@ -353,6 +355,8 @@ def moveHostsFileIntoPlace(finalFile): def removeOldHostsFile(): # hotfix since merging with an already existing hosts file leads to artefacts and duplicates oldFilePath = os.path.join(BASEDIR_PATH, 'hosts') open(oldFilePath, 'a').close() # create if already removed, so remove wont raise an error + backupFilePath = os.path.join(BASEDIR_PATH, 'hosts-{0}'.format(time.strftime("%c"))) + shutil.copyfile(oldFilePath, backupFilePath) # make a backup copy, marking the date in which the list was updated os.remove(oldFilePath) open(oldFilePath, 'a').close() # create new empty hostsfile