forked from RagnarB83/ash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathash_header.py
169 lines (146 loc) · 10.1 KB
/
ash_header.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"""
Functions to print header, footer, logo, inputscript etc.
"""
import time
import os
import sys
import ash.settings_ash
#import ash
from ash.functions.functions_general import ashexit, BC, print_time_tot_color, timingsobject, print_line_with_mainheader, \
print_line_with_subheader1
programversion = "0.9dev"
# ASH footer
def print_footer():
print()
print_time_tot_color(init_time)
def print_timings():
"""
Print timings of each module
"""
print()
print_line_with_subheader1("Total timings of all modules")
timingsobject.print(init_time)
def print_header():
"""
ASH initial output. Used to print header (logo, version etc.), set initial time, print inputscript etc.
"""
# Initializes time
global init_time
init_time = time.time()
#########################################
# Print main header w/wo logo
#########################################
# Getting commit version number from file VERSION (updated by ashpull) inside module dir
try:
with open(os.path.dirname(ash.__file__) + "/VERSION") as f:
git_commit_number = int(f.readline())
except:
git_commit_number = "Unknown"
print(f"{BC.OKGREEN}{'-' * 80}{BC.END}")
print(f"{BC.OKGREEN}{'-' * 80}{BC.END}")
if ash.settings_ash.settings_dict["print_logo"] is True:
print_logo()
else:
print("ASH".center(90))
print(f"{BC.WARNING}A MULTISCALE MODELLING PROGRAM{BC.END}".center(90))
print(f"{BC.WARNING}{BC.BOLD}Version: {programversion}{BC.END}".center(95))
print(f"{BC.WARNING}Git commit version: {git_commit_number}{BC.END}".center(90))
print(f"{BC.OKGREEN}{'-' * 80}{BC.END}")
print(f"{BC.OKGREEN}{'-' * 80}{BC.END}")
print("ASH path:", ash.settings_ash.ashpath)
#Check Python version
pythonversion=(sys.version_info[0],sys.version_info[1],sys.version_info[2])
print("Python version: {}.{}.{}".format(pythonversion[0],pythonversion[1],pythonversion[2]))
print("Python interpreter:", sys.executable)
if pythonversion < (3,6,0):
print("ASH requires Python version 3.6.0 or higher")
ashexit()
print("\nASH Settings after reading defaults and ~/ash_user_settings.ini : ")
print("See https://ash.readthedocs.io/en/latest/basics.html#ash-settings on how to change settings.")
# print(ash.settings_ash.settings_dict)
for key, val in ash.settings_ash.settings_dict.items():
print("\t", key, ": ", val)
print("\nNote: ASH can use ANSI escape sequences for displaying color. Use e.g. less -R to display")
print("To turn on/off escape sequences, set: 'use_ANSI_color = False' in")
print("~/ash_user_settings.ini")
print()
# Print input script unless interactive session or pytest
if ash.settings_ash.settings_dict["print_input"] is True:
if ash.settings_ash.interactive_session is False:
#Ignore if pytest is active
if "pytest" not in sys.modules:
try:
inputfilepath = os.getcwd() + "/" + sys.argv[0]
print("Input script:", inputfilepath)
print(f"{BC.WARNING}{'=' * 80}")
with open(inputfilepath) as f:
for line in f:
print(" >", line, end="")
except:
pass
print(f"{BC.WARNING}{'=' * 80}",BC.END)
print()
def print_logo():
# http://asciiflow.com
# https://textik.com/#91d6380098664f89
# https://www.gridsagegames.com/rexpaint/
ascii_banner = """
▄████████ ▄████████ ▄█ █▄
███ ███ ███ ███ ███ ███
███ ███ ███ █▀ ███ ███
███ ███ ███ ▄███▄▄▄▄███▄▄
▀███████████ ▀███████████ ▀▀███▀▀▀▀███▀
███ ███ ███ ███ ███
███ ███ ▄█ ███ ███ ███
███ █▀ ▄████████▀ ███ █▀
"""
ascii_banner_center = """
▄████████ ▄████████ ▄█ █▄
███ ███ ███ ███ ███ ███
███ ███ ███ █▀ ███ ███
███ ███ ███ ▄███▄▄▄▄███▄▄
▀███████████ ▀███████████ ▀▀███▀▀▀▀███▀
███ ███ ███ ███ ███
███ ███ ▄█ ███ ███ ███
███ █▀ ▄████████▀ ███ █▀
"""
ascii_tree = """
[ ▓ ▒ ╒ ▓
╙█ ▓▓ ▓ -µ ╙▄ ¬ ▓▀
▌∩ ▀█▓▌▄▄▓▓▓▄, ▀▄▓▌ ▓ ▀█ ▌ █ ╓▓Γ ▄▓▀¬
╓Γ╘ % ╙▀▀▀▀▀▓▓▄ ▓▓ █▓,╒ ▀▓ ▓▌ Æ▀▓▓▓ ▄▓▓¬ . ▌
▓ ^█ ▌ ▄ ▀▓▓ ▓▓m ▐▓ ▓▓ ▐▌▓▌▓▀ Å▓▓▓▓▀ ▐ ▐▓ ▄
╘▓▌ \ ▀▓▄▐▓ ▐▓ ▀▓▓▓▓m ▓▌▄▓▓█ ▓┘ ▓▓ ▄█▀▀▓▓▄ ▐▓ ▐▄ j▓ ▓
█ ╙▓ ╙▀▄▄▀▓▓µ ▓ ▄▄▀▀▓▓▓ ▓▓▓Σ▄▓▓▓Γ ▓▓▓▀ █▓▀^▓ ▄▓ ▓ ▐▓ █
▌ ▀▀█,▓▓ ▄╙▀▓▓▓▄▓▌▄▓▌ ▓▓ ▓▓▓▀▓▓▓▓▓ ▓▓▓▓▓▀ ╞ ▓▄▓▀ ╓─ ▓▄ ,▓█▀▀ .▀
▐▄ ▀▓▓ ▓ ▓▓▓▓▓Γ╙▓▄ ▓▓▓▓▓▌▓▓▀▓Γ ▓▓▄▓▓▓▀ ▄ ▓▓▀ ▀ ▐▓▄▓▀ ▄▓
╓┴▀███▓▓▓▄ ▓▓▓ █▓▓▓ ║ ¬▓▓▓▓▓▓▓▓▀ ▓▌ ▐▓▓▓▓ ▄▓▓▓▀ ▄▓██▀▀ ▓▓▄▓█▀Γ
╙▀▓▓▓▓▓▓ ▓▓▓ █▄ ▀▓▓▓▓▓ j▓▄ ▓▓▓▓▓▓▓▓▀ █▓▓▀ ▄▓▓▓▀▐
,▄µ ▀▓▓▓▓▓▄ ▓▓▓ ▓▓▄▓▓▀▓▓▓▓▓▓▓ ▄▓▓▓▓▓▓▓▓▓▓▓▓▀ ▄▓▓▀▀¬
▄▓█▀▀▀▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ²▓▓▓ ▀▓▓▓▓ ▄▓▓▓▓▓▓▀▀▀¬ ▄▓▓▀¬ ▄Φ` ▄` ▓
Σ▀Σ ▄██▀▀Σ ¬▀▓▓▓▓▓▓▓▓ j▓▓▌ ▐▓▓▓▓▓▓▓▓▀ .▓▓▀ ▄▓ ▄▓Γ ▄▄▄▀▀
╒▓ ▀▓▓▓▓▓▄,▓▓▓▓▓▓▓▓▄ ▓▓▓▓▓▓▓▓▓▄, ▓▓▓▄▄▓▓▓█▀▀ ▓▓▀¬
╙⌐ ▄ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▐▀▓▓▓▓▓▓▓▓▓▓▓▓▀▀▓▓▓▓▓▓▓▀
▄█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀▀¬ ▐▀▓▓▓▓▓▓▓▓▓ ▐▀▀▄
▄▀▀▐▓▓▀▐ ¬*▐▀▀▀▀ ▓▓▓▓▓▓▓
╒Γ ▐▓ ▓▓▓▓▓▓▓
Γ ╫ ▓▓▓▓▓▓▓
▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▄
▓▓▓▓▓▓▓▓▓▓▄
,▓▓▓▓▓▓▓▓▓▓▓▓▓▄
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▄▌▌▄▄▄
,▄æ∞▄▄▄█▓▀▀▐¬▐▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄ ▐▀▓▓▓▓▓▀▀▀▀Σ╙
╙Φ¥¥▀▀▀▀ ╒▓ ▄▓█▀▀▓▓▓▓▓▓▓▓▀ ▓▓▓▓▓▓ ▀▓▓▄▄▐▀▀▀▀▀▐▐▀██
▓▌▄▓▓▀ ▓▓▓▓▓▀▀▓▓ ▓▓ ▓▓▓ ▐▀▀█▓▓▌¥4▀▀▀▀▓▓▄
`ΓΦ▀▓▀▐ ▄▄▓▓ ▓▓ ▐▌▓ ▓▓▓ ▓▀▀▓▄ ,▓▓ ▀▀▀▀▀
▄▀, ▄█▀▀ ▓¬ ▓τ ▓ ▐▓ ▓ ▓ ¥ ▓ ▀▌
^ ▓▀ █ ▓▀ ▄█¬ ▐▓ ▌ Γ ▐▓τ* ▀█▄
▓ /Γ ƒ▀ⁿ █ ▓ Γ ╓▀▐⌐ ¬▀²
▓ \ ▀ ╙µ ⌡
└
"""
# print(BC.OKBLUE,ascii_banner3,BC.END)
# print(BC.OKBLUE,ascii_banner2,BC.END)
print(f"{BC.OKGREEN}{ascii_banner_center}{BC.END}")
print(f"{BC.OKGREEN}{ascii_tree}{BC.END}")