Skip to content

Commit f6ab30b

Browse files
committed
Enh: prepare the rebranding (ง︡’-‘︠)ง
1 parent ee06ad4 commit f6ab30b

File tree

5 files changed

+175
-36
lines changed

5 files changed

+175
-36
lines changed

bin/kunai

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import signal
1313

1414
sys.path.append('.')
1515

16-
from kunai.log import cprint, logger
16+
from kunai.log import cprint, logger, is_tty
1717
from kunai import cli as cli_mod
18-
from kunai.info import VERSION, BANNER
18+
from kunai.info import VERSION, BANNER, TXT_BANNER
1919
from kunai.modulemanager import modulemanager
20+
from kunai.misc.bro_quotes import get_quote
2021
from kunai.defaultpaths import DEFAULT_LOG_DIR, DEFAULT_CFG_FILE
2122

2223
logger.setLevel('WARNING')
@@ -392,7 +393,14 @@ if __name__ == '__main__':
392393

393394
# if just call kunai, we must show the available commands
394395
if len(command_args) == 0:
395-
cprint(BANNER, color='blue')
396+
if is_tty():
397+
cprint(BANNER)
398+
else:
399+
cprint(TXT_BANNER, color='blue')
400+
# Also print some quotes
401+
quote, from_film = get_quote()
402+
cprint(' >> %s (%s)\n' % (quote, from_film), color='grey')
403+
396404
parser.print_help()
397405
CLI.print_list()
398406
sys.exit(0)

kunai/info.py

+72-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,74 @@
1+
# -*- coding: utf-8 -*-
2+
13
VERSION = '0.9b1'
24

3-
BANNER = r'''
4-
___ ___ ___ ___
5-
/__/| /__/\ /__/\ / /\ ___
6-
| |:| \ \:\ \ \:\ / /::\ / /\
7-
| |:| \ \:\ \ \:\ / /:/\:\ / /:/
8-
__| |:| ___ \ \:\ _____\__\:\ / /:/~/::\ /__/::\
9-
/__/\_|:|____ /__/\ \__\:\ /__/::::::::\ /__/:/ /:/\:\ \__\/\:\__
10-
\ \:\/:::::/ \ \:\ / /:/ \ \:\~~\~~\/ \ \:\/:/__\/ \ \:\/\
11-
\ \::/~~~~ \ \:\ /:/ \ \:\ ~~~ \ \::/ \__\::/
12-
\ \:\ \ \:\/:/ \ \:\ \ \:\ /__/:/
13-
\ \:\ \ \::/ \ \:\ \ \:\ \__\/
14-
\__\/ \__\/ \__\/ \__\/
15-
'''
5+
# Generated by figlet -f isometric3 "OpsBro" -w 9999
6+
TXT_BANNER = r'''
7+
___ ___ ___ ___ ___
8+
/ /\ / /\ / /\ _____ / /\ / /\
9+
/ /::\ / /::\ / /:/_ / /::\ / /::\ / /::\
10+
/ /:/\:\ / /:/\:\ / /:/ /\ / /:/\:\ / /:/\:\ / /:/\:\
11+
/ /:/ \:\ / /:/~/:/ / /:/ /::\ / /:/~/::\ / /:/~/:/ / /:/ \:\
12+
/__/:/ \__\:\ /__/:/ /:/ /__/:/ /:/\:\ /__/:/ /:/\:| /__/:/ /:/___ /__/:/ \__\:\
13+
\ \:\ / /:/ \ \:\/:/ \ \:\/:/~/:/ \ \:\/:/~/:/ \ \:\/:::::/ \ \:\ / /:/
14+
\ \:\ /:/ \ \::/ \ \::/ /:/ \ \::/ /:/ \ \::/~~~~ \ \:\ /:/
15+
\ \:\/:/ \ \:\ \__\/ /:/ \ \:\/:/ \ \:\ \ \:\/:/
16+
\ \::/ \ \:\ /__/:/ \ \::/ \ \:\ \ \::/
17+
\__\/ \__\/ \__\/ \__\/ \__\/ \__\/
18+
version: %s
19+
''' % VERSION
20+
21+
BANNER = r'''                            
22+
                            
23+
                            
24+
                            
25+
                            
26+
                            
27+
                            
28+
                            
29+
                            
30+
                            
31+
                            
32+
                            
33+
                            
34+
                            
35+
                            
36+
'''
37+
38+
# Show a cool banner for our Bro
39+
# 7 = reverse
40+
_REVERSE = '\033[7m'
41+
# 1 = bold
42+
_BOLD = '\033[1m'
43+
# 47 = white background
44+
_WHITE_BACK = '\033[74m'
45+
# 94 = blue
46+
_BLUE = '\033[94m'
47+
# 94 = blue
48+
_MAGENTA = '\033[95m'
49+
# 97 = white
50+
_WHITE = '\033[97m'
51+
# 91 = red
52+
_RED = '\033[91m'
53+
# 0 = reset
54+
_RESET = '\033[0m'
55+
56+
# Which line to put the bro title & version
57+
_idx = 5
58+
banner_lines = BANNER.splitlines()
59+
line = banner_lines[_idx].rstrip()
60+
line_before = banner_lines[_idx - 1].rstrip()
61+
line_after = banner_lines[_idx + 1].rstrip()
62+
63+
_OPS = '%s%s%s%sOps%s' % ('', _BOLD, '', _BLUE, _RESET)
64+
_STAR = '%s%s%s%s*%s' % ('', _BOLD, '', _WHITE, _RESET)
65+
_BRO = '%s%s%s%sBro%s' % ('', '', _BOLD, _RED, _RESET)
66+
_title = (u'%s||%s %s%s%s %s||%s Version:%s%s%s' % (_REVERSE, _RESET, _OPS, _STAR, _BRO, _REVERSE, _RESET, _MAGENTA, VERSION, _RESET))
67+
68+
line_before += (u' %s///~~~~~~~~~~~\\\\\\%s' % (_REVERSE, _RESET))
69+
banner_lines[_idx - 1] = line_before
70+
line += (u' %s' % _title)
71+
banner_lines[_idx] = line
72+
line_after += (u' %s\\\\\\~~~~~~~~~~~///%s' % (_REVERSE, _RESET))
73+
banner_lines[_idx + 1] = line_after
74+
BANNER = u'\n'.join(banner_lines)

kunai/misc/bro_quotes.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import random
2+
3+
quotes = [
4+
("Dead or alive, you're coming with me.", 'RoboCop'),
5+
6+
("I never broke the law. I am the law!", 'Judge Dredd'),
7+
8+
("I will look for you, I will find you, and I will kill you.", 'Taken'),
9+
10+
("You've got to ask yourself one question: 'Do I feel lucky?' Well, do ya, punk?", 'Dirty Harry'),
11+
12+
("Yippie-ki-yay, motherf***er.", 'Die Hard'),
13+
14+
("Hasta la vista, baby.", 'Terminator 2: Judgement Day'),
15+
16+
("This is Sparta!", '300'),
17+
18+
("Say hello to my little friend.", 'Scarface'),
19+
20+
("I'll be back.", 'Terminator'),
21+
22+
("Get off my plane!", 'Air Force One'),
23+
24+
("At my signal, unleash hell.", 'Gladiator'),
25+
26+
("If it bleeds, we can kill it.", 'Predator'),
27+
28+
("Come with me if you want to live.", 'Terminator'),
29+
30+
("Let's put a smile on that face.", 'The Dark Knight'),
31+
32+
(" I got all the time in the world. *You* don't, but I do.", 'Man on Fire'),
33+
34+
("I ain't got time to bleed.", 'Predator'),
35+
36+
("Forgiveness is between them and God. It's my job to arrange the meeting.", 'Man on Fire'),
37+
38+
("I could have killed 'em all, I could kill you. In town you're the law, out here it's me. Don't push it. Don't push it or I'll give you a war you won't believe. Let it go. Let it go.", 'Rambo'),
39+
40+
("I'll make him an offer he can't refuse.", 'The Godfather'),
41+
42+
("Remember Sully when I promised to kill you last? I lied.", 'Commando'),
43+
44+
("None of you understand. I'm not locked up in here with you. You're locked up in here with me.", 'Watchmen'),
45+
46+
("I have come here to chew bubble gum and kick ass...and I'm all out of bubble gum.", 'They Live'),
47+
48+
("Mongol General: What is best in life? Conan: To crush your enemies, to see them driven before you, and to hear the lamentations of their women!", 'Conan'),
49+
50+
("Don't let your mouth get your ass in trouble.", 'Shaft'),
51+
52+
("Imagine the future, Chains, 'cause you're not in it.", 'Stone Cold'),
53+
54+
("You're a disease... And I'm the cure.", 'Cobra'),
55+
]
56+
57+
58+
def get_quote():
59+
return random.sample(quotes, 1)[0]

setup.py

+32-20
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def unhook_stdout():
7272
global stderr_redirect
7373
# If we have something in the file descriptor 2, reinject into stderr
7474
stderr_redirect.close()
75-
#with open(stderr_redirect_path, 'r') as f:
75+
# with open(stderr_redirect_path, 'r') as f:
7676
# stdout_catched.write(f.read())
7777
sys.stdout = stdout_orig
7878
sys.stderr = stderr_orig
@@ -130,8 +130,9 @@ def _error(msg):
130130
# Now look at loading the local kunai lib for version and banner
131131
my_dir = os.path.dirname(os.path.abspath(__file__))
132132
kunai = imp.load_module('kunai', *imp.find_module('kunai', [os.path.realpath(my_dir)]))
133-
from kunai.info import VERSION, BANNER
134-
from kunai.log import cprint
133+
from kunai.info import VERSION, BANNER, TXT_BANNER
134+
from kunai.log import cprint, is_tty
135+
from kunai.misc.bro_quotes import get_quote
135136
from kunai.systempacketmanager import systepacketmgr
136137

137138
################################## Only root as it's a global system tool.
@@ -140,12 +141,20 @@ def _error(msg):
140141
sys.exit(2)
141142

142143
################################## Start to print to the user
143-
cprint(BANNER, color='green')
144+
# If we have a real tty, we can print the delicious banner with lot of BRO
145+
if is_tty():
146+
cprint(BANNER)
147+
else: # ok you are poor, just got some ascii art then
148+
cprint(TXT_BANNER)
149+
150+
# Also print a Bro quote
151+
quote, from_film = get_quote()
152+
cprint(' >> %s (%s)\n' % (quote, from_film), color='grey')
144153

145154
what = 'Installing' if not is_update else 'Updating'
146155
cprint('%s ' % ('*' * 20), end='')
147156
cprint('%s' % what, color='magenta', end='')
148-
cprint(' to version ', end='')
157+
cprint(' OpsBro to version ', end='')
149158
cprint('%s' % VERSION, color='magenta', end='')
150159
cprint(' %s' % ('*' * 20))
151160

@@ -292,41 +301,41 @@ def _error(msg):
292301
mod_need = {
293302
'requests': {
294303
'packages': {
295-
'debian': 'python-requests', 'ubuntu': 'python-requests',
296-
'amazon-linux' : 'python27-requests', 'centos': 'python-requests', 'redhat': 'python-requests', 'oracle-linux': 'python-requests', 'fedora': 'python-requests',
304+
'debian' : 'python-requests', 'ubuntu': 'python-requests',
305+
'amazon-linux': 'python27-requests', 'centos': 'python-requests', 'redhat': 'python-requests', 'oracle-linux': 'python-requests', 'fedora': 'python-requests',
297306
}
298307
},
299308
'cherrypy': { # note: centos: first epel to enable cherrypy get from packages
300309
'packages' : {
301-
'debian': 'python-cherrypy3', 'ubuntu': 'python-cherrypy3',
302-
'amazon-linux' : 'python-cherrypy3', 'centos': ['epel-release', 'python-cherrypy'], 'redhat': 'python-cherrypy', 'oracle-linux': 'python-cherrypy', 'fedora': 'python-cherrypy',
310+
'debian' : 'python-cherrypy3', 'ubuntu': 'python-cherrypy3',
311+
'amazon-linux': 'python-cherrypy3', 'centos': ['epel-release', 'python-cherrypy'], 'redhat': 'python-cherrypy', 'oracle-linux': 'python-cherrypy', 'fedora': 'python-cherrypy',
303312
},
304313
'failback_pip': 'cherrypy==3.2.4',
305314
},
306315
'jinja2' : {
307316
'packages': {
308-
'debian': 'python-jinja2', 'ubuntu': 'python-jinja2',
309-
'amazon-linux' : 'python-jinja2', 'centos': 'python-jinja2', 'redhat': 'python-jinja2', 'oracle-linux': 'python-jinja2', 'fedora': 'python-jinja2',
317+
'debian' : 'python-jinja2', 'ubuntu': 'python-jinja2',
318+
'amazon-linux': 'python-jinja2', 'centos': 'python-jinja2', 'redhat': 'python-jinja2', 'oracle-linux': 'python-jinja2', 'fedora': 'python-jinja2',
310319
}
311320
},
312321
'Crypto' : {
313322
'packages': {
314-
'debian': 'python-crypto', 'ubuntu': 'python-crypto',
315-
'amazon-linux' : 'python-crypto', 'centos': 'python-crypto', 'redhat': 'python-crypto', 'oracle-linux': 'python-crypto', 'fedora': 'python-crypto',
323+
'debian' : 'python-crypto', 'ubuntu': 'python-crypto',
324+
'amazon-linux': 'python-crypto', 'centos': 'python-crypto', 'redhat': 'python-crypto', 'oracle-linux': 'python-crypto', 'fedora': 'python-crypto',
316325
}
317326
},
318327
}
319328
# leveldb is not available on windows
320329
if os.name != 'nt':
321330
mod_need['leveldb'] = {
322331
'packages' : {
323-
'debian': 'python-leveldb', 'ubuntu': 'python-leveldb',
324-
'amazon-linux' : 'python-leveldb', 'centos': 'python-leveldb', 'redhat': 'python-leveldb', 'oracle-linux': 'python-leveldb', 'fedora': 'python-leveldb',
332+
'debian' : 'python-leveldb', 'ubuntu': 'python-leveldb',
333+
'amazon-linux': 'python-leveldb', 'centos': 'python-leveldb', 'redhat': 'python-leveldb', 'oracle-linux': 'python-leveldb', 'fedora': 'python-leveldb',
325334
},
326335
'pip_packages': {
327-
'debian': ['build-essential', 'python-dev'], 'ubuntu': ['build-essential', 'python-dev'],
336+
'debian' : ['build-essential', 'python-dev'], 'ubuntu': ['build-essential', 'python-dev'],
328337
# NOTE: amazon: no python-devel/python-setuptools, only versionsed packages are available
329-
'amazon-linux' : ['gcc', 'gcc-c++', 'python27-devel', 'libyaml-devel', 'python27-setuptools'], 'centos': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'], 'redhat': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'],
338+
'amazon-linux': ['gcc', 'gcc-c++', 'python27-devel', 'libyaml-devel', 'python27-setuptools'], 'centos': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'], 'redhat': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'],
330339
'oracle-linux': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'], 'fedora': ['gcc', 'gcc-c++', 'python-devel', 'libyaml-devel'],
331340
},
332341
}
@@ -339,7 +348,8 @@ def _error(msg):
339348
cprint('%s (version %s) ' % (system_distro, system_distroversion), color='magenta', end='')
340349
cprint('is managed by this installer and will be able to use system package manager to install dependencies.')
341350
else:
342-
cprint(" * NOTICE: your system (%s - %s) is not a tested system, it won't use the package system to install dependencies and will use the python pip dependency system instead (internet connection is need)." % (system_distro, system_distroversion))
351+
cprint(
352+
" * NOTICE: your system (%s - %s) is not a tested system, it won't use the package system to install dependencies and will use the python pip dependency system instead (internet connection is need)." % (system_distro, system_distroversion))
343353

344354
for (m, d) in mod_need.iteritems():
345355
cprint(' * checking dependency for ', end='')
@@ -411,6 +421,8 @@ def _error(msg):
411421
hook_stdout()
412422

413423
setup_phase_is_done = False
424+
425+
414426
def print_fail_setup(exp=''):
415427
if setup_phase_is_done:
416428
return
@@ -421,7 +433,8 @@ def print_fail_setup(exp=''):
421433
_prefix = ' | '
422434
cprint('Python setuptools call fail:\n%s' % ('\n'.join(['%s%s' % (_prefix, s) for s in f.read().splitlines()])), color='red')
423435
sys.exit(2)
424-
436+
437+
425438
atexit.register(print_fail_setup)
426439

427440
try:
@@ -461,7 +474,6 @@ def print_fail_setup(exp=''):
461474
# don't print something at exit now
462475
setup_phase_is_done = True
463476

464-
465477
# We did finish the setup, and we did succeed, so we can put the result into a log, we don't fucking care about
466478
# printing it to everyone unless we want to fear them
467479
unhook_stdout()

technical_spec_and_todo.txt

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ Besoins:
349349
### Installers
350350
* renommer les en un truc + général (compliance?)
351351
* exporter leur états dans le CLI
352+
* rajouter un système de variable évaluable dans les intaller (afin de ne pas se répéter)
352353

353354

354355
### Monitoring

0 commit comments

Comments
 (0)