Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Azure
GitHub Repository: Azure/Azure-Sentinel-Notebooks
Path: blob/master/scenario-notebooks/UserSecurityMetadata/Utils.py
3253 views
1
# -------------------------------------------------------------------------
2
# Copyright (c) Microsoft Corporation. All rights reserved.
3
# Licensed under the MIT License. See License.txt in the project root for
4
# license information.
5
# --------------------------------------------------------------------------
6
import subprocess
7
import datetime
8
9
10
def executeProcess(cmdLine):
11
try:
12
rawoutput = subprocess.check_output(
13
cmdLine, stderr=subprocess.STDOUT).decode().strip()
14
except subprocess.CalledProcessError as exc:
15
raise Exception("Failed Executing cmd : {0}\nReturn Code : {1}\nOutput :{2}".format(
16
" ".join(exc.cmd), exc.returncode, exc.output))
17
return rawoutput
18
19
20
def validatedate(timestr):
21
try:
22
datetime.datetime.strptime(timestr, '%Y-%m-%d')
23
except ValueError:
24
raise ValueError("Incorrect date format, should be yyyy-MM-dd")
25
26