Пример #1
0
def check_answer(answer, Choise, current_line, answers, choises, table_line_length, shuffled_line, question):
    betuk = [' A: ', ' B: ', ' C: ', ' D: ']
    choise_lengths=[]
    for n in range(4):
            choise_lengths.append(len(shuffled_line[n]))
    choise_lengths=max(choise_lengths)
    for pos in range(len(answers)):
        if shuffled_line[pos] == current_line[0]:
            index = shuffled_line.index(shuffled_line[pos])
    if answer == current_line[0]:
        choises[index] = Choise(betuk[index], shuffled_line[index], '\x1b[42m', '\x1b[39m', '\x1b[49m', '\x1b[30m',choise_lengths)
        fg.green = Style(RgbFg(0, 255, 0))
        time.sleep(2)
        os.system('clear')
        play_sound("./msc/jo valasz.mp3", 0)
        print(fg.green + "Well done!" + fg.rs)
    else:
        play_sound("./msc/rossz valasz.mp3", 0)
        time.sleep(2)
        fg.red = Style(RgbFg(255, 0, 0))
        print(fg.red+answer+"\nBetter luck next time!"+fg.rs)
        ask = safe_input("Would you like to play again? ('y'/'n')", ['y'])
        if ask == 'y':
            game_start()
            quiz()
        else:
            sys.exit(0)

    return choises
Пример #2
0
    def __init__(self):
        fg.orange = Style(RgbFg(255, 150, 50))

        #######Help_Crochet###########
        self.couleur_help_crochet = fg.orange
        self.bg_help_crochet = ""
        self.end_couleur_help_crochet = fg.rs
        self.end_bg_help_crochet = ""

        ########Help##################
        self.couleur_help = fg.da_green
        self.bg_help = ""
        self.end_couleur_help = fg.rs
        self.end_bg_help = ""

        ########Error#################
        self.couleur_error = fg.red
        self.bg_error = ""
        self.end_couleur_error = fg.rs
        self.end_bg_error = ""

        ########Info##################
        self.couleur_info = ""
        self.bg_info = bg.li_green
        self.end_couleur_info = ""
        self.end_bg_info = bg.rs
Пример #3
0
def transform_image(img):
    img = cv2.resize(img, (200, 200), interpolation=cv2.INTER_AREA)

    rgb_matrix = np.zeros((img.shape[0], img.shape[1]))

    for x in range(0, img.shape[0]):
        for y in range(0, img.shape[1]):
            rgb_matrix[x][y] = 0.21 * int(img[y][x][2]) + 0.72 * int(
                img[y][x][1]) + 0.07 * int(img[y][x][0])

    ascii_matrix = np.full((img.shape[0], img.shape[1]), "")
    ascii_string = "`^\",:;Il!i~+_-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$"

    for x in range(0, img.shape[0]):
        for y in range(0, img.shape[1]):
            ascii_matrix[x][y] = ascii_string[int(
                (rgb_matrix[x][y] / 255) * 64)] + ascii_string[int(
                    (rgb_matrix[x][y] / 255) * 64)] + ascii_string[int(
                        (rgb_matrix[x][y] / 255) * 64)]

    for x in range(0, img.shape[0]):
        for y in range(0, img.shape[1]):
            fg.color = Style(
                RgbFg(int(img[x][y][2]), int(img[x][y][1]), int(img[x][y][0])))
            if (y == img.shape[1] - 1):
                print(fg.color + ascii_matrix[x][y] + fg.rs)
            else:
                print(fg.color + ascii_matrix[x][y] + fg.rs, end='')
Пример #4
0
    def color(self):
        # Gets a list of RGB ('RGB') values of each frame
        if not self.framesRGB:
            self.framesRGB = [frame.image.get_data('RGB', -self.width*3) for frame in self.anim.frames]
        print('animation ready2run, running..\n')
        # Step through forever, frame by frame
        while True:
            for frame,frameL in zip(self.yielderRGB(), self.yielderL()):
                # Built up the string, by translating luminance values to characters
                outstr = ''

                # Define color from contigously stored RGB vals, map Luminance and repeat each char twice for correct aspect ratio
                for i in range(0,len(frame)-2,3):
                    R = frame[i]
                    G = frame[i+1]
                    B = frame[i+2]
                    pixel = frameL[i//3]
                    fg.color = Style(RgbFg(R, G, B))
                    outstr += fg.color + self.chars[(int(pixel) * (self.len - 1)) // 255]*2  + fg.rs + \
                              ('\n' if (i + 3) % (self.width*3) == 0 else '')

                # Clear the console
                os.system(self.clear_console)

                # Write the current frame on stdout and sleep
                sys.stdout.write(outstr)
                sys.stdout.flush()
            
                #time.sleep(0.01)

            time.sleep(3)
Пример #5
0
def game_start():
    fg.purple = Style(RgbFg(148, 0, 211))
    pygame.mixer.init()
    os.system('clear')
    play_sound("./msc/loim_intro.wav", 0)
    time.sleep(2)
    print("This is the game of games..\nIn the arena..\nMr Steven Vágó is awaiting You!\n"+fg.purple+"Become the next Millionaire!\n"+fg.rs)
    circle.who_wants_to_be_a_millionaire_circle()
    time.sleep(5)
Пример #6
0
    def __init__(self):

        super().__init__()

        # Add custom style attributes.

        self.purple = Style(Sgr(35))
        self.blue = Style(Sgr(34))
        self.orange = Style(RgbFg(255, 128, 0))
Пример #7
0
def fullColor(imgHeight, imgWidth, pixels):
    char = '█'
    for row in range(imgHeight):
        for col in range(imgWidth):
            fg.col = Style(RgbFg(pixels[col, row][0],
                                 pixels[col, row][1],
                                 pixels[col, row][2]))
            print(fg.col + char + fg.rs, end='')
            print(fg.col + char + fg.rs, end='')
        print()
Пример #8
0
 def get_color(attr):
     if attr > 0:
         g = int(128 * attr) + 127
         b = 128 - int(64 * attr)
         r = 128 - int(64 * attr)
     else:
         g = 128 + int(64 * attr)
         b = 128 + int(64 * attr)
         r = int(-128 * attr) + 127
     fg.color = Style(RgbFg(r, g, b))
     return fg.color
Пример #9
0
def highlight_rhyming_words(poem_file):

    with open(poem_file, 'r') as file:
        data = file.read()
    input = re.sub(r'[^\w\s]', '', data)
    input_list = re.findall(r'(\S+)\s*$(?!/)', input, re.MULTILINE)

    # initializing our sound dict
    sound_dict = {}
    already_rhymed = []
    for i in input_list:
        sound_dict[i] = []

    # rhyming
    for i in input_list:
        for n in input_list:
            if n != i:
                if n in pronouncing.rhymes(i) and n not in already_rhymed:
                    sound_dict[i].append(n)
                    already_rhymed.append(n)
                    already_rhymed.append(i)

    # remove the non-rhymers
    for x in list(sound_dict.keys()):
        if sound_dict[x] == []:
            del sound_dict[x]

    # add the word itself to the values
    for k in sound_dict:
        sound_dict[k].append(k)

    # print out the final results
    # print(sound_dict)

    # optionally, and maybe more usefully, print out all rhyming values in a list
    rhyming_words = list(sound_dict.values())

    # print("original poem:\n\n" + data)

    for rhyme_scheme in rhyming_words:

        #generate a color for the current scheme
        r_rand = np.random.choice(range(256))
        g_rand = np.random.choice(range(256))
        b_rand = np.random.choice(range(256))
        fg.color = Style(RgbFg(r_rand, g_rand, b_rand))

        for word in rhyme_scheme:

            # in here, we'd like to find and replace each word in the text file with it's associated fg.color word
            colored_word = fg.color + ef.bold + word + fg.rs + rs.bold_dim
            data = data.replace(word, colored_word)

    print(data)
Пример #10
0
def coloredASCII(imgHeight, imgWidth, pixels):
    ASCII = "`^\",:;Il!i~+-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$"
    for row in range(imgHeight):
        for col in range(imgWidth):
            bright = round(sum(pixels[col, row])/3)
            char = bright//4
            fg.col = Style(RgbFg(pixels[col, row][0],
                                 pixels[col, row][1],
                                 pixels[col, row][2]))
            print(fg.col + ASCII[char] + fg.rs, sep='', end='')
            print(fg.col + ASCII[char] + fg.rs, sep='', end='')
        print()
Пример #11
0
 def log(self, channel, message=""):
     fg.orange = Style(RgbFg(255, 150, 50))
     icons = {
         "logo": (fg.white + ASCII_ART, fg.rs),
         "header": (" " + ef.bold, rs.bold_dim),
         "subheader": (ef.i + fg.white + " ", fg.rs + rs.i + "\r\n"),
         "info": ("  " + "🤷 " + fg.white, fg.rs),
         "error": ("  " + "💥 " + fg.orange, fg.rs),
         "check": ("  " + "🎉 " + fg.green, fg.rs),
         "phone": ("  " + "📱", ""),
         "end": ("\r\n", ""),
     }
     before, after = icons.get(channel, "")
     print(f"{before} {message} {after}")
Пример #12
0
    def __init__(self):

        super().__init__()

        self.set_renderfunc(Sgr, renderfunc.sgr)
        self.set_renderfunc(EightbitFg, renderfunc.eightbit_fg)
        self.set_renderfunc(RgbFg, renderfunc.rgb_fg)

        self.set_eightbit_call(EightbitFg)
        self.set_rgb_call(RgbFg)

        self.red = Style(Sgr(31))
        self.green = Style(Sgr(32))
        self.rs = Style(Sgr(39))
        self.yellow = Style(RgbFg(250, 250, 70))
Пример #13
0
    def create_cube(resolution=2):
        res = 2 ** resolution

        print(f"Resolution {resolution} generates RGB file with {(2**7)**3} colors")
        if resolution >= 7:
            print(
                "\x1b[38;2;0;255;250m Need to create RGB memory file. Expected size: up to 300mb \x1b[39m"
            )
        cube = np.chararray(shape=[res, res, res], itemsize=19)
        cube = cube.astype("|S19")

        rd = int(256 / (2 ** resolution))
        for x in tqdm(range(res)):
            for y in range(res):
                for z in range(res):

                    fg.set_style("colorr", RgbFg(z * rd, y * rd, x * rd))
                    cube[x, y, z] = fg.colorr.replace("38", "38")
        np.save(f"color_{resolution}.npy", cube.astype("|S19"))
        return cube.astype("<U19")
Пример #14
0
# ===== Start =====
Example("as namedtuple")
from sty import fg as fg_obj

fg = fg_obj.as_namedtuple()

a = fg.yellow + "I have a yellow fg." + fg.rs

print(a)
# ===== End =====

# ===== Start =====
Example("copy")
from sty import RgbFg, Style, fg

fg_copy = fg.copy()
fg_no_copy = fg

fg.orange = Style(RgbFg(255, 200, 35))

# 'fg' and 'fg_no_copy' point to the same instance, therefore both can access 'orange':
assert hasattr(fg, "orange") == True
assert hasattr(fg_no_copy, "orange") == True

# fg_copy is not effected by the changes made to the global 'fg' register-object.
assert hasattr(fg_copy, "orange") == False
# ===== End =====
print("Copy works if no exception was thrown.")

Пример #15
0
# from sty.rendertype import EightbitFg

from .. import Example

print("\n\nCUSTOMIZING\n" + "=" * 80)

# ===== Start =====
Example("customizing the register-objects: assignment")
from sty import RgbFg, Sgr, Style, ef, fg, rs

fg.my_red = Style(RgbFg(255, 0, 0))

a = fg.my_red + "This text has red fg." + fg.rs

print(a)
# ===== End =====

# ===== Start =====
Example("customizing the register-objects: compose")
from sty import RgbFg, Sgr, Style, ef, fg, rs

fg.blue_bold = Style(RgbFg(0, 100, 200), Sgr(1))
fg.green_italic = Style(fg.green, ef.i)

a = fg.blue_bold + "This text has bold blue fg." + rs.all
b = fg.green_italic + "This text has italic green fg" + rs.all

print(a, b, sep="\n")
# ===== End =====

# ===== Start =====
Пример #16
0
print("\n\nGETTING STARTED\n" + "=" * 80)

# ===== Start =====
Example("gettings started: sty all the strings")
from sty import fg, bg, ef, rs, RgbFg

foo = fg.red + 'This is red text!' + fg.rs
bar = bg.blue + 'This has a blue background!' + bg.rs
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

# Add new colors:

fg.set_style('orange', RgbFg(255, 150, 50))

buf = fg.orange + 'Yay, Im orange.' + fg.rs

print(foo, bar, baz, qux, qui, buf, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select dynamically")
a = ef('italic') + 'Italic text.' + rs.italic
b = fg('blue') + 'Blue text.' + rs.fg
c = bg(randint(0, 254)) + 'Random colored bg' + rs.bg

print(a, b, c, sep='\n')
# ===== End =====
Пример #17
0
fg = fg_obj.as_namedtuple()

a = fg.yellow + "I have a yellow fg." + fg.rs

print(a)
# ===== End =====

# ===== Start =====
Example("copy")
from sty import fg as fg_a, RgbFg, FgRegister

fg_b = fg_a

fg_c = fg_a.copy()

fg_a.set_style('orange', RgbFg(240, 100, 100))

a = fg_a.orange + "I have an orange fg." + fg.rs
b = fg_b.orange + "I have an orange fg too." + fg.rs

print(a, b, sep="\n")

try:
    msg = "But I have no orange fg, because I'm an earlier copy."
    fg_c.orange + msg + fg.rs
except AttributeError:
    print(msg)

# # ===== End =====
Пример #18
0
from sty import fg, Style, RgbFg

# It's necessary to initialise colors by adding it to fg

fg.brown_1 = Style(RgbFg(191, 92, 0))
fg.brown_2 = Style(RgbFg(150, 84, 23))
fg.brown_3 = Style(RgbFg(117, 60, 7))
brown_colors = (fg.brown_1, fg.brown_2, fg.brown_3)

fg.green_1 = Style(RgbFg(34, 139, 34))
fg.green_2 = Style(RgbFg(0, 128, 0))
fg.green_3 = Style(RgbFg(0, 100, 0))
green_colors = (
    fg.green_1,
    fg.green_2,
    fg.green_3,
)


class Symbols:
    leaf = "&"
    wood_u = "|"
    wood_h = "~"
    wood_r = "/"
    wood_l = "\\"


class Directions:
    RIGHT = "right"
    LEFT = "left"
    UP = "up"
Пример #19
0
from fake_useragent import UserAgent  # 偽裝請求
from sty import fg, bg, ef, rs, Style, RgbFg


def set_header_user_agent():
    user_agent = UserAgent()
    return user_agent.random


# Font, Colors
ef.end = '\033[0m'
# ef.italic for italic
ef.blod = '\033[1m'
ef.underline = '\033[4m'
# fg.rs for end
fg.orange = Style(RgbFg(255, 150, 50))
fg.gray = Style(RgbFg(165, 165, 165))
fg.gray_light = Style(RgbFg(125, 125, 125))

#################################################


def run_dcl(check="n"):
    check = check.lower()
    if check != "y" and check != "yes":
        pass


def main(url, url_board, sys_debug=False):
    while True:
        req_url = url + url_board
Пример #20
0
    if not os.path.isdir(songs_path):
        print(fg.yellow + "WARNING!!!! SONGS PATH IS INCORRECT")
        input()
        end()


def getRecentJournal():
    global journal_path
    journal_files = glob.glob(ED_Journal_Folder + "\\*.log")
    journal_path = max(journal_files, key=os.path.getmtime)


pygame.mixer.init()

#style stuff
fg.orange = Style(RgbFg(255, 90, 0))
fg.yellow = Style(RgbFg(255, 204, 0))
title_fig = pyfiglet.Figlet(font='big')

journal_path = ''
current_user_dir = os.path.expanduser("~")
ED_Journal_Folder = ''
songs_path = ''
battle_songs_path = ''
battle_songs_enabled = True
in_battle = False
docking_reminder = False
song_selection_method = "Shuffle"
song_volume = 0.15
next_song_keybind = "l"
Пример #21
0
def print_colors(colors):
    for color in colors:
        fg.color = Style(RgbFg(color[0], color[1], color[2]))
        buf = fg.color + '■' + fg.rs
        print(buf, end=" ")
    log("")
Пример #22
0
def quiz():
    Help_available = [True, True, True]
    prices = ["5.000 Ft", "10.000 Ft", "25.000 Ft", "50.000 Ft", "100.000 Ft", "200.000 Ft", "300.000 Ft", "500.000 Ft", "800.000 Ft", "1.500.000 Ft", "3.000.000 Ft", "5.000.000 Ft", "10.000.000 Ft", "20.000.000 Ft", "40.000.000 Ft"]
    prices1 = ['40.000.000 Ft', '20.000.000 Ft', '10.000.000 Ft', '5.000.000 Ft', '3.000.000 Ft', '1.500.000 Ft', '800.000 Ft', '500.000 Ft', '300.000 Ft', '200.000 Ft', '100.000 Ft', '50.000 Ft', '25.000 Ft', '10.000 Ft', '5.000 Ft']
    prices2 = ['40.000.000 Ft', '20.000.000 Ft', '10.000.000 Ft', '5.000.000 Ft', '3.000.000 Ft', '1.500.000 Ft', '800.000 Ft', '500.000 Ft', '300.000 Ft', '200.000 Ft', '100.000 Ft', '50.000 Ft', '25.000 Ft', '10.000 Ft', '5.000 Ft']
    question_lines = open_file('questions.txt', "r")
    list_of_answers = open_file('questions.txt', "r")
    starting_range = 0
    ending_range = 4
    max_choise=[]
    
    class Choise():
        def __init__(self, letter, answer, firstpart, secondpart, thirdpart, additional, lengths=''):
            self.lengths=lengths
            self.additional = additional
            self.mark = "▏"
            self.quote = "◆"
            self.letter = letter
            self.answer = answer 
            self.spaces = (self.lengths-(len(self.answer)))*" " +5*" "+"▕"
            self.firstpart = firstpart
            self.secondpart = secondpart
            self.thirdpart = thirdpart
            self.f_end = "◀"
            self.s_end = "▶"
            self.line = "-"
            self.slash = "▕"
            self.slash_ = "▏"

    letters_ = [" A: ", " B: ", " C: ", " D: "]
    for i in range(15):
        counter = i
        random_question = []
        random_question = random.choice(list_of_answers[starting_range:ending_range])
        question = random_question[0]
        time.sleep(2)
        os.system('clear')
        current_line = random_question[1:5]
        copy_of_list_of_answers = copy.deepcopy(random_question)
        shuffled_line = copy_of_list_of_answers[1:5]
        random.shuffle(shuffled_line)
        a = shuffled_line[0]
        b = shuffled_line[1]
        c = shuffled_line[2]
        d = shuffled_line[3]
        choise_lengths=[]
        answers = [a, b, c, d]
        choises = [' ', ' ', ' ', ' ']
        for n in range(4):
            choise_lengths.append(len(shuffled_line[n]))
        choise_lengths=max(choise_lengths)
        for letter_ in range(len(letters_)):
            choises[letter_] = Choise(letters_[letter_],shuffled_line[letter_],'\x1b[40m','\x1b[39m','\x1b[49m','\x1b[38;2;255;150;50m',choise_lengths)
        fg.orange = Style(RgbFg(255, 150, 50))
        table_line_length = calculate_quiz_table_size(question_lines,list_of_answers)
        print_lists(Help_available, table_line_length)
        quiz_table(table_line_length, choises, question, shuffled_line)
        answer = safe_input("\nSelect the correct answer (a,b,c,d) or 'h' for help! ", ["a", "b", "c", "d", "h", "s"])
        pressed_h_key(answer,answers, current_line, question, table_line_length, shuffled_line, choises, Help_available, prices, prices1, prices2, counter)
        list_of_are_you_sure_sound_files = ["./msc/vegleges.mp3", "./msc/vegleges2.mp3", "./msc/vegleges3.mp3", "./msc/vegleges4.mp3", "./msc/vegyem_veglegesnek.mp3"]
        are_you_sure_sound = choose_random_from_list(list_of_are_you_sure_sound_files)
        play_sound(are_you_sure_sound, 0)
        time.sleep(1)
        answer = safe_input("Are you sure? ", ["a", "b", "c", "d", "s"])
        stop_game_and_guess_out_of_game(answer, Help_available, table_line_length, prices, prices1, prices2, counter,current_line, answers, choises, shuffled_line, question)
        answer=marking(Choise, answer, current_line, answers, choises, table_line_length, shuffled_line, question, Help_available)[1]
        os.system('clear')
        print_lists(Help_available, table_line_length)
        quiz_table(table_line_length, choises, question, shuffled_line)
        play_sound("./msc/marked.mp3", 0)
        time.sleep(4)
        #check_answer(answer, Choise, current_line, answers, choises, table_line_length, shuffled_line, question)
        choises=check_answer(answer, Choise, current_line, answers, choises, table_line_length, shuffled_line, question)
        print_lists(Help_available, table_line_length)
        quiz_table(table_line_length, choises, question, shuffled_line)
        time.sleep(2)
        os.system('clear')
        won_prize = prices[i]
        if i == 4:
            won_prize = "You have guaranteed 100.000 Ft"
            time.sleep(1)
        elif i == 9:
            won_prize = "You have guaranteed 1.500.000 Ft"
            time.sleep(1)
        elif i == 14:
            won_prize = fg.orange + "Congratulations!\nYou've just won the unbelivable 40.000.000 Ft\n"+fg.purple+"You became the new Millionaire!!!" + fg.rs
            print(won_prize)
            time.sleep(3)
            sys.exit(0)
        price_len=len("▏40.000.000 Ft▕")-4
        print_lists(Help_available, table_line_length)
        print("  "+bg.black+"/"+"‾"*(table_line_length)+"\\"+price_len*" "+bg.rs)
        width = table_line_length
        len_table = len("‾"*(table_line_length-len(won_prize)))
        print(bg.black+"-"+"‹" + fg.orange + ''.join(won_prize).center((width), ' ') + fg.rs +"  "+ "›" + "-"+(price_len-2)*" "+bg.rs)
        print(bg.black+"  "+"\\"+"_"*(table_line_length)+"/"+price_len*" "+bg.rs)
        for line in range(6):
            print(bg.black+108*" "+bg.rs)
        starting_range = ending_range + 1
        ending_range = starting_range + 4
        time.sleep(1)
Пример #23
0
def orange(text):
    fg.orange = Style(RgbFg(255, 150, 50))
    return fg.orange + text + fg.rs
Пример #24
0
from .. import Example
from sty.rendertype import *

print("\n\nCUSTOMIZING\n" + "=" * 80)

# ===== Start =====
Example("customizing the register-objects: assignment")
from sty import fg, ef, rs, Style, RgbFg, Sgr

fg.my_red = Style(RgbFg(255, 0, 0))

a = fg.my_red + 'This text has red fg.' + fg.rs

print(a)
# ===== End =====

# ===== Start =====
Example("customizing the register-objects: compose")
from sty import fg, ef, rs, Style, RgbFg, Sgr

fg.blue_bold = Style(RgbFg(0, 100, 200), Sgr(1))
fg.green_italic = Style(fg.green, ef.i)

a = fg.blue_bold + 'This text has bold blue fg.' + rs.all
b = fg.green_italic + 'This text has italic green fg' + rs.all

print(a, b, sep='\n')
# ===== End =====

# ===== Start =====
Example("customizing the register-objects: set_style")
Пример #25
0
import pypresence
from pypresence import Presence
import tkinter as tk
import time
from random import randint
import sty
from sty import fg, RgbFg
from tkinter import Tk

#connecting to discord
client_id = '785245597279846442'
RPC = Presence(client_id)
RPC.connect()

#color varibles
fg.set_style('eCDP_Cyan', RgbFg(96, 136, 184))
cyan = fg.eCDP_Cyan + 'Thank You For Using My Rich Presence!' + fg.rs

fg.set_style('killConnect_Cyan', RgbFg(71, 180, 255))
cyanB = fg.killConnect_Cyan + 'Connection Will Close Shortly!'

fg.set_style('startUp', RgbFg(0, 88, 136))
start = fg.startUp + 'Starting Up!'

fg.set_style('statUp', RgbFg(232, 104, 168))
stat = fg.statUp + 'Status Updated!'

#setting the base rich presence
RPC.update(state="In Menus",
           details="Playing the eCrew Development Program",
           large_image="ecdp_ico",
Пример #26
0
import time
from configparser import ConfigParser
from datetime import datetime, timedelta
from pathlib import Path
from shutil import rmtree
from subprocess import CompletedProcess
from zipfile import ZipFile, ZIP_BZIP2
from time import sleep

import signal
import psutil
import requests
from dateutil.relativedelta import relativedelta
from sty import fg, RgbFg

fg.set_style("orange", RgbFg(255, 150, 50))
config = None


def get_config(section: str, config_name: str) -> str:
    global config
    if config is None:
        config = ConfigParser()
        config.read("config.ini")
    return config[section][config_name]


def format_seconds(seconds: float) -> str:
    seconds = math.fabs(seconds)
    if seconds > 3600:
        return f"{seconds / 3600} hours"
Пример #27
0
	print("Debug Mod On!\n")
	sys_debug=True;

def exit(signum, frame):
    print('\n Stoped '+_info.name+'! \n')
    sys.exit()
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)

# Font, Colors
ef.end = '\033[0m'
# ef.italic for italic
ef.blod = '\033[1m'
ef.underline = '\033[4m'
# fg.rs for end
fg.red=Style(RgbFg(255, 50, 50))
fg.orange = Style(RgbFg(255, 150, 50))
fg.gray = Style(RgbFg(165,165,165))
fg.green = Style(RgbFg(110,255,120))

#################################################

url='https://www.dcard.tw'
url_board='/f'
url_search=url+"/f/search?query="

print(fg.green+"Use \"Ctrl+C\" to exit. \n\tHave fun! ヽ(●´∀`●)ノ"+fg.rs+"\n")

while True:
	# 查詢板塊
	dcl_mode=input(ef.blod+"(1) Board URL (Default)\n(2) Board list select\n(3) Board keyword search (Not recommend)"+ef.end+fg.orange+"\nChoice mode: "+fg.rs).replace(" ","")
Пример #28
0
def create_basic_color(rgb):
    fg.set_style("colorr", RgbFg(*rgb))
    c = fg.colorr.replace("38", "38")
    return c
Пример #29
0
# ===== Start =====
Example("gettings started: sty all the strings")
from sty import fg, bg, ef, rs

foo = fg.red + 'This is red text!' + fg.rs
bar = bg.blue + 'This has a blue background!' + bg.rs
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

# Add custom colors:

from sty import Style, RgbFg

fg.orange = Style(RgbFg(255, 150, 50))

buf = fg.orange + 'Yay, Im orange.' + fg.rs

print(foo, bar, baz, qux, qui, buf, sep='\n')
# ===== End =====

# ===== Start =====
Example("gettings started: select dynamically")
a = ef('italic') + 'Italic text.' + rs.italic
b = fg('blue') + 'Blue text.' + rs.fg
c = bg(randint(0, 254)) + 'Random colored bg' + rs.bg

print(a, b, c, sep='\n')
# ===== End =====
Пример #30
0
        "id": id,
        "name": name,
        "initial_logs": initial_logs,
        "current_logs": content
    })
    running_containers.append(id)

# for visual pleasure
for i in running_containers_data:
    name = i["name"]
    spaces_to_be_added = longest_name_length - len(name)
    name += ' ' * spaces_to_be_added
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    fg.color = Style(RgbFg(r, g, b))
    i["name"] = fg.color + name.capitalize() + fg.rs


def line_formater(line, container_name):
    try:
        parsed = json.loads(line)
        time = parse(parsed['time']).astimezone(time_zone)
        milliseconds = int(
            round(
                time.strptime(time.strftime('%d.%m.%Y %H:%M:%S,%f'),
                              '%d.%m.%Y %H:%M:%S,%f').timestamp() * 1000))
        actual_log = '%s | %s | %s' % (container_name,
                                       time.strftime('%H:%M:%S %Y-%m-%d'),
                                       parsed["log"].split('\n')[0])
        return [actual_log, milliseconds]