Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bwinf
medal
Commits
fb89cdc1
Commit
fb89cdc1
authored
Feb 14, 2019
by
Robert Czechowski
Browse files
Clean up debug message noise
parent
1e820d3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/configreader_yaml.rs
View file @
fb89cdc1
...
...
@@ -21,14 +21,9 @@ struct ContestYaml {
pub
fn
parse_yaml
(
content
:
&
str
,
filename
:
&
str
,
directory
:
&
str
)
->
Option
<
Contest
>
{
let
config
:
ContestYaml
=
serde_yaml
::
from_str
(
&
content
)
.unwrap
();
println!
(
"hi"
);
let
mut
contest
=
Contest
::
new
(
directory
.to_string
(),
filename
.to_string
(),
config
.name
?
,
config
.duration_minutes
?
,
config
.public_listing
.unwrap_or
(
false
),
None
,
None
);
println!
(
"hi"
);
for
(
name
,
info
)
in
config
.tasks
?
{
println!
(
"hi"
);
if
let
serde_yaml
::
Value
::
String
(
name
)
=
name
{
let
mut
taskgroup
=
Taskgroup
::
new
(
name
);
match
info
{
...
...
src/db_apply_migrations.rs
View file @
fb89cdc1
...
...
@@ -16,17 +16,18 @@ pub fn test<C: MedalConnection>(conn: &mut C) {
.collect
();
paths
.sort_by_key
(|
dir
|
dir
.path
());
for
path
in
paths
{
println!
(
"Found: {}."
,
path
.path
()
.display
());
for
path
in
paths
{
let
filename
=
path
.file_name
()
.into_string
()
.unwrap
();
if
!
conn
.migration_already_applied
(
&
filename
)
{
let
mut
file
=
fs
::
File
::
open
(
path
.path
())
.unwrap
();
let
mut
contents
=
String
::
new
();
file
.read_to_string
(
&
mut
contents
)
.unwrap
();
conn
.apply_migration
(
&
filename
,
&
contents
);
}
else
{
println!
(
"Already applied."
)
println!
(
"Found: {}. Applying …"
,
path
.path
()
.display
());
}
/*else { // TODO: Show in high debug level only
println!("Found: {}. Already applied", path.path().display());
}*/
...
...
src/main.rs
View file @
fb89cdc1
...
...
@@ -62,9 +62,9 @@ pub struct Config {
fn
read_config_from_file
(
file
:
&
Path
)
->
Config
{
use
std
::
io
::
Read
;
println!
(
"Reading
C
onfig file '{}'"
,
file
.to_str
()
.unwrap_or
(
"<Encoding error>"
));
println!
(
"Reading
c
onfig
uration
file '{}'"
,
file
.to_str
()
.unwrap_or
(
"<Encoding error>"
));
let
mut
config
:
Config
=
if
let
Ok
(
mut
file
)
=
fs
::
File
::
open
(
file
)
{
let
mut
contents
=
String
::
new
();
file
.read_to_string
(
&
mut
contents
)
.unwrap
();
...
...
@@ -78,7 +78,7 @@ fn read_config_from_file(file: &Path) -> Config {
if
config
.port
.is_none
()
{
config
.port
=
Some
(
8080
)}
if
config
.self_url
.is_none
()
{
config
.self_url
=
Some
(
"http://localhost:8080"
.to_string
())}
println!
(
"
I will ask
OAuth
-
providers to redirect to {}"
,
config
.self_url
.as_ref
()
.unwrap
());
println!
(
"OAuth
providers
will be told
to redirect to {}"
,
config
.self_url
.as_ref
()
.unwrap
());
config
}
...
...
@@ -108,7 +108,6 @@ struct Opt {
fn
read_contest
(
p
:
&
path
::
PathBuf
)
->
Option
<
Contest
>
{
use
std
::
fs
::
File
;
use
std
::
io
::
Read
;
println!
(
"Try to read some file …"
);
let
mut
file
=
File
::
open
(
p
)
.unwrap
();
let
mut
contents
=
String
::
new
();
...
...
@@ -191,8 +190,8 @@ fn add_admin_user(conn: &mut Connection, resetpw: bool) {
fn
main
()
{
let
opt
=
Opt
::
from_args
();
println!
(
"{:?}"
,
opt
);
//
println!("{:?}", opt);
// Show in different debug level?
let
mut
config
=
read_config_from_file
(
&
opt
.configfile
);
if
opt
.databasefile
.is_some
()
{
config
.database_file
=
opt
.databasefile
;
}
...
...
@@ -207,26 +206,9 @@ fn main() {
refresh_all_contests
(
&
mut
conn
);
println!
(
"Hello, world!"
);
let
contest
=
conn
.get_contest_by_id_complete
(
1
);
add_admin_user
(
&
mut
conn
,
opt
.resetadminpw
);
println!
(
"Contest {}"
,
contest
.name
);
for
taskgroup
in
contest
.taskgroups
{
print!
(
" Task {}: "
,
taskgroup
.name
);
for
task
in
taskgroup
.tasks
{
print!
(
"{} ({}) "
,
task
.stars
,
task
.location
);
}
println!
(
""
);
}
match
start_server
(
conn
,
config
)
{
Ok
(
_
)
=>
println!
(
"
Ok
"
),
Err
(
_
)
=>
println!
(
"Err"
)
Ok
(
_
)
=>
println!
(
"
Server started
"
),
Err
(
_
)
=>
println!
(
"Err
or on server start …
"
)
};
println!
(
"Could not run server. Is the port already in use?"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment