Skip to content

Commit

Permalink
Merge branch 'main' of github.com:diverso-lab/uvlhub
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Sep 10, 2024
2 parents e6455b1 + cbbbb05 commit 992aa12
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FLASK_APP_NAME="UVLHUB.IO(dev)"
FLASK_ENV=development
FLASK_APP=app
SECRET_KEY=dev_test_key_1234567890abcdefghijklmnopqrstu
DOMAIN=localhost
DOMAIN=localhost:5000
MARIADB_HOSTNAME=localhost
MARIADB_PORT=3306
MARIADB_DATABASE=uvlhubdb
Expand Down
11 changes: 9 additions & 2 deletions core/blueprints/base_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, send_from_directory
from flask import Blueprint, Response
import os


Expand All @@ -21,4 +21,11 @@ def add_script_route(self):
print(f"(BaseBlueprint) -> {script_path} does not exist.")

def send_script(self):
return send_from_directory(self.module_path, 'assets/scripts.js')
script_path = os.path.join(self.module_path, 'assets', 'scripts.js')

try:
with open(script_path, 'r') as file:
script_content = file.read()
return Response(script_content, mimetype='application/javascript')
except FileNotFoundError:
return Response(f"File not found: {script_path}", status=404)
26 changes: 25 additions & 1 deletion rosemary/commands/make_module.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import stat
import click
from jinja2 import Environment, FileSystemLoader, select_autoescape
import os
Expand Down Expand Up @@ -50,7 +51,7 @@ def make_module(name):
'forms.py': 'module_forms.py.j2',
'seeders.py': 'module_seeders.py.j2',
os.path.join('templates', name, 'index.html'): 'module_templates_index.html.j2',
os.path.join('assets', name, 'scripts.js'): 'module_scripts.js.j2',
'assets/scripts.js': 'module_scripts.js.j2',
'tests/test_unit.py': 'module_tests_test_unit.py.j2',
'tests/locustfile.py': 'module_tests_locustfile.py.j2',
'tests/test_selenium.py': 'module_tests_test_selenium.py.j2'
Expand All @@ -77,3 +78,26 @@ def make_module(name):
open(os.path.join(module_path, filename), 'a').close() # Create empty file if there is no template.

click.echo(click.style(f"Module '{name}' created successfully.", fg='green'))

# Change the owner of the main folder of the module
os.chown(module_path, 1000, 1000)

# Change permissions to drwxrwxr-x (chmod 775)
os.chmod(module_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH)

# Change the owner of all created files and directories to UID 1000 and GID 1000
uid = 1000
gid = 1000

for root, dirs, files in os.walk(module_path):
for dir_ in dirs:
dir_path = os.path.join(root, dir_)
os.chown(dir_path, uid, gid)
os.chmod(dir_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH)

for file_ in files:
file_path = os.path.join(root, file_)
os.chown(file_path, uid, gid)
os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH)

click.echo(click.style(f"Module '{name}' permissions changed successfully.", fg='green'))

0 comments on commit 992aa12

Please sign in to comment.