Beispiel #1
0
def prepare_ping():
    j = parse_json_from_file(PROJECT_CONFIG_FILE)

    manager = Manager(server_file_name=j['servers_file'],
                      binary=j['v2ray_binary'])

    choices = ["ping all"]

    l = manager.server_number
    for i in range(l):
        s = manager.get_server(i)
        choices.append(str(i + 1) + "  " + s['ps'] + "  " + s['host'])

    prompt = ScrollBar(height=10, choices=choices)
    result = prompt.launch()
    index = choices.index(result)
    print("index            ps          time")
    if index == 0:
        for i in range(l):
            s = manager.get_server(i)
            r = ping(host=s['host'])
            result = str(r) + "ms" if r != -1 else "timeout"
            print(str(i + 1) + "  " + s['ps'] + "  " + result)
    else:
        s = manager.get_server(index - 1)
        r = ping(host=s['host'])
        result = str(r) + "ms" if r != -1 else "timeout"
        print(str(index) + "  " + s['ps'] + "  " + result)
Beispiel #2
0
    def select_a_program(self):
        playlist_links = set()
        cli = ScrollBar("Select a show: ", [*self.programs],
                        pointer="🎵",
                        height=6,
                        align=5,
                        margin=3)

        program = cli.launch()
        search_fill = self.PROG_SEARCH_FILL.copy(
        )  # make a copy of the dict in case we want to do another search
        search_fill['program'] = self.programs[program]
        search_url = "?".join([self.WMBR_SITE, parse.urlencode(search_fill)])
        search_data = requests.get(search_url)
        search_parser = BeautifulSoup(search_data.content, "html.parser")
        playlist_a_tags = search_parser.find_all(
            "a", href=re.compile(r"playlist.php*"))

        for a in playlist_a_tags:
            playlist_links.add(a.get('href'))

        playlist_links = list(playlist_links)

        songz = []
        for lonk in playlist_links:
            time.sleep(1)
            songz.extend(self.playlist_visitor(lonk))

        playlist_id = self.mb.create_playlist(program)

        self.mb.add_songs_to_playlist(playlist_id, songz)
Beispiel #3
0
    def issues(self):
        utils.clear()
        print('{}{}%s{}'.format(utils.Color.BOLD, utils.Color.BLUE,
                                utils.Color.END) % self.title)
        count_score = 0

        for key in self.question:
            if key[0] == MultidimensionalEvaluationTest.HAVE_CHOICE:
                answer_aux = ScrollBar(prompt=key[1],
                                       choices=key[2],
                                       indent=0,
                                       margin=2,
                                       pointer="★",
                                       pad_right=5)
                answer = answer_aux.launch()
            else:
                answer = input(key[1])

            utils.line_break()
            key.append(answer)

            if key[0] == MultidimensionalEvaluationTest.HAVE_CHOICE:
                try:
                    count_score += int(str(answer[1]))
                except ValueError:
                    pass

        return count_score
Beispiel #4
0
  def select_victim(self):
    """Ask to the hoster which victim he want to interact with."""
    user_choice = None

    while True:
      try:
        self.wait_victims()
      except KeyboardInterrupt:
        break

      choices = [REFRESH, *self.victims, QUIT]
      cli = ScrollBar('Select your victim :'
                      , choices=choices
                      , height=SCROLL_HEIGHT)

      try:
        user_choice = cli.launch()
      except KeyboardInterrupt:
        break
      finally:
        utils.clearConsoleUp(SCROLL_HEIGHT - 1)

      if user_choice == QUIT:
        break
      if user_choice == REFRESH:
        continue
      return user_choice
Beispiel #5
0
 def list(self, index):
     message = self.items[index]['message']
     cli = ScrollBar(prompt=f'   {message}',
                     choices=self.items[index]['elements'],
                     pointer_color=colors.foreground['cyan'],
                     margin=2,
                     height=10)
     answers = cli.launch()
     return answers
Beispiel #6
0
def select_users():
    user_choice = None

    while True:
        wait_victims()
        choices = [QUIT, REFRESH, *victims]
        cli = ScrollBar('Select your victim :',
                        choices=choices,
                        height=SCROLL_HEIGHT)
        user_choice = cli.launch()
        utils.clearConsoleUp(SCROLL_HEIGHT)
        if user_choice == QUIT:
            return None
        if user_choice != REFRESH:
            print(f'You have selected \'{user_choice}\'.')
            return victims.get(user_choice)
Beispiel #7
0
    def input_gerontologist():
        print('{}{}## Ficha cadastral: {} \n'.format(Color.BOLD, Color.CYAN, Color.END))
        inpt_primary_name = input('Gerontólogo(a), digite o seu nome: ').capitalize()
        inpt_last_name = input('Último nome: ').capitalize()
        inpt_num_membership_abg = input('Número de associação ABG (Associação Brasileira de Gerontologia): ')
        inpt_service_institution = input('Serviço/Instituíção: ').capitalize()

        inpt_is_elderly_interviewee_aux = ScrollBar('O entrevistado é o próprio idoso?: ', choices=['Sim', 'Não'],
                                                    indent=0, margin=2, pointer="★", pad_right=5)

        inpt_is_elderly_interviewee = inpt_is_elderly_interviewee_aux.launch()

        inpt_evaluation_date = time.strftime("%d/%m/%Y")

        inpt_is_elderly_interviewee = (1 if (inpt_is_elderly_interviewee.upper() == 'S') else 0)

        gerontologist = Gerontologian(inpt_primary_name, inpt_last_name, inpt_num_membership_abg,
                                      inpt_service_institution, inpt_is_elderly_interviewee, inpt_evaluation_date)

        print('Bem vindo(a), %s. \n' % gerontologist.full_name)
        time.sleep(1)
        return gerontologist
Beispiel #8
0
    def input_patient():
        clear()
        print('{}{}## Dados de identificação do paciente: {} \n'.format(Color.BOLD, Color.CYAN, Color.END))
        inpt_first_name = input('Primeiro nome: ').capitalize()
        inpt_last_name = input('Segundo nome: ').capitalize()
        inpt_adress = input('Endereço: ').capitalize()
        inpt_telephone = input('Telefone: ')
        inpt_date_birth = input('Data de nascimento (DD/MM/AAAA): ')
        inpt_age = input('Idade: ').capitalize()

        inpt_genre_aux = ScrollBar(prompt='Gênero: ', choices=['Feminino', 'Masculino', 'Prefiro não dizer'],
                                   indent=0, margin=2, pointer="★", pad_right=5)

        inpt_genre = inpt_genre_aux.launch()

        inpt_marital_status = input('Estado civíl: ').capitalize()
        inpt_scholarity = input('Escolaridade: ').capitalize()
        inpt_years_scholarity = input('De acordo com sua escolaridade, o(a) senhor(a) estudou,'
                                      ' formalmente durante quantos anos? ')
        inpt_retired = input('O(a) Sr(a) é aposentado? Se não, qual é a sua profissão atual? ')
        inpt_retired_pensioner = input('Caso seja aposentado ou pensionista,'
                                       ' qual a profissão que exerceu por mais tempo? ')
        inpt_paid_work = input('Exerce atualmente algum tipo de trabalho remunerado? Se sim, qual? ')
        inpt_individual_income = input('Renda individual: ')
        inpt_family_income = input('Renda familiar (se houver): ')
        inpt_live_with = input('Com quem mora: ').capitalize()
        inpt_have_relegion = input('Possui religião - Sim (S) | Não (N): ')

        inpt_have_relegion = (1 if (inpt_have_relegion.upper() == 'S') else 0)

        patient = Patient(inpt_first_name, inpt_last_name, inpt_adress, inpt_telephone,
                          inpt_date_birth, inpt_age, inpt_genre, inpt_marital_status,
                          inpt_scholarity, inpt_years_scholarity, inpt_retired,
                          inpt_retired_pensioner, inpt_paid_work, inpt_individual_income,
                          inpt_family_income, inpt_live_with, inpt_have_relegion)

        print('Iniciando a avaliação de %s... \n' % patient.full_name)
        return patient
def prompt_for_application(controller_service, prompt_header: str) -> int:
    result = controller_service.get_applications()
    if result.error is not None:
        exit_with_message(
            f"Error getting applications with status code {result.error.msg}")

    apps = result.data

    cli = ScrollBar(prompt_header, [app.name for app in apps],
                    height=15,
                    align=5,
                    margin=3,
                    pointer=">",
                    pointer_color=colors.foreground["cyan"],
                    word_color=colors.foreground["white"],
                    word_on_switch=colors.foreground["white"],
                    background_color=colors.background["black"],
                    background_on_switch=colors.background["black"])
    application_name = cli.launch()
    application_id = next(app.id for app in apps
                          if app.name == application_name)
    move_cursor_up_lines(len(apps) - 1 if len(apps) < 15 else 14)
    return application_id
Beispiel #10
0
def video_prompt(playlist_id: str,
                 page_token: str = "") -> Tuple[Details, ScrollBar]:
    videos = get_videos(playlist_id=playlist_id, page=page_token)
    v_choices = ["[Range]", "[ALL VIDEOS]"]
    if videos.prev_page != "":
        v_choices.append("[Previous Page]")
    v_choices = v_choices + [v.title for v in videos.items]
    if videos.next_page != "":
        v_choices.append("[Next Page]")
    return videos, ScrollBar("Select a Video:",
                             height=10,
                             pointer="→ ",
                             align=4,
                             margin=1,
                             choices=v_choices)
Beispiel #11
0
 def _get_scroll_menu(self):
     return ScrollBar(
         self.menu_text,
         choices=self.menu_item_text_list,
         height=8,
         pointer=self.pointer,
         shift=1,
         indent=2,
         margin=2,
         pointer_color=self.pointer_color,
         background_color=self.background_color,
         background_on_switch=self.background_on_switch,
         word_color=self.word_color,
         word_on_switch=self.word_on_switch,
     )
Beispiel #12
0
def create_scrolling_prompt(prompt, choices, wrap=True, max_line_len=70):
    if wrap:
        prompt = wrap_text(prompt, max_line_len)
    return ScrollBar(
        prompt,
        choices,
        height=8,
        pointer="",
        shift=1,
        indent=0,
        margin=2,
        pointer_color=colors.foreground["default"],
        word_color=colors.foreground["default"],
        word_on_switch=colors.bright(colors.foreground["cyan"]),
        background_color=colors.background["default"],
        background_on_switch=colors.background["default"],
    )
Beispiel #13
0
def playlist_prompt(channel_id: str,
                    page_token: str = "") -> Tuple[Details, ScrollBar]:
    playlists = get_playlists(channel_id=channel_id, page=page_token)
    pl_choices = []
    if playlists.prev_page != "":
        pl_choices.append("[Previous Page]")
    pl_choices = pl_choices + [p.title for p in playlists.items]
    if playlists.next_page != "":
        pl_choices.append("[Next Page]")
    return playlists, ScrollBar(
        "Select a Playlist:",
        height=10,
        pointer="→ ",
        align=4,
        margin=1,
        choices=pl_choices,
    )
Beispiel #14
0
from bullet import ScrollBar
from bullet import emojis
from bullet import colors

cli = ScrollBar(
    "How are you feeling today? ", 
    emojis.feelings,
    height = 5,
    align = 5,
    margin = 0,
    pointer = "👉",
    background_on_switch = colors.background['default'],
    word_on_switch = colors.foreground['default'],
    return_index = True
)
print('\n')
result = cli.launch()
print(result)
Beispiel #15
0
from bullet import ScrollBar
from bullet import colors
import random
''' Pumping bars. '''

n = [random.randint(0, 15) for _ in range(1000)]
choices = []
# Do some interpolation
for i in range(0, len(n) - 1):
    choices.append(n[i])
    choices.append(int((n[i] + n[i + 1]) / 2))
choices = list(map(lambda i: "▉" * i, choices))

cli = ScrollBar(prompt="",
                choices=choices,
                height=1,
                pointer="",
                word_color=colors.bright(colors.foreground["cyan"]),
                word_on_switch=colors.bright(colors.foreground["cyan"]),
                background_color=colors.background["black"],
                background_on_switch=colors.background["black"])
print('\n')
cli.launch()
Beispiel #16
0
from bullet import ScrollBar
from bullet import emojis
from bullet import colors

cli = ScrollBar("How are you feeling today? ",
                emojis.feelings,
                height=5,
                align=5,
                margin=3,
                pointer="👉",
                pointer_color=colors.foreground["cyan"],
                word_color=colors.foreground["white"],
                word_on_switch=colors.foreground["white"],
                background_color=colors.background["black"],
                background_on_switch=colors.background["black"])
print('\n')
result = cli.launch()
print('\n')