Shutdown Source VM (PAUSED) on successfull migration + blackened all .py files

This commit is contained in:
ahmadbilalkhalid 2019-12-30 14:35:07 +05:00
commit 9bdf4d2180
31 changed files with 1307 additions and 638 deletions

View file

@ -21,7 +21,8 @@ def sha512sum(file: str):
ELSE:
return None
"""
if not isinstance(file, str): raise TypeError
if not isinstance(file, str):
raise TypeError
try:
output = sp.check_output(["sha512sum", file], stderr=sp.PIPE)
except sp.CalledProcessError as e:
@ -49,23 +50,25 @@ def track_file(file, base_dir):
file_path = pathlib.Path(file).parts[-1]
# Create Entry
entry_key = os.path.join(settings['etcd']['file_prefix'], str(file_id))
entry_key = os.path.join(
settings["etcd"]["file_prefix"], str(file_id)
)
entry_value = {
"filename": file_path,
"owner": owner,
"sha512sum": sha512sum(file),
"creation_date": creation_date,
"size": os.path.getsize(file)
"size": os.path.getsize(file),
}
logger.info("Tracking %s", file)
shared.etcd_client.put(entry_key, entry_value, value_in_json=True)
os.setxattr(file, 'user.utracked', b'True')
os.setxattr(file, "user.utracked", b"True")
def main():
base_dir = settings['storage']['file_dir']
base_dir = settings["storage"]["file_dir"]
# Recursively Get All Files and Folder below BASE_DIR
files = glob.glob("{}/**".format(base_dir), recursive=True)
@ -76,7 +79,7 @@ def main():
untracked_files = []
for file in files:
try:
os.getxattr(file, 'user.utracked')
os.getxattr(file, "user.utracked")
except OSError:
track_file(file, base_dir)
untracked_files.append(file)