def import_module(name_or_path: Union[Path, str]) -> 'module':
    """Dynamically import a module from a file path or module name.
    e.g. file path: `/home/user/crawler-cluster/crawler_cluster/examples/data/functions.py`.
    e.g. module name: `crawler_cluster.examples.data.functions`
    """
    name_or_path = str(name_or_path)
    # file path has '/' separator. module path has '.' seperator.
    if '/' in name_or_path:
        # import module from .py file
        logger.info(f"Importing module from file path: {name_or_path}")
        module_spec = importlib.util.spec_from_file_location(
            Path(name_or_path).stem, name_or_path)
        module = importlib.util.module_from_spec(module_spec)
        try:
            module_spec.loader.exec_module(module)
            logger.info(f"Successfully imported: {name_or_path}")
            return module
        except FileNotFoundError:
            logger.error(
                cowsay.daemon(
                    f"Module not found: {name_or_path}! Make sure file path is valid."
                ))
    else:
        # import module from module path.
        try:
            logger.info(f"Importing installed module: {name_or_path}")
            module = importlib.import_module(name_or_path)
            logger.info(f"Successfully imported: {name_or_path}")
            return module
        except ImportError:
            logger.error(
                cowsay.daemon(
                    f"Could not import module {name_or_path}! Make sure module is installed, or provide a valid path to the file."
                ))
def import_module(module_path: str) -> 'module':
    """Dynamically import a module from a file path or module name."""
    # file path has '/' separator. module path has '.' seperator.
    if '/' in module_path:
        # import module from .py file
        module_spec = importlib.util.spec_from_file_location(
            Path(module_path).stem, module_path)
        module = importlib.util.module_from_spec(module_spec)
        try:
            module_spec.loader.exec_module(module)
            return module
        except FileNotFoundError:
            logging.error(cowsay.daemon(f"Module not found: {module}"))
    else:
        # import module from module path.
        try:
            return importlib.import_module(module_path)
        except ImportError:
            logging.error(
                cowsay.daemon(f"Could not import module {module_path}!"))
Beispiel #3
0
def predict(test_data, checkpoint_dir, target_dict, fun=False):
    """
    Prints out a prediction for a given input.
    
    :param test_data: data that you want to make the prediction on 
    :type test_data: numpy 
    :param checkpoint_dir: checkpoint directory 
    :type checkpoint_dir: str
    :param target_dict: map between int and url 
    :type target_dict: dict
    :param fun: wanna have fun?
    :type fun: bool
    """
    model, model_summary = build_model(len(set(test_data[0])),
                                       test_data.shape[1])
    model = compile_model(model, optimizer=tf.keras.optimizers.Nadam())
    model.load_weights(tf.train.latest_checkpoint(checkpoint_dir))

    tf.logging.debug(model_summary)

    time1 = time.time()
    predictions = model.predict(test_data)
    time2 = time.time()
    tf.logging.debug("time: {}".format(time2 - time1))
    result = []

    for prediction in predictions:
        guess = np.argmax(prediction.flatten())
        result.append([(guess, target_dict[guess])])

    if fun == False:
        for r in result:
            print(TermColors.GREEN + "=======================> " + str(r) +
                  " <=======================" + TermColors.ENDC)
    else:
        for r in result:
            print(TermColors.RED)
            cowsay.daemon("Oh no you found out about:\n " + str(r[0][1]))
            print(TermColors.ENDC)
Beispiel #4
0
import cowsay
cowsay.daemon("Hi")
cowsay.dragon("Hey")
cowsay.cow("Konstantina")
Beispiel #5
0
import cowsay
cowsay.daemon("I'm an ineffective-image")
Beispiel #6
0
import cowsay
cowsay.daemon("Greetings!")
Beispiel #7
0
import cowsay

cowsay.daemon("Acker Code")
Beispiel #8
0
    UNDERLINE = '\033[4m'


start_time = time.time()

url = 'http://192.168.34.8:8080/etalon/'
cam_list_downloaded = []
cam_list_not_loaded = []
laps = 1 / 100

system('cls')
print(
    f'\n\n\n\n{bcolors.WARNING}Need to to fetch{bcolors.FAIL} {len(cam_list) - len(cam_list_downloaded)} {bcolors.WARNING}files from {url}{bcolors.ENDC}'
)
cowsay.daemon(
    f"{bcolors.WARNING}All is ready to start downloading files.\nPlease press Enter to START.{bcolors.ENDC}"
)
input()
system('cls')

laps = laps
check = 0

for camera in cam_list:
    file = camera + '.jpg'
    full_path = url + file
    destination = 'C:/downloaded/' + file
    print(
        f"\n\n{bcolors.FAIL}DON'T CLOSE THE APPLICATION OR SHUTDOWN THE COMPUTER{bcolors.ENDC}\n"
    )
    print(
async def daemon(ctx, *, text):
    await ctx.send('```' + cowsay.daemon(text) + '```')
Beispiel #10
0
import cowsay
cowsay.daemon("I am the Deamon")
#!/usr/bin/env python3
# encoding: utf-8

import cowsay

num = int(input("Input a number: "))

if num > 1:
    for i in range(2, num):
        if (num % i) == 0:
            cowsay.beavis(str(num) + " is not a prime number")
            print(i, "times", num // i, "is", num)
            break
    else:
        cowsay.cheese(str(num) + " is a prime number")
else:
    cowsay.daemon(str(num) + " is not a prime number")
Beispiel #12
0
import cowsay

cowsay.daemon("Hi Deamon")
Beispiel #13
0
import cowsay
# print(cowsay.char_names)
name = input('Enter your name : ')
string = f'Hello {name}'

cowsay.daemon(string)
cowsay.cow(string)
cowsay.dragon(string)
cowsay.beavis(string)
cowsay.cheese(string)
cowsay.ghostbusters(string)
cowsay.kitty(string)
cowsay.meow(string)
cowsay.milk(string)
cowsay.pig(string)
cowsay.stegosaurus(string)
cowsay.stimpy(string)
cowsay.turkey(string)
cowsay.turtle(string)
cowsay.tux(string)