Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
tddd96-grupp1
teknikattan-scoring-system
Commits
a987e4ae
Commit
a987e4ae
authored
3 years ago
by
robban64
Browse files
Options
Downloads
Patches
Plain Diff
fix: populate is now done in main.py with argument populate
parent
7fa2b3a7
No related branches found
No related tags found
No related merge requests found
Pipeline
#47139
passed
3 years ago
Stage: setup
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.vscode/tasks.json
+1
-1
1 addition, 1 deletion
.vscode/tasks.json
server/main.py
+30
-19
30 additions, 19 deletions
server/main.py
server/populate.py
+2
-0
2 additions, 0 deletions
server/populate.py
with
33 additions
and
20 deletions
.vscode/tasks.json
+
1
−
1
View file @
a987e4ae
...
...
@@ -66,7 +66,7 @@
"label"
:
"Populate database"
,
"type"
:
"shell"
,
"group"
:
"build"
,
"command"
:
"env/Scripts/python
populate.py
"
,
"command"
:
"env/Scripts/python
main.py populate dev lite
"
,
"problemMatcher"
:
[],
"options"
:
{
"cwd"
:
"${workspaceFolder}/server"
...
...
This diff is collapsed.
Click to expand it.
server/main.py
+
30
−
19
View file @
a987e4ae
import
sys
from
app
import
create_app
from
app
import
create_app
,
db
from
populate
import
create_default_items
"""
Action-arg1: server(default), populate
Mode-arg2: dev(default), prod
, test
Mode-arg2: dev(default), prod
Database-arg3: lite(default), postgre
"""
def
start_server
(
mode
,
database
):
print
(
f
"
Starting server in
{
mode
}
mode with database
{
database
}
...
"
)
app
,
sio
=
create_app
(
mode
,
database
)
sio
.
run
(
app
)
def
populate_server
(
mode
,
database
):
print
(
f
"
Populating server in
{
mode
}
mode with database
{
database
}
...
"
)
app
,
_
=
create_app
(
mode
,
database
)
with
app
.
app_context
():
db
.
drop_all
()
db
.
create_all
()
create_default_items
()
print
(
"
Task populate done
"
)
if
__name__
==
"
__main__
"
:
argv
=
sys
.
argv
# action = argv[1] if len(argv) > 1 else "server"
mode
=
argv
[
1
]
if
len
(
argv
)
>
1
else
"
dev
"
# database = argv[3] if len(argv) > 3 else "lite"
# if mode == "prod":
# database = "postgre"
action
=
argv
[
1
]
if
len
(
argv
)
>
1
else
"
server
"
mode
=
argv
[
2
]
if
len
(
argv
)
>
2
else
"
dev
"
database
=
argv
[
3
]
if
len
(
argv
)
>
3
else
"
lite
"
if
mode
==
"
dev
"
or
mode
==
"
test
"
:
database
=
argv
[
2
]
if
len
(
argv
)
>
2
else
"
lite
"
elif
mode
==
"
prod
"
:
if
mode
==
"
prod
"
:
database
=
"
postgre
"
else
:
print
(
"
Invalid args
"
)
print
(
"
Dev args: no args,
'
dev lite
'
or
'
dev postgre
'"
)
print
(
"
Prod args:
'
prod
'
\n
"
)
sys
.
exit
(
-
1
)
print
(
f
"
Starting server in
{
mode
}
mode with database
{
database
}
...
"
)
app
,
sio
=
create_app
(
mode
,
database
)
sio
.
run
(
app
)
if
action
==
"
server
"
:
start_server
(
mode
,
database
)
elif
action
==
"
populate
"
:
populate_server
(
mode
,
database
)
This diff is collapsed.
Click to expand it.
server/populate.py
+
2
−
0
View file @
a987e4ae
...
...
@@ -144,6 +144,7 @@ def create_default_items():
# dbc.add.question_answer("ett svar som ger 3p", 3, 1, 3)
"""
if __name__ ==
"
__main__
"
:
argv = sys.argv
...
...
@@ -169,3 +170,4 @@ if __name__ == "__main__":
create_default_items()
print(
"
Task populating done
"
)
"""
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