#!/usr/bin/env python

import os
import time

def ensure_directory(directory):
	try:
		os.mkdir(directory)
	except (OSError, 17):
		pass

def hex_nybble(nybble):
	return '0123456789abcdef'[nybble]

def hex_byte(byte):
	return '%s%s' % (hex_nybble(byte/16), hex_nybble(byte & 0xf))

def random_string():
	file = open('/dev/urandom', 'r')
	bytes = file.read(16)
	file.close()
	result = ''
	for byte in bytes:
		result += hex_byte(ord(byte))
	return result

# note the relative paths!
# hcm is going to chdir to ~/.hcm/logs - if something else cd's away
# from there, these are going to go to the wrong place
ensure_directory(time.strftime('%Y'))
ensure_directory(time.strftime('%Y/%m'))
ensure_directory(time.strftime('%Y/%m/%d'))

print '%s-R%s' % (time.strftime('%Y/%m/%d/%a'), random_string())