Path: blob/master/scenario-notebooks/UserSecurityMetadata/Utils.py
3253 views
# -------------------------------------------------------------------------1# Copyright (c) Microsoft Corporation. All rights reserved.2# Licensed under the MIT License. See License.txt in the project root for3# license information.4# --------------------------------------------------------------------------5import subprocess6import datetime789def executeProcess(cmdLine):10try:11rawoutput = subprocess.check_output(12cmdLine, stderr=subprocess.STDOUT).decode().strip()13except subprocess.CalledProcessError as exc:14raise Exception("Failed Executing cmd : {0}\nReturn Code : {1}\nOutput :{2}".format(15" ".join(exc.cmd), exc.returncode, exc.output))16return rawoutput171819def validatedate(timestr):20try:21datetime.datetime.strptime(timestr, '%Y-%m-%d')22except ValueError:23raise ValueError("Incorrect date format, should be yyyy-MM-dd")242526