Ejemplo n.º 1
0
def build_scripts():
    '''
    Build script JSON data for UIs (default), don't overwrite

    :return:
    '''

    scripts = find_files(os.path.join('.', 'scripts'), '.py')
    collect_argparses(scripts)
Ejemplo n.º 2
0
def build_scripts():
    '''
    Build script JSON data for UIs (default), don't overwrite

    :return:
    '''

    scripts = find_files(os.path.join('.', 'scripts'), '.py')
    collect_argparses(scripts)
Ejemplo n.º 3
0
def build_scripts():
    '''
    Build script JSON data for UIs (default), don't overwrite

    :return:
    '''

    for f in app.config.get('SCRIPT_FOLDERS'):
        scripts = find_files(f, '.py')
        collect_argparses(scripts)
Ejemplo n.º 4
0
def build_scripts():
    '''
    Build script JSON data for UIs (default), don't overwrite

    :return:
    '''

    for f in app.config.get('SCRIPT_FOLDERS'):
        scripts = find_files(f, '.py')
        collect_argparses(scripts)
Ejemplo n.º 5
0
def find_scripts():
    '''
    Loader that iterates over script config folder, reading JSON files and updating the
    admin config to store. The config itself is not loaded (parsed and managed on output).

    :return:
    '''

    for f in app.config.get('SCRIPT_FOLDERS'):

        jsons = find_files(f, '.json')

        for json_filename in jsons:
            # Extract to dict structure, then interrogate the database to see if we already have this and update
            with open(json_filename, 'r') as f:
                jo = json.load(f)

            full_path = os.path.realpath(json_filename)

            # Try query the db for object with the same (?hash)
            script = Script.query.filter_by(
                config_path=full_path).first()  # Will be only one
            if not script:
                script = Script(config_path=full_path)  # Create it

            # Amend the object
            script.exec_path = jo['program']['path']
            script.description = jo['program']['description']
            script.name = jo['program']['name']

            if 'documentation' in jo['program']:
                script.doc_path = jo['program']['documentation']
            elif os.path.exists(os.path.splitext(script.exec_path)[0] + '.md'):
                script.doc_path = os.path.splitext(script.exec_path)[0] + '.md'
            elif os.path.exists(
                    os.path.splitext(script.config_path)[0] + '.md'):
                script.doc_path = os.path.splitext(
                    script.config_path)[0] + '.md'

            db.session.add(script)
            db.session.commit()
Ejemplo n.º 6
0
def find_scripts():
    '''
    Loader that iterates over script config folder, reading JSON files and updating the
    admin config to store. The config itself is not loaded (parsed and managed on output).

    :return:
    '''

    for f in app.config.get('SCRIPT_FOLDERS'):

        jsons = find_files(f, '.json')

        for json_filename in jsons:
            # Extract to dict structure, then interrogate the database to see if we already have this and update
            with open(json_filename, 'r') as f:
                jo = json.load(f)

            full_path = os.path.realpath(json_filename)

            # Try query the db for object with the same (?hash)
            script = Script.query.filter_by(config_path=full_path).first()  # Will be only one
            if not script:
                script = Script(config_path=full_path)  # Create it

            # Amend the object
            script.exec_path = jo['program']['path']
            script.description = jo['program']['description']
            script.name = jo['program']['name']

            if 'documentation' in jo['program']:
                script.doc_path = jo['program']['documentation']
            elif os.path.exists(os.path.splitext(script.exec_path)[0] + '.md'):
                script.doc_path = os.path.splitext(script.exec_path)[0] + '.md'
            elif os.path.exists(os.path.splitext(script.config_path)[0] + '.md'):
                script.doc_path = os.path.splitext(script.config_path)[0] + '.md'

            db.session.add(script)
            db.session.commit()