Giter Site home page Giter Site logo

bashutils's Introduction

BASH UTILS

Bash colors management and log system for python users

Bashutils provide you two functionnalities:

  • Create bash colored text
  • Log message system (like lsb init-functions log message)

bash colors

Import :

from bashutils import colors

Color function :

color_text(text, color="none", bcolor="none", effect="none")
  • color : text color
  • bcolor : background color
  • effect : font effect

Text and background colors list : none, black ,red ,green ,yellow ,blue ,magenta ,cyan ,white

default color is 'none' (terminal default color)

Text effects : none, bold, underscore, blink, reverse, concealed

default effect is 'none'

bash logmsg

Import :

from bashutils import logmsg

Functions

Basic functions

Start a new log message :

log_begin_message("My message")

End a log message :

log_end_message(logmsg.LOG.OK)

Existing log type : LOG.OK (0), LOG.FAIL (1), LOG.ERROR (2), LOG.INFO (3), LOG.WARNING (4)

Predefined message (begin and end message):

log_success_msg("My message")
log_info_msg("My message")
log_warning_msg("My message")
log_failure_msg("My message")
log_error_msg("My message")

Other functions

If you want to add some information before or after the begin message, you can use these functions:

log_msg_pre("SUPP")
log_msg_post("SUPP")
log_end_msg_pre("SUPP", logmsg.LOG.OK)
log_end_msg_post("SUPP", logmsg.LOG.OK)

The last two functions add a PRE or POST information and end massage with LOG status

Add a LOG Type

It is possible to add a new LOG Type :

add_log_type(name, display, color, bcolor)
  • name : call name (A-Z and '_')
  • display : display message in [-]
  • color : text color (see bashutils.colors)
  • bcolor : background color (see bashutils.colors)

You can use this new LOG with LOG.MYNEWLOG (name in upper case)

You have an all in one function like log_success_msg with :

log_msg_type("My message", logmsg.LOG.MYNEWLOG)

Example :

add_log_type("MYNEWLOG", "NEWL", "red", "yellow")
log_msg_type("Message with new LOG", LOG.MYNEWLOG)

bashutils's People

Contributors

olivierb avatar

Watchers

 avatar  avatar  avatar

Forkers

python3pkg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.