Python colors.green() Examples

The following are 8 code examples of colors.green(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module colors , or try the search function .
Example #1
Source File: new_algo.py    From Photoroid with GNU General Public License v3.0 6 votes vote down vote up
def check_match(source):
    try:
        import numpy as np
    except ImportError:
        print("[-] Error importing numpy module.")
        exit(1)
    list_search_images = os.listdir(
        os.path.join(os.getcwd(), target_images_dir_name))
    colors.success("Search image list grabbed ")
    print(
        "\n{}\
        ----------------------------------------------------------------------\
        {}".format(
            colors.red, colors.green
        )
    )
    print("\n\t {}:: Similar images found are :: \n".format(colors.lightgreen))
    for path in list_search_images:
        src_image = cv2.imread(os.path.join(target_images_dir_name, path), 0)
        if custom_hashing(source) == custom_hashing(src_image):
            print("Image : {}".format(path)) 
Example #2
Source File: run.py    From scrubadub with MIT License 5 votes vote down vote up
def run_test(command):
    wrapped_command = "cd %s && %s" % (root_dir, command)
    pipe = subprocess.Popen(
        wrapped_command, shell=True,
    )
    pipe.wait()
    if pipe.returncode == 0:
        print(green("TEST PASSED"))
    else:
        print(red("TEST FAILED"))
    return pipe.returncode

# load the script tests from the .travis.yml file 
Example #3
Source File: thread_photo.py    From Photoroid with GNU General Public License v3.0 5 votes vote down vote up
def check_match():

    list_temp_images = os.listdir(os.path.join(
        os.getcwd(), template_image_dir_name))
    colors.success("Template image list grabbed.")
    list_search_images = os.listdir(
        os.path.join(os.getcwd(), target_images_dir_name))
    colors.success("Search images list grabbed")
    print(
        "\n{}\
        ----------------------------------------------------------------------\
        {}"
        .format(colors.red, colors.green))
    print("\n\t {}:: Similar images found are :: \n".format(colors.lightgreen))

    image_thread_process = []

    for path in list_search_images:
        image_thread_process.append(
            th(
                target=thread_checker,
                args=(path, list_temp_images,)
            )
        )

    for process in image_thread_process:
        process.start()

    for process in image_thread_process:
        process.join()

    colors.success("Threading function completed") 
Example #4
Source File: populate.py    From mcsema with Apache License 2.0 5 votes vote down vote up
def try_find(locations, basename):
    for p in locations:
        maybe = os.path.join(p, basename)
        if os.path.isfile(maybe):
            print(" > " + colors.green("Found " + maybe))
            new_file = os.path.join(bin_dir, basename)
            shutil.copyfile(maybe, new_file)
            st = os.stat(new_file)
            os.chmod(new_file, st.st_mode | stat.S_IEXEC)

            return True
    return False 
Example #5
Source File: result_data.py    From mcsema with Apache License 2.0 5 votes vote down vote up
def get_result_color(self):
        if self.total == 0:
            return colors.magneta

        if self.total == self.success:
            return colors.green

        if self.success == 0:
            return colors.red

        return colors.orange 
Example #6
Source File: util.py    From carml with The Unlicense 5 votes vote down vote up
def nice_router_name(router, color=True):
    """
    returns a router name with ~ at the front if it's not a named router
    """
    green = str
    italic = str
    if color:
        green = colors.green
        italic = colors.italic
    if router.name_is_unique:
        return green(router.name)
    return italic('~%s' % router.name) 
Example #7
Source File: photo.py    From Photoroid with GNU General Public License v3.0 4 votes vote down vote up
def check_match():
    try:
        import numpy as np
    except ImportError:
        print("[-] Error importing numpy module.")
        exit(1)

    list_temp_images = os.listdir(os.path.join(
        os.getcwd(), template_image_dir_name))
    colors.success("Template image list grabbed.")
    list_search_images = os.listdir(
        os.path.join(os.getcwd(), target_images_dir_name))
    colors.success("Search image list grabbed ")
    print(
        "\n{}----------------------------------------------------------------------{}".format(colors.red, colors.green))
    print("\n\t {}:: Similar images found are :: \n".format(colors.lightgreen))

    for path in list_search_images:
        checked = []
        pos = 0

        # Reading images to be matched one by one.
        src_image = cv2.imread(os.path.join(
            target_images_dir_name, path), cv2.IMREAD_COLOR)

        # Converting image to grayscale.
        src_gray = cv2.cvtColor(src_image, cv2.COLOR_BGR2GRAY)

        # Checking if all the templates are there in image or not.
        while pos < 12:
            template_path = list_temp_images[pos]
            template_image = cv2.imread(os.path.join(
                template_image_dir_name, template_path), cv2.IMREAD_GRAYSCALE)

            # Using cv2.matchTemplate() to check if template is found or not.
            result = cv2.matchTemplate(
                src_gray, template_image, cv2.TM_CCOEFF_NORMED)
            thresh = 0.9
            loc = np.where(result > thresh)
            if str(loc[0]) == str(loc[1]):
                checked.append("False")
                break
            else:
                checked.append("True")
            pos += 1

        if "False" not in checked:
            print("Image : {}".format(path)) 
Example #8
Source File: ssh_transport.py    From ssh_client with MIT License 4 votes vote down vote up
def read(self):
    '''Read a packet from the remote server.

    Assuming the initial connection has completed (i.e. #connect has been called, and returned),
    this data will be encrypted, and its authenticity guaranteed.

    Returns (string): the data sent by the remote server.
    '''

    # Read the first <block_len> bytes of the packet, decrypt it if necessary, and parse out the
    # remaining packet length
    initial_packet = self._socket.recv(AES_BLOCK_LEN)
    if self._encryption_negotiated:
      initial_packet = self._aes_server_to_client.decrypt(initial_packet)
    _, packet_len = parse_uint32(initial_packet, 0)

    # Read the remaining bytes of the packet, decrypting if necessary, and checking the MAC
    remaining_msg = self._socket.recv(packet_len - (AES_BLOCK_LEN - 4))
    if self._encryption_negotiated:
      remaining_msg = self._aes_server_to_client.decrypt(remaining_msg)

      # Read and verify the MAC
      received_mac = self._socket.recv(SHA1_LEN)
      calculated_mac = hmac.new(
          self._integrity_key_server_to_client,
          generate_uint32(self._packets_received_counter) + initial_packet + remaining_msg,
          hashlib.sha1
      ).digest()
      assert received_mac == calculated_mac, \
        'MACs did not match: %s != %s' % (repr(received_mac), repr(calculated_mac))
      print colors.cyan('MAC validated correctly!')

    # Pull the payload out of the message
    data = (initial_packet + remaining_msg)[4:]
    index, padding_len = parse_byte(data, 0)
    payload_len = packet_len - padding_len - index
    payload = data[index:payload_len + index]

    self._packets_received_counter += 1
    print colors.green('< Received: %s' % repr(payload))

    return payload