forked from DevPops-Inc/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckDeviceConsoleOnMac.py
More file actions
68 lines (45 loc) · 2.12 KB
/
Copy pathcheckDeviceConsoleOnMac.py
File metadata and controls
68 lines (45 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/python
# check deviceconsole on Mac
import colorama, os, sys, subprocess, traceback
from colorama import Fore, Style
from datetime import datetime
colorama.init()
def checkOsForMac():
print("Started checking operating system at", datetime.now().strftime("%m-%d-%Y %I:%M %p"))
if sys.platform == "darwin":
print(Fore.GREEN + "Operating System: ")
os.system('sw_vers')
print(Style.RESET_ALL, end="")
print("Finished checking operating system at", datetime.now().strftime("%m-%d-%Y %I:%M %p"))
print("")
else:
raise Exception("Sorry but this script only runs on Mac.")
def checkDeviceConsole():
print("\nCheck deviceconsole on Mac.\n")
checkOsForMac()
try:
startDateTime = datetime.now()
print("Started checking deviceconsole at", startDateTime.strftime("%m-%d-%Y %I:%M %p"))
FNULL = open(os.devnull, 'w')
checkAnsibleOnMacOrLinux = subprocess.call(['which', 'brew'], stdout=FNULL)
if checkAnsibleOnMacOrLinux == 0:
print(Fore.GREEN + "deviceconsole is installed."+ Style.RESET_ALL)
os.system('brew --version')
print(Fore.GREEN + "Successfully checked deviceconsole." + Style.RESET_ALL)
finishedDateTime = datetime.now()
print("Finished checking Hombrew at", finishedDateTime.strftime("%m-%d-%Y %I:%M %p"))
duration = finishedDateTime - startDateTime
print("Total execution time: {0} second(s)".format(duration.seconds))
print("")
else:
print(Fore.RED + "deviceconsole is not installed." + Style.RESET_ALL)
finishedDateTime = datetime.now()
print("Finished checking deviceconsole at", finishedDateTime.strftime("%m-%d-%Y %I:%M %p"))
duration = finishedDateTime - startDateTime
print("Total execution time: {0} second(s)".format(duration.seconds))
exit("")
except Exception:
print(Fore.RED + "Failed to check deviceconsole.")
traceback.print_exc()
exit("" + Style.RESET_ALL)
checkDeviceConsole()