Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
fa0090db
Verified
Commit
fa0090db
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of edugit.org:AlekSIS/official/AlekSIS-Core
parents
2a258094
59be5513
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#4533
passed
4 years ago
Stage: test
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/core/util/core_helpers.py
+20
-14
20 additions, 14 deletions
aleksis/core/util/core_helpers.py
poetry.lock
+638
-701
638 additions, 701 deletions
poetry.lock
pyproject.toml
+1
-0
1 addition, 0 deletions
pyproject.toml
with
659 additions
and
715 deletions
aleksis/core/util/core_helpers.py
+
20
−
14
View file @
fa0090db
import
os
import
pkgutil
import
time
from
datetime
import
datetime
,
timedelta
from
importlib
import
import_module
...
...
@@ -8,6 +7,11 @@ from operator import itemgetter
from
typing
import
Any
,
Callable
,
Optional
,
Sequence
,
Union
from
uuid
import
uuid4
try
:
from
importlib
import
metadata
except
ImportError
:
import
importlib_metadata
as
metadata
from
django.conf
import
settings
from
django.db.models
import
Model
,
QuerySet
from
django.http
import
HttpRequest
...
...
@@ -59,14 +63,8 @@ def dt_show_toolbar(request: HttpRequest) -> bool:
def
get_app_packages
()
->
Sequence
[
str
]:
"""
Find all packages within the aleksis.apps namespace.
"""
# Import error are non-fatal here because probably simply no app is installed.
try
:
import
aleksis.apps
except
ImportError
:
return
[]
return
[
f
"
aleksis.apps.
{
pkg
[
1
]
}
"
for
pkg
in
pkgutil
.
iter_modules
(
aleksis
.
apps
.
__path__
)]
"""
Find all registered apps from the setuptools entrypoint.
"""
return
[
f
"
{
ep
.
module
}
.
{
ep
.
attr
}
"
for
ep
in
metadata
.
entry_points
()[
"
aleksis.app
"
]]
def
merge_app_settings
(
...
...
@@ -81,11 +79,19 @@ def merge_app_settings(
Note: Only selected names will be imported frm it to minimise impact of
potentially malicious apps!
"""
for
pkg
in
get_app_packages
():
try
:
mod_settings
=
import_module
(
pkg
+
"
.settings
"
)
except
ImportError
:
# Import errors are non-fatal. They mean that the app has no settings.py.
for
app
in
get_app_packages
():
pkg
=
"
.
"
.
join
(
app
.
split
(
"
.
"
)[:
-
2
])
mod_settings
=
None
while
"
.
"
in
pkg
:
try
:
mod_settings
=
import_module
(
pkg
+
"
.settings
"
)
except
ImportError
:
# Import errors are non-fatal.
pkg
=
"
.
"
.
join
(
pkg
.
split
(
"
.
"
)[:
-
1
])
continue
break
if
not
mod_settings
:
# The app does not have settings
continue
app_setting
=
getattr
(
mod_settings
,
setting
,
None
)
...
...
This diff is collapsed.
Click to expand it.
poetry.lock
+
638
−
701
View file @
fa0090db
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
0
View file @
fa0090db
...
...
@@ -88,6 +88,7 @@ django-health-check = "^3.12.1"
psutil
=
"^5.7.0"
celery-progress
=
"^0.0.14"
django-prometheus
=
"^2.1.0"
importlib-metadata
=
{
version
=
"^2.0.0"
,
python
=
"<3.8"
}
[tool.poetry.extras]
ldap
=
[
"django-auth-ldap"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment