2016-02-24 09:33:49 +01:00
|
|
|
import os
|
2016-02-26 15:32:36 +01:00
|
|
|
import time
|
2016-03-03 17:44:01 +01:00
|
|
|
from platform import system
|
|
|
|
|
2016-02-19 22:10:24 +01:00
|
|
|
|
2016-05-13 11:08:45 +02:00
|
|
|
program_version = '0.1.2'
|
2016-02-21 21:25:37 +01:00
|
|
|
|
|
|
|
|
2016-02-19 22:10:24 +01:00
|
|
|
def log(data):
|
2016-03-30 20:05:21 +02:00
|
|
|
with open(curr_directory() + '/logs.log', 'a') as fl:
|
2016-02-29 22:23:03 +01:00
|
|
|
fl.write(str(data) + '\n')
|
2016-02-19 22:10:24 +01:00
|
|
|
|
2016-02-20 09:06:24 +01:00
|
|
|
|
2016-02-24 09:33:49 +01:00
|
|
|
def curr_directory():
|
|
|
|
return os.path.dirname(os.path.realpath(__file__))
|
2016-02-24 16:32:35 +01:00
|
|
|
|
|
|
|
|
2016-02-26 15:32:36 +01:00
|
|
|
def curr_time():
|
2016-03-13 13:06:06 +01: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 15:32:36 +01:00
|
|
|
|
|
|
|
|
2016-05-06 12:31:18 +02:00
|
|
|
# obsolete
|
2016-03-03 17:44:01 +01:00
|
|
|
def get_style(style):
|
|
|
|
if style != 'default':
|
|
|
|
return style
|
|
|
|
else:
|
2016-05-06 12:31:18 +02:00
|
|
|
if system() == 'Windows':
|
2016-03-03 17:44:01 +01:00
|
|
|
return 'windows'
|
2016-05-06 12:31:18 +02:00
|
|
|
else:
|
|
|
|
return 'gtk'
|
2016-03-03 17:44:01 +01:00
|
|
|
|
|
|
|
|
2016-02-24 16:32:35 +01:00
|
|
|
class Singleton(object):
|
|
|
|
|
2016-03-03 20:19:09 +01: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
|