Skip to content

Commit 992aa12

Browse files
committed
Merge branch 'main' of github.com:diverso-lab/uvlhub
2 parents e6455b1 + cbbbb05 commit 992aa12

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

.env.local.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FLASK_APP_NAME="UVLHUB.IO(dev)"
22
FLASK_ENV=development
33
FLASK_APP=app
44
SECRET_KEY=dev_test_key_1234567890abcdefghijklmnopqrstu
5-
DOMAIN=localhost
5+
DOMAIN=localhost:5000
66
MARIADB_HOSTNAME=localhost
77
MARIADB_PORT=3306
88
MARIADB_DATABASE=uvlhubdb

core/blueprints/base_blueprint.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask import Blueprint, send_from_directory
1+
from flask import Blueprint, Response
22
import os
33

44

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

2323
def send_script(self):
24-
return send_from_directory(self.module_path, 'assets/scripts.js')
24+
script_path = os.path.join(self.module_path, 'assets', 'scripts.js')
25+
26+
try:
27+
with open(script_path, 'r') as file:
28+
script_content = file.read()
29+
return Response(script_content, mimetype='application/javascript')
30+
except FileNotFoundError:
31+
return Response(f"File not found: {script_path}", status=404)

rosemary/commands/make_module.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import stat
12
import click
23
from jinja2 import Environment, FileSystemLoader, select_autoescape
34
import os
@@ -50,7 +51,7 @@ def make_module(name):
5051
'forms.py': 'module_forms.py.j2',
5152
'seeders.py': 'module_seeders.py.j2',
5253
os.path.join('templates', name, 'index.html'): 'module_templates_index.html.j2',
53-
os.path.join('assets', name, 'scripts.js'): 'module_scripts.js.j2',
54+
'assets/scripts.js': 'module_scripts.js.j2',
5455
'tests/test_unit.py': 'module_tests_test_unit.py.j2',
5556
'tests/locustfile.py': 'module_tests_locustfile.py.j2',
5657
'tests/test_selenium.py': 'module_tests_test_selenium.py.j2'
@@ -77,3 +78,26 @@ def make_module(name):
7778
open(os.path.join(module_path, filename), 'a').close() # Create empty file if there is no template.
7879

7980
click.echo(click.style(f"Module '{name}' created successfully.", fg='green'))
81+
82+
# Change the owner of the main folder of the module
83+
os.chown(module_path, 1000, 1000)
84+
85+
# Change permissions to drwxrwxr-x (chmod 775)
86+
os.chmod(module_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH)
87+
88+
# Change the owner of all created files and directories to UID 1000 and GID 1000
89+
uid = 1000
90+
gid = 1000
91+
92+
for root, dirs, files in os.walk(module_path):
93+
for dir_ in dirs:
94+
dir_path = os.path.join(root, dir_)
95+
os.chown(dir_path, uid, gid)
96+
os.chmod(dir_path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH)
97+
98+
for file_ in files:
99+
file_path = os.path.join(root, file_)
100+
os.chown(file_path, uid, gid)
101+
os.chmod(file_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH)
102+
103+
click.echo(click.style(f"Module '{name}' permissions changed successfully.", fg='green'))

0 commit comments

Comments
 (0)