Commit d3bb7fe1 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Remove debug print statements, clean up programm output

parent 6c948ff7
Pipeline #188 passed with stage
in 15 minutes and 33 seconds
...@@ -4,7 +4,6 @@ use std::io::Read; ...@@ -4,7 +4,6 @@ use std::io::Read;
use db_conn::MedalConnection; use db_conn::MedalConnection;
pub fn test<C: MedalConnection>(conn: &mut C) { pub fn test<C: MedalConnection>(conn: &mut C) {
println!("reading dirs");
let mut paths: Vec<_> = let mut paths: Vec<_> =
fs::read_dir(format!("migrations/{}", conn.dbtype())).unwrap() fs::read_dir(format!("migrations/{}", conn.dbtype())).unwrap()
.map(|r| r.unwrap()) .map(|r| r.unwrap())
...@@ -27,5 +26,4 @@ pub fn test<C: MedalConnection>(conn: &mut C) { ...@@ -27,5 +26,4 @@ pub fn test<C: MedalConnection>(conn: &mut C) {
println!("Found: {}. Already applied", path.path().display()); println!("Found: {}. Already applied", path.path().display());
}*/ }*/
} }
println!("finished");
} }
...@@ -77,19 +77,15 @@ pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, ...@@ -77,19 +77,15 @@ pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>,
let mut oauth_links: Vec<(String, String, String)> = Vec::new(); let mut oauth_links: Vec<(String, String, String)> = Vec::new();
if let Some(oauth_providers) = oauth_providers { if let Some(oauth_providers) = oauth_providers {
println!("tblub");
for oauth_provider in oauth_providers { for oauth_provider in oauth_providers {
oauth_links.push((oauth_provider.provider_id.to_owned(), oauth_links.push((oauth_provider.provider_id.to_owned(),
oauth_provider.login_link_text.to_owned(), oauth_provider.login_link_text.to_owned(),
oauth_provider.url.to_owned())); oauth_provider.url.to_owned()));
println!("testayy {}", oauth_provider.provider_id.to_owned());
} }
} }
data.insert("self_url".to_string(), to_json(&self_url)); data.insert("self_url".to_string(), to_json(&self_url));
data.insert("oauth_links".to_string(), to_json(&oauth_links)); data.insert("oauth_links".to_string(), to_json(&oauth_links));
/*contests.push("blaa".to_string());
data.insert("contest".to_string(), to_json(&contests));*/
("index".to_owned(), data) ("index".to_owned(), data)
} }
......
...@@ -236,15 +236,12 @@ fn prepare_and_start_server<C>(mut conn: C, config: Config, onlycontestscan: boo ...@@ -236,15 +236,12 @@ fn prepare_and_start_server<C>(mut conn: C, config: Config, onlycontestscan: boo
where C: MedalConnection + std::marker::Send + 'static, where C: MedalConnection + std::marker::Send + 'static,
db_objects::Contest: db_conn::MedalObject<C> db_objects::Contest: db_conn::MedalObject<C>
{ {
println!("connected!");
println!("applying migrations …");
db_apply_migrations::test(&mut conn); db_apply_migrations::test(&mut conn);
if onlycontestscan || config.no_contest_scan == Some(false) { if onlycontestscan || config.no_contest_scan == Some(false) {
println!("scanning for contests …"); print!("Scanning for contests …");
refresh_all_contests(&mut conn); refresh_all_contests(&mut conn);
println!("finished") println!(" Done")
} }
if !onlycontestscan { if !onlycontestscan {
...@@ -283,6 +280,9 @@ fn main() { ...@@ -283,6 +280,9 @@ fn main() {
if opt.databasefile.is_some() { if opt.databasefile.is_some() {
config.database_file = opt.databasefile; config.database_file = opt.databasefile;
} }
if config.database_file.is_none() {
config.database_file = Some(Path::new("medal.db").to_owned())
}
if opt.databaseurl.is_some() { if opt.databaseurl.is_some() {
config.database_url = opt.databaseurl; config.database_url = opt.databaseurl;
} }
...@@ -296,22 +296,20 @@ fn main() { ...@@ -296,22 +296,20 @@ fn main() {
config.open_browser = Some(true) config.open_browser = Some(true)
} }
if config.database_url.is_some() { if config.database_url.is_some() {
let conn = let url = config.database_url.clone().unwrap();
postgres::Connection::connect(config.database_url.clone().unwrap(), postgres::TlsMode::None).unwrap();
print!("Using database {} … ", &url);
let conn = postgres::Connection::connect(url, postgres::TlsMode::None).unwrap();
println!("Connected");
prepare_and_start_server(conn, config, opt.onlycontestscan, opt.resetadminpw); prepare_and_start_server(conn, config, opt.onlycontestscan, opt.resetadminpw);
} else { } else {
let conn = match config.database_file { let path = config.database_file.clone().unwrap();
Some(ref path) => { print!("Using database file {} … ", &path.to_str().unwrap_or("<unprintable filename>"));
println!("Using database file {}", &path.to_str().unwrap_or("<unprintable filename>")); let conn = rusqlite::Connection::open(path).unwrap();
rusqlite::Connection::open(path).unwrap() println!("Connected");
}
None => {
println!("Using default database file ./medal.db");
rusqlite::Connection::open(&Path::new("medal.db")).unwrap()
}
};
prepare_and_start_server(conn, config, opt.onlycontestscan, opt.resetadminpw); prepare_and_start_server(conn, config, opt.onlycontestscan, opt.resetadminpw);
} }
......
...@@ -416,7 +416,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response> ...@@ -416,7 +416,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response>
// TODO: Submit current session to login // TODO: Submit current session to login
let loginresult = with_conn![functions::login_with_code, C, req, &code]; let loginresult = with_conn![functions::login_with_code, C, req, &code];
println!("aa");
match loginresult { match loginresult {
// Login successful // Login successful
...@@ -430,7 +429,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response> ...@@ -430,7 +429,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response>
} }
// Login failed // Login failed
Err((template, data)) => { Err((template, data)) => {
println!("bb");
let mut resp = Response::new(); let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok); resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
Ok(resp) Ok(resp)
...@@ -457,8 +455,6 @@ fn submission<C>(req: &mut Request) -> IronResult<Response> ...@@ -457,8 +455,6 @@ fn submission<C>(req: &mut Request) -> IronResult<Response>
req.get_ref::<UrlEncodedQuery>().ok()?.get("subtask")?.get(0).map(|x| x.to_owned()) req.get_ref::<UrlEncodedQuery>().ok()?.get("subtask")?.get(0).map(|x| x.to_owned())
})(); })();
println!("{}", task_id);
let result = with_conn![functions::load_submission, C, req, task_id, &session_token, subtask]; let result = with_conn![functions::load_submission, C, req, task_id, &session_token, subtask];
match result { match result {
...@@ -479,10 +475,11 @@ fn submission_post<C>(req: &mut Request) -> IronResult<Response> ...@@ -479,10 +475,11 @@ fn submission_post<C>(req: &mut Request) -> IronResult<Response>
formdata.get("subtask").map(|x| x[0].to_owned()), formdata.get("subtask").map(|x| x[0].to_owned()),
) )
}; };
/* This should only be printed in verbose Mode:
print!("New submission for task {} (graded {}): ", task_id, grade);
println!("{}", data); println!("{}", data);
println!("{}", task_id); */
println!("{}", grade);
let result = let result =
with_conn![functions::save_submission, C, req, task_id, &session_token, &csrf_token, data, grade, subtask]; with_conn![functions::save_submission, C, req, task_id, &session_token, &csrf_token, data, grade, subtask];
...@@ -497,8 +494,6 @@ fn task<C>(req: &mut Request) -> IronResult<Response> ...@@ -497,8 +494,6 @@ fn task<C>(req: &mut Request) -> IronResult<Response>
let task_id = req.expect_int::<i32>("taskid")?; let task_id = req.expect_int::<i32>("taskid")?;
let session_token = req.require_session_token()?; let session_token = req.require_session_token()?;
println!("{}", task_id);
let (template, data) = with_conn![functions::show_task, C, req, task_id, &session_token].aug(req)?; let (template, data) = with_conn![functions::show_task, C, req, task_id, &session_token].aug(req)?;
let mut resp = Response::new(); let mut resp = Response::new();
...@@ -917,6 +912,6 @@ pub fn start_server<C>(conn: C, config: ::Config) -> iron::error::HttpResult<iro ...@@ -917,6 +912,6 @@ pub fn start_server<C>(conn: C, config: ::Config) -> iron::error::HttpResult<iro
let socket_addr = format!("{}:{}", config.host.unwrap(), config.port.unwrap()); let socket_addr = format!("{}:{}", config.host.unwrap(), config.port.unwrap());
let srvr = Iron::new(ch).http(&socket_addr); let srvr = Iron::new(ch).http(&socket_addr);
println!("Listening on {}.", &socket_addr); print!("Listening on {}", &socket_addr);
srvr srvr
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment