From 87a2d3ca22d502f510ea669ff1c29d8806d0b98b Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Wed, 17 Jun 2026 16:01:10 +0200 Subject: [PATCH] fixed make_color.py to work on machines that don't have python2 work related to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4405] --- home/bin/make_color.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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':