fix package to work on pip installs

master
Laura Liberda 2020-12-03 08:25:22 +01:00
parent 6226b75fc2
commit 1f843d5468
2 changed files with 29 additions and 7 deletions

View File

@ -1,6 +1,31 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .librefi import LibreFi
import sys
__all__ = ['LibreFi']
from .librefi import LibreFi
from .logger import _Logger, LOG_LEVELS
from .utils import LFiError, FxckerError
def _real_main(argv=None):
librefi = LibreFi(logger=_Logger, log_level=LOG_LEVELS.DEBUG)
librefi._periodical_check()
def main(argv=None):
try:
_real_main(argv)
except LFiError:
sys.exit('ERROR (core): report this to librefi@selfisekai.rocks')
except FxckerError:
sys.exit('ERROR (fxcker): report this to librefi@selfisekai.rocks')
except KeyboardInterrupt:
sys.exit('\nERROR: Interrupted by user')
__all__ = [
'LibreFi',
'main',
'_real_main',
]

View File

@ -9,10 +9,7 @@ if __package__ is None and not hasattr(sys, 'frozen'):
path = os.path.realpath(os.path.abspath(__file__))
sys.path.insert(0, os.path.dirname(os.path.dirname(path)))
from librefi import LibreFi
from .logger import _Logger, LOG_LEVELS
librefi = LibreFi(logger=_Logger, log_level=LOG_LEVELS.DEBUG)
from librefi import main
if __name__ == '__main__':
librefi._periodical_check()
main()