# -*- coding: utf-8 -*- | |
# | |
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
# pylint: disable= no-member, arguments-differ, invalid-name | |
# | |
# Utils for JTVAE | |
import datetime | |
import errno | |
import os | |
def get_timestamp(): | |
return datetime.datetime.now().strftime("%d-%b-%Y-%H:%M:%S") | |
def mkdir_p(path): | |
"""Create a folder for the given path. | |
Parameters | |
---------- | |
path: str | |
Folder to create | |
""" | |
try: | |
os.makedirs(path) | |
print("Created directory {}".format(path)) | |
except OSError as exc: | |
if exc.errno == errno.EEXIST and os.path.isdir(path): | |
print("Directory {} already exists.".format(path)) | |
else: | |
raise | |