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;
use db_conn::MedalConnection;
pub fn test<C: MedalConnection>(conn: &mut C) {
println!("reading dirs");
let mut paths: Vec<_> =
fs::read_dir(format!("migrations/{}", conn.dbtype())).unwrap()
.map(|r| r.unwrap())
......@@ -27,5 +26,4 @@ pub fn test<C: MedalConnection>(conn: &mut C) {
println!("Found: {}. Already applied", path.path().display());
}*/
}
println!("finished");
}
......@@ -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();
if let Some(oauth_providers) = oauth_providers {
println!("tblub");
for oauth_provider in oauth_providers {
oauth_links.push((oauth_provider.provider_id.to_owned(),
oauth_provider.login_link_text.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("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)
}
......
......@@ -236,15 +236,12 @@ fn prepare_and_start_server<C>(mut conn: C, config: Config, onlycontestscan: boo
where C: MedalConnection + std::marker::Send + 'static,
db_objects::Contest: db_conn::MedalObject<C>
{
println!("connected!");
println!("applying migrations …");
db_apply_migrations::test(&mut conn);
if onlycontestscan || config.no_contest_scan == Some(false) {
println!("scanning for contests …");
print!("Scanning for contests …");
refresh_all_contests(&mut conn);
println!("finished")
println!(" Done")
}
if !onlycontestscan {
......@@ -283,6 +280,9 @@ fn main() {
if opt.databasefile.is_some() {
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() {
config.database_url = opt.databaseurl;
}
......@@ -296,22 +296,20 @@ fn main() {
config.open_browser = Some(true)
}
if config.database_url.is_some() {
let conn =
postgres::Connection::connect(config.database_url.clone().unwrap(), postgres::TlsMode::None).unwrap();
let url = config.database_url.clone().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);
} else {
let conn = match config.database_file {
Some(ref path) => {
println!("Using database file {}", &path.to_str().unwrap_or("<unprintable filename>"));
rusqlite::Connection::open(path).unwrap()
}
None => {
println!("Using default database file ./medal.db");
rusqlite::Connection::open(&Path::new("medal.db")).unwrap()
}
};
let path = config.database_file.clone().unwrap();
print!("Using database file {} … ", &path.to_str().unwrap_or("<unprintable filename>"));
let conn = rusqlite::Connection::open(path).unwrap();
println!("Connected");
prepare_and_start_server(conn, config, opt.onlycontestscan, opt.resetadminpw);
}
......
......@@ -416,7 +416,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response>
// TODO: Submit current session to login
let loginresult = with_conn![functions::login_with_code, C, req, &code];
println!("aa");
match loginresult {
// Login successful
......@@ -430,7 +429,6 @@ fn login_code_post<C>(req: &mut Request) -> IronResult<Response>
}
// Login failed
Err((template, data)) => {
println!("bb");
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
Ok(resp)
......@@ -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())
})();
println!("{}", task_id);
let result = with_conn![functions::load_submission, C, req, task_id, &session_token, subtask];
match result {
......@@ -479,10 +475,11 @@ fn submission_post<C>(req: &mut Request) -> IronResult<Response>
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!("{}", task_id);
println!("{}", grade);
*/
let result =
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>
let task_id = req.expect_int::<i32>("taskid")?;
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 mut resp = Response::new();
......@@ -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 srvr = Iron::new(ch).http(&socket_addr);
println!("Listening on {}.", &socket_addr);
print!("Listening on {}", &socket_addr);
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