2016-02-24 11:33:49 +03:00
|
|
|
import os
|
2016-02-26 17:32:36 +03:00
|
|
|
import time
|
2016-03-03 19:44:01 +03:00
|
|
|
|
2016-02-20 00:10:24 +03:00
|
|
|
|
2016-05-28 22:43:51 +03:00
|
|
|
program_version = '0.1.3'
|
2016-02-21 23:25:37 +03:00
|
|
|
|
|
|
|
|
2016-02-20 00:10:24 +03:00
|
|
|
def log(data):
|
2016-03-30 21:05:21 +03:00
|
|
|
with open(curr_directory() + '/logs.log', 'a') as fl:
|
2016-03-01 00:23:03 +03:00
|
|
|
fl.write(str(data) + '\n')
|
2016-02-20 00:10:24 +03:00
|
|
|
|
2016-02-20 11:06:24 +03:00
|
|
|
|
2016-02-24 11:33:49 +03:00
|
|
|
def curr_directory():
|
|
|
|
return os.path.dirname(os.path.realpath(__file__))
|
2016-02-24 18:32:35 +03:00
|
|
|
|
|
|
|
|
2016-02-26 17:32:36 +03:00
|
|
|
def curr_time():
|
2016-03-13 15:06:06 +03:00
|
|
|
return time.strftime('%H:%M')
|
|
|
|
|
|
|
|
|
|
|
|
def convert_time(t):
|
|
|
|
sec = int(t) - time.timezone
|
|
|
|
m, s = divmod(sec, 60)
|
|
|
|
h, m = divmod(m, 60)
|
|
|
|
d, h = divmod(h, 24)
|
|
|
|
return '%02d:%02d' % (h, m)
|
2016-02-26 17:32:36 +03:00
|
|
|
|
|
|
|
|
2016-02-24 18:32:35 +03:00
|
|
|
class Singleton(object):
|
|
|
|
|
2016-03-03 22:19:09 +03:00
|
|
|
def __new__(cls, *args, **kwargs):
|
|
|
|
if not hasattr(cls, '_instance'):
|
|
|
|
cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
|
|
|
|
return cls._instance
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_instance(cls):
|
|
|
|
return cls._instance
|