diff --git a/home/bin/make_color.py b/home/bin/make_color.py index 22646c1..694be8f 100755 --- a/home/bin/make_color.py +++ b/home/bin/make_color.py @@ -1,10 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # this program generates a color value by hashing the input string from colorsys import hsv_to_rgb from hashlib import md5 import argparse - +import logging def float_to_16b(component): # print(hex_comp) @@ -28,6 +28,7 @@ def hsv_to_linux(hue, saturation, value): if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) parser = argparse.ArgumentParser(description="Generate a rgb color by hashing the input string", epilog="Example usage: make_color.py cloud.ipr.univ-rennes.fr 0.7 0.5 linux") parser.add_argument("seed_string", type=str, help="the string to be hashed to generate the pseudo random hue of the color") @@ -44,6 +45,10 @@ if __name__ == '__main__': rgb_string_format = args.rgb_string_format # eg 'osx' 'linux' # color_hue = int(md5(seed_string).hexdigest()[:8], 16) # taken from http://www.guguncube.com/3237/python-string-to-number-hash color_hue = float(int(md5(seed_string.encode('utf-8')).hexdigest(), 16) % 100000) / 100000.0 + # logging.debug(md5(seed_string.encode('utf-8')).hexdigest()) + # logging.debug(int(md5(seed_string.encode('utf-8')).hexdigest(), 16)) + # logging.debug(int(md5(seed_string.encode('utf-8')).hexdigest(), 16) % 100000) + # logging.debug('color_hue : %f', color_hue) # print(color_hue) if rgb_string_format == 'osx':