toxygen/src/util.py

35 lines
641 B
Python
Raw Normal View History

import os
2016-02-26 14:32:36 +00:00
import time
2016-02-19 21:10:24 +00:00
program_version = '0.0.1 (alpha)'
2016-02-19 21:10:24 +00:00
def log(data):
with open('logs.log', 'a') as fl:
2016-02-19 21:10:24 +00:00
fl.write(str(data))
2016-02-20 08:06:24 +00:00
def string_to_bin(tox_id):
return tox_id.decode('hex')
2016-02-20 08:06:24 +00:00
def bin_to_string(raw_id):
res = ''.join('{:02x}'.format(ord(x)) for x in raw_id)
return res.upper()
def curr_directory():
return os.path.dirname(os.path.realpath(__file__))
2016-02-26 14:32:36 +00:00
def curr_time():
return time.strftime("%H:%M:")
class Singleton(object):
2016-02-25 20:40:00 +00:00
def __new__(cls, *args):
if not hasattr(cls, 'instance'):
2016-02-25 20:40:00 +00:00
cls.instance = super(Singleton, cls,).__new__(cls, *args)
return cls.instance