-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ripper runs status changer (#20)
* feat: ripper runs status changer * fix: rejudge for rejudge, not empty; less verdicts
- Loading branch information
Showing
8 changed files
with
170 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ linters: | |
- depguard | ||
- wsl | ||
- wrapcheck | ||
- goerr113 | ||
- exhaustruct | ||
- godox | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"os" | ||
"sort" | ||
|
||
"github.com/Gornak40/algolymp/config" | ||
"github.com/Gornak40/algolymp/ejudge" | ||
"github.com/akamensky/argparse" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
verdicts := make([]string, 0, len(ejudge.Verdicts)) | ||
for v := range ejudge.Verdicts { | ||
verdicts = append(verdicts, v) | ||
} | ||
sort.Strings(verdicts) | ||
|
||
parser := argparse.NewParser("ripper", "Change Ejudge runs status (stdin input).") | ||
cID := parser.Int("i", "cid", &argparse.Options{ | ||
Required: true, | ||
Help: "Ejudge contest ID", | ||
}) | ||
status := parser.Selector("s", "status", verdicts, &argparse.Options{ | ||
Required: true, | ||
Help: "New runs status", | ||
}) | ||
if err := parser.Parse(os.Args); err != nil { | ||
logrus.WithError(err).Fatal("bad arguments") | ||
} | ||
|
||
cfg := config.NewConfig() | ||
ejClient := ejudge.NewEjudge(&cfg.Ejudge) | ||
|
||
sid, err := ejClient.Login() | ||
if err != nil { | ||
logrus.WithError(err).Fatal("login failed") | ||
} | ||
|
||
csid, err := ejClient.MasterLogin(sid, *cID) | ||
if err != nil { | ||
logrus.WithError(err).Fatal("master login failed") | ||
} | ||
|
||
logrus.Info("waiting for run ids input...") | ||
for { | ||
var runID int | ||
_, err := fmt.Scanf("%d", &runID) | ||
if errors.Is(err, io.EOF) { | ||
break | ||
} | ||
if err != nil { | ||
logrus.WithError(err).Fatal("invalid run id") | ||
} | ||
if err := ejClient.ChangeRunStatus(csid, runID, *status); err != nil { | ||
logrus.WithError(err).Fatal("failed change run status") | ||
} | ||
} | ||
|
||
if err := ejClient.Logout(sid); err != nil { | ||
logrus.WithError(err).Fatal("logout failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters