예제 #1
0
def get_version() -> str:
    try:
        with open(resource_path('VERSION')) as version_file:
            version = f'v{version_file.read().strip()}'
    except FileNotFoundError:
        version = 'v0.0.0'
    return version
예제 #2
0
 def __reload_app_settings(self):
     if self.mqtt_rest_bridge_setting.master:
         path: str = self.fallback_app_master_settings_file
     else:
         path: str = self.fallback_app_settings_file
     app_setting = resource_path(path)
     data = self.__read_file(app_setting, "", False)
     installable_app_settings = data.get(InstallableAppSetting.KEY, [])
     if len(installable_app_settings) > 0:
         self.__installable_app_settings = [InstallableAppSetting().reload(s) for s in installable_app_settings]
예제 #3
0
 def create_service(self):
     lines = []
     with open(resource_path(
             'systemd/nubeio-rubix-bios.service')) as systemd_file:
         for line in systemd_file.readlines():
             if '<working_dir>' in line and self.__wd:
                 line = line.replace('<working_dir>', self.__wd)
             if '<device_type>' in line and self.__device_type:
                 line = line.replace('<device_type>', self.__device_type)
             if ' --auth' in line and not self.__auth:
                 line = line.replace(' --auth', '')
             lines.append(line)
     return lines
예제 #4
0
 def create_service(self):
     lines = []
     with open(resource_path(
             'systemd/nubeio-app-go-service.service')) as systemd_file:
         wd: str = self.get_wd()
         global_dir: str = self.get_global_dir()
         for line in systemd_file.readlines():
             if '<pre_start_sleep>' in line:
                 line = line.replace('<pre_start_sleep>',
                                     str(self.pre_start_sleep))
             if '<working_dir>' in line and wd:
                 line = line.replace('<working_dir>', wd)
             if '<port>' in line and self.port:
                 line = line.replace('<port>', str(self.port))
             if '<global_dir>' in line and global_dir:
                 line = line.replace('<global_dir>', global_dir)
             if '<name>' in line and self.repo_name:
                 line = line.replace('<name>', self.repo_name)
             if '<description>' in line and self.description:
                 line = line.replace('<description>', self.description)
             lines.append(line)
     return lines
예제 #5
0
def get_version():
    details = toml.load(resource_path("pyproject.toml"))
    version = details.get('tool', {}).get('poetry', {}).get('version')
    return f'v{version}' if version else None
예제 #6
0
import time
from datetime import datetime

from flask import current_app
from rubix_http.resource import RubixResource

from src.lora import SerialConnectionListener
from src.mqtt import MqttClient
from src.pyinstaller import resource_path
from src.utils.project import get_version

startTime = time.time()
up_time_date = str(datetime.now())

try:
    with open(resource_path('VERSION')) as version_file:
        version = version_file.read().strip()
except FileNotFoundError:
    version = 'Fake'


def get_up_time():
    """
    Returns the number of seconds since the program started.
    """
    return time.time() - startTime


class Ping(RubixResource):
    @classmethod
    def get(cls):
예제 #7
0
from logging.config import fileConfig

from alembic import context
from flask import current_app
from sqlalchemy import engine_from_config
from sqlalchemy import pool

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
from src.pyinstaller import resource_path

config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(resource_path('./config/logging.conf'))
logger = logging.getLogger(__name__)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option(
    'sqlalchemy.url',
    str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.