minor fixes

This commit is contained in:
陈浩南 2024-05-03 19:53:38 +08:00
parent c1b00bb9f1
commit 2c18ea7044
3 changed files with 11 additions and 9 deletions

View File

@ -61,9 +61,9 @@ namespace hpcstat::sql
unsigned Id = 0;
long Time;
unsigned JobId;
std::string JobResult, SubmitTime, Signature = "";
std::string JobResult, SubmitTime, JobDetail, Signature = "";
double CpuTime;
using serialize = zpp::bits::members<7>;
using serialize = zpp::bits::members<8>;
};
using FinishJobTable = zxorm::Table
<
@ -73,6 +73,7 @@ namespace hpcstat::sql
zxorm::Column<"job_id", &FinishJobData::JobId>,
zxorm::Column<"job_result", &FinishJobData::JobResult>,
zxorm::Column<"submit_time", &FinishJobData::SubmitTime>,
zxorm::Column<"job_detail", &FinishJobData::JobDetail>,
zxorm::Column<"signature", &FinishJobData::Signature>,
zxorm::Column<"cpu_time", &FinishJobData::CpuTime>
>;

View File

@ -16,7 +16,7 @@ namespace hpcstat::lfs
return std::nullopt;
else
{
std::set<std::string> valid_args = { "J" "q" "n" "R" "o" };
std::set<std::string> valid_args = { "J", "q", "n", "R", "o" };
for (auto it = args.begin(); it != args.end(); it++)
{
if (it->length() > 0 && (*it)[0] == '-')
@ -29,11 +29,11 @@ namespace hpcstat::lfs
"please submit issue on [github](https://github.com/CHN-beta/hpcstat) or contact chn@chn.moe.\n";
return std::nullopt;
}
if (it + 1 != args.end() && ((it + 1)->length() == 0 || (*(it + 1))[0] != '-')) it++;
else if (it + 1 != args.end() && ((it + 1)->length() == 0 || (*(it + 1))[0] != '-')) it++;
}
else break;
}
if (auto result = exec(*bsub, args); result) return std::nullopt;
if (auto result = exec(*bsub, args); !result) return std::nullopt;
else
{
// Job <462270> is submitted to queue <normal_1day>.

View File

@ -19,7 +19,7 @@ int main(int argc, const char** argv)
}
else if (args[1] == "login")
{
std::cout << "Communicating with the agent..." << std::flush;
if (env::interactive()) std::cout << "Communicating with the agent..." << std::flush;
if (auto fp = ssh::fingerprint(); !fp) return 1;
else if (auto session = env::env("XDG_SESSION_ID", true); !session)
return 1;
@ -34,7 +34,7 @@ int main(int argc, const char** argv)
if (!signature) return 1;
data.Signature = *signature;
sql::writedb(data);
std::cout << fmt::format("\33[2K\rLogged in as {}.\n", Keys[*fp].Username);
if (env::interactive()) std::cout << fmt::format("\33[2K\rLogged in as {}.\n", Keys[*fp].Username);
}
}
else if (args[1] == "logout")
@ -66,7 +66,7 @@ int main(int argc, const char** argv)
data.Signature = *signature;
sql::writedb(data);
std::cout << fmt::format
("Job {} was submitted to {} by {}.\n", bsub->first, bsub->second, Keys[*fp].Username);
("Job <{}> was submitted to <{}> by <{}>.\n", bsub->first, bsub->second, Keys[*fp].Username);
}
}
else if (args[1] == "finishjob")
@ -94,7 +94,8 @@ int main(int argc, const char** argv)
sql::FinishJobData data
{
.Time = now(), .JobId = jobid, .JobResult = std::get<1>(all_jobs->at(jobid)),
.SubmitTime = std::get<1>(all_jobs->at(jobid)), .CpuTime = std::get<2>(all_jobs->at(jobid)),
.SubmitTime = std::get<0>(all_jobs->at(jobid)), .JobDetail = *detail,
.CpuTime = std::get<2>(all_jobs->at(jobid)),
};
if
(