Kattis shell for getting examples, testing and submitting.

Related tags

CLI Tools Kat
Overview

Kat - a command-line Kattis assistant

This is a command-line program for getting, testing, and submitting Kattis problem attempts!

Credit goes to Kattis and their python script for submitting files found here. Our submission script is heavily inspired by theirs.

Logo provided by @CptF1nn

Installing

  1. First of all, download this repository (either by .zip or via git) and make sure to extract it to a known location.
  2. Install dependencies by running python -m pip install -r requirements.txt inside the directory.
  3. Add the directory to your %PATH-variable on Windows or ln -s /path/to/kat/kattis.py /usr/bin/kat on Unix systems (Linux/Mac)
  4. To use most functionalities, add your personal configuration to this repository. Go to open.kattis.com > Help > How to submit > Download your personal configuration file and download the resulting file to this folder as .kattisrc.
  5. Run kattis startup to run an install-guide where Kat-internal configurations are copied into the .kattisrc and settings such as language are set up.

Usage

To get a list of commands and usage, use kattis --help and kattis [command] --help once installed.

Get

kattis get problem [problem ...]

This downloads the sample input-output files for the problem and creates a directory for the problem. Inside, the test files are put in the subfolder test, and an initial script file is waiting for your solution. To specify your language of choice for a single problem, use the command -l LANGUAGE. Happy hacking!

Test/watch

kattis test/watch problem [file]

test pipes every .in-file into the corresponding script, while recording the output. The output is compared to the corresponding .ans-files and supplied to a report, which tells you which tests failed and displaying failed output.

If multiple supported source files are present within the problem directory, you are prompted to choose one. Alternatively, you can supply the path to your chosen script as a second argument

If you use watch instead of test, then a file watcher is used on the primary script file, making the tests run when you save the file.

Submit

kattis submit problem [file]

This submits a given script to kattis for final judgement. Remember to get your configuration file from here.

If multiple supported source files are present within the problem directory, you are prompted to choose one. Alternatively, you can supply the path to your chosen script as a second argument.

Archive/Unarchive

kattis archive/unarchive problem [problem ...]

Move a problem (or several) between a ./.archive folder and the current folder.

List

kattis list [-p PAGE] [-l LIMIT] [-c] [sorting/filter [sorting/filter ...]]

List problems from the Kattis instance.

--compact shows only the names of the problems.

Possible sortings:

  • Leaving it out sorts problems alphabetically by display name
  • easiest sorts easiest problem first, by points
  • hardest sorts hardest problem first

If you add several filters, then they are used in a union style (unsolved solved would allow every problem again)

Possible filters:

  • unsolved allows any problem not solved, same as tried untried
  • solved allows any solved problem
  • tried allows problems tried before
  • untried allows problem never even tried before

Contest

kattis contest [-c CONTEST_URL] get [-s] [-o] [-l LANGUAGE]

Get all problems from a contest, optionally submitting already completed problems.

You can provide only the ID of a contest if you have the hostname in the config, otherwise the whole URL should be provided.

Read

kattis read [-c] problem [problem ...]

Read the problem descriptions in your browser.

--console prints the description in the console, but test cases and embedded LaTeX takes up a lot of space, making it hard to use.

Work

kattis work [-h] [-oafs] [sorting/filter [sorting/filter ...]]

This command initiates a loop where you can run commands by just typing their command, and where problems are automatically opened according to filters and sorting for the list command. You can specify arguments for submit and get to this command, which will be applied when running them in the loop.

Boilerplates

If you add a script file for your favourite language to the boilerplate folder, it is copied into every new problem you initialize with the get command. That way, you can quickly get started on solving problems.

Configuration

Once you have used almost any command once, configurations have appeared in your .kattisrc. The great part about them is that they are very extensible, allowing you to register additional languages and the like.

User

You probably wouldn't want to change the username or token fields manually, but here you can. These fields are the primary reason for getting the .kattisrc from the Kattis instance.

Kattis

This section contains information about which kattis instance you are currenctly using. If you want to change the hostname, you should either remove the other options (relying on known fallback-routes shared among Kattis instances) or replace the hostname in each.

Kat

The primary config options for the Kat tool, and the ones you would like to change the most often.

language designates the language used for creating the initial script file in the get command.

openfilecommand (WIP) designates a way to open a file after get or unarchive, letting you work just a bit faster on problems.

workcommand specifies which arguments you would want to call the work command with, since there are an awful lot of arguments possible.

File associations

Here, you can associate a file type with a specific language. This is used as the sole source of truth when determining language, so make sure it works with your Kattis instance before editing this config.

Initialize commands

These commands are used to initialize problem folders for languages which cannot use only script files. If you use a build system you would like to use for a language in Kattis, then here is where that command goes.

Run commands

These commands tell Kat how to run and test your submission attempt. Without a command for your language, the test and run commands do not work.

There are some indicators which are replaced when running the command:

  • @f is replaced with the file name
  • @c is replaced with the problem name

Compile commands

These commands tell Kat that script files should be compiled before being run.

See the section on Run commands above for info on indicators.

For C++ support it is required that a C++ compiler exists in PATH and is specified under [Compile commands] in your .kattisrc. By default the compiler used is g++.

Naming

Some languages, like Java, enforce a naming convention for their files. If any other language enforces capital first letter, then add it here.

Currently, only PascalCase is supported, create an issue or edit the namingSchemeConverters in helpers/fileUtils.py to add more cases.

Comments
  • Play sound crashes on windows, not sure why :)

    Play sound crashes on windows, not sure why :)

    Traceback (most recent call last):
      File "D:\.Projekter\Kat\kattis.py", line 41, in main
        execCommand[command](data)
      File "D:\.Projekter\Kat\commands\submit.py", line 81, in submitCommand
        winsound()
      File "D:\.Projekter\Kat\helpers\sound.py", line 8, in winsound
        playsound(random.choice(glob.glob(prefix + "/win/*.mp3")))
      File "C:\Users\mikke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 72, in _playsoundWin
        winCommand(u'open {}'.format(sound))
      File "C:\Users\mikke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 64, in winCommand
        raise PlaysoundException(exceptionMessage)
    playsound.PlaysoundException: 
        Error 305 for command:
            open "D:\.Projekter\Kat\helpers/../resources//win\win.mp3"
        Der kan ikke angives ekstra tegn efter en streng, som er omgivet af anførelsestegn.
    
    
    opened by MikkelNilsson 2
  • Test specific index case only

    Test specific index case only

    If for example a problem has many test cases baiscprogramming1 for example has a lot that take some time to go through.

    Testing the last sample with kattis test basicprogramming1 7 would make it immensely faster.

    This could even include testing only a range, 5-7 on basicprogramming1 for example.

    opened by CptF1nn 2
  • Add alternative to manually changing language

    Add alternative to manually changing language

    I have seperate folders that I use for Kattis written in Python, F# or Java. I would like to have the option to tell Kat what language the folder is for, and then just have that determine what language should be used

    enhancement 
    opened by Jakobis 2
  • Contest mode

    Contest mode

    To enter a contest: kat contest enter <contest-id> this makes future commands work against the contest url.

    when contest is done and you want to go back to normal mode: kat contest leave (perhaps with alias end)

    enhancement 
    opened by jlndk 2
  • Submit crashes when including slashes

    Submit crashes when including slashes

    Most commands, like archive and test, work fine if you tab to complete them, even though the command ends up looking like .\simplecronspec, but submit crashes.

    Traceback (most recent call last):
      File "C:\Users\Clipsterman\PycharmProjects\Kat\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\Clipsterman\PycharmProjects\Kat\commands\submit.py", line 66, in submitCommand
        "📬 Submission Successful (url " + getConfigUrl("submissionsurl", "submissions") + "/" + id + ")"
    TypeError: can only concatenate str (not "int") to str
    
    
    opened by Jakobis 1
  • Exception:

    Exception: "can only concatenate str (not "NoneType") to str"

    Traceback (most recent call last):
      File "C:\Users\Clipsterman\PycharmProjects\Kat\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\Clipsterman\PycharmProjects\Kat\commands\submit.py", line 81, in submitCommand
        losesound()
      File "C:\Users\Clipsterman\PycharmProjects\Kat\helpers\sound.py", line 12, in losesound
        playsound(playsound(random.choice(glob.glob(prefix + "/lose/*.mp3"))))
      File "C:\Users\Clipsterman\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 35, in _playsoundWin
        winCommand('open "' + sound + '" alias', alias)
    TypeError: can only concatenate str (not "NoneType") to str
    
    
    opened by Jakobis 1
  • Submission results from other Kattis instances (like itu.kattis.com) does not show up

    Submission results from other Kattis instances (like itu.kattis.com) does not show up

    Apparently, the mentioned instance does not use the checkmark sequence that open.kattis.com uses, so a different approach might be required to get the submission status.

    opened by Duckapple 1
  • Add flag to

    Add flag to "test" command for automatically submitting if it passes tests

    Sometimes, you're so sure of your code that you want to run kattis test and immediately submit the code if it passes the tests.

    I imagine it could look something like this: kattis test -s problemname

    And to circumvent the y/N on kattis submit, you could even have a force submit with: kattis test -fs problemname

    This might all be compressed into a single command (test-submit) instead of flags: kattis ts problemname

    enhancement 
    opened by CptF1nn 1
  • Rewrite in Rust

    Rewrite in Rust

    Let's just do it. Pros:

    • Binaries are faster
    • Rust is expandable
    • Rust is good to learn
    • I wanna do it, even if it means I'll do it on my own Cons:
    • There is a learning curve
    • Cloning the repository is not enough to run; building is required
      • Can be alleviated by releasing releases. CI would be required, and we should scope release types.
    opened by Duckapple 1
  • Stop test process if file doesn't compile

    Stop test process if file doesn't compile

    Testing a non-existent or previous version of a .class file i not helpful. It would be more helpful if the testing process ended after a compile error

    opened by poppyjones 1
  • Add unarchive command

    Add unarchive command

    Add a command that allows users to unarchive a certain problem.

    This would also be useful for work mode where getting to an archived problem tells you that you've already gotten a problem, but trying to test or submit it will give an error.

    opened by Jakobis 1
  • Exception:

    Exception: " Error 277 for command: open "C:\Users\jonas\AppData\Roaming\Kat\resources\win\win.mp3" alias playsound_0.3350055210840338 Der opstod et problem under initialisering af MCI."

    Traceback (most recent call last):
      File "C:\Users\jonas\AppData\Roaming\Kat\kattis.py", line 43, in main
        execCommand[command](data)
      File "C:\Users\jonas\AppData\Roaming\Kat\commands\submit.py", line 87, in submitCommand
        winsound()
      File "C:\Users\jonas\AppData\Roaming\Kat\helpers\sound.py", line 9, in winsound
        playsound(random.choice(glob.glob(os.path.join(prefix, "win", "*.mp3"))))
      File "C:\Users\jonas\AppData\Roaming\Python\Python310\site-packages\playsound.py", line 35, in _playsoundWin
        winCommand('open "' + sound + '" alias', alias)
      File "C:\Users\jonas\AppData\Roaming\Python\Python310\site-packages\playsound.py", line 31, in winCommand
        raise PlaysoundException(exceptionMessage)
    playsound.PlaysoundException: 
        Error 277 for command:
            open "C:\Users\jonas\AppData\Roaming\Kat\resources\win\win.mp3" alias playsound_0.3350055210840338
        Der opstod et problem under initialisering af MCI.
    
    
    opened by joglr 0
  • PermissionError:

    PermissionError: "[WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots'"

    Traceback (most recent call last):
      File "...\shutil.py", line 813, in move
        os.rename(src, real_dst)
    PermissionError: [WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots' -> '.solved/carrots'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "...\Kat\kattis.py", line 41, in main
        execCommand[command](data)
      File "...\Kat\commands\submit.py", line 85, in submitCommand
        archive(problemName, ".solved/")
      File "...\Kat\commands\archive.py", line 30, in archive
        shutil.move(problemName, folder + problemName)
    PermissionError: [WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots'
    
    
    opened by MegetSkuffet 1
  • Extend config command

    Extend config command

    Make config command capable of

    • giving the location(s) of the read configs
    • giving the location of the one it saves to
    • get contents of individual options
    opened by Duckapple 0
  • Exception:

    Exception: "'utf-8' codec can't decode byte 0xe5 in position 23: invalid continuation byte"

    Can't handle special characters in print() statement, throws the above exception (I tried with the Danish 'å' letter.)

    In addition, at submission, because of the issue, it replaces the special characters with others, producing a 'Wrong answer' result.

    Traceback (most recent call last):
      File "C:\Users\path\to\Kat-master\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\path\to\Kat-master\commands\test.py", line 57, in testCommand
        result, time = runSingleTest(command, directory, inF, ansF)
      File "C:\Users\path\to\Kat-master\commands\test.py", line 107, in runSingleTest
        subprocess.run(command, stdout=subprocess.PIPE, input=inp, cwd=directory)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 23: invalid continuation byte
    
    
    opened by Navarot 3
Releases(1.9.0)
  • 1.9.0(Feb 7, 2022)

    Changelog:

    • Added switch command: Allows you to switch between config files for different instances
      • (Currently only works for configs in the same folder)
    • Added more cases for exiting after submission (Thanks @marfavi!)
    • Added Rust support
    • Added Go support
    • Fixed Rust support
    • Fixed lack of feedback when problem is already active with get command
    • Fixed autocomplete for problem names on Windows (Thanks @jakobis!)
    • Bumped packages (Thanks @jakobis!)
    Source code(tar.gz)
    Source code(zip)
    install_mac.sh(949 bytes)
    install_windows.bat(1.32 KB)
  • 1.8.0(Mar 30, 2021)

    Changelog:

    • Made the config make use of the openfilecommand option under [kat]. When defined, get command automatically invokes this function in order to open the problem in your editor of choice. I use Visual Studio Code, and thus my command is code -r @d, which opens the problem source file in my currently open editor. An alternative would be code @p if you want to open the problem folder.
    • Made .out files work like .ans files
    • Fixed boilterplate not getting copied
    • Removed the stacktrace from terminating tests with ctrl+c
    • Added feedback to contest get for when the contest hasn't begun
      • Also added feedback for when it is over.

    On an organizational note: I think I'll start using releases as a way to keep info about changes in this form instead of in commit history, which only I really look at.

    Source code(tar.gz)
    Source code(zip)
Owner
Simon Green Kristensen
Simon Green Kristensen
Kubernetes shell: An integrated shell for working with the Kubernetes

kube-shell Kube-shell: An integrated shell for working with the Kubernetes CLI Under the hood kube-shell still calls kubectl. Kube-shell aims to provi

CloudNative Labs 2.2k Jan 8, 2023
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 2021
iTerm2 Shell integration for Xonsh shell.

iTerm2 Shell Integration iTerm2 Shell integration for Xonsh shell. Installation To install use pip: xpip install xontrib-iterm2 # or: xpip install -U

Noorhteen Raja NJ 6 Dec 29, 2022
A simple CLI tool for getting region-specific status of Logz.io components.

About A simple CLI tool for checking the current status of Logz.io components per region. Built With Python 3 The following packeges (see requirements

Yotam Bernaz 1 Dec 11, 2021
WebApp Maker make web apps (Duh). It is open source and make with python and shell.

WebApp Maker make web apps (Duh). It is open source and make with python and shell. This app can take any website and turn it into an app. I highly recommend turning these few websites into webapps: - Krunker.io (Fps Game) - play.fancade.com (Minigame Arcade) - Your Own Website If You Have One Apart from that enjoy my app By 220735540 (a.k.a RP400)

null 2 Jan 9, 2022
Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries

Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries. It automates the boring stuff like URL encoding the command and setting up a listener.

Yash Bhardwaj 3 Sep 27, 2022
xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

xonsh xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt. The language is a superset of Python 3.6+ with additio

xonsh 6.7k Jan 8, 2023
A CLI/Shell supporting OpenRobot API and more!

A CLI/Shell supporting JeyyAPI, OpenRobot API and RePI API.

OpenRobot Packages 1 Jan 6, 2022
DShell, a tool that combines with discord.py and Jishaku to present to you, shell channels.

Discord shell or dshell for short is a Python package that combines with discord.py and Jishaku to transform an ordinary Discord channel into one capable of running bash commands using a Discord bot.

null 11 Nov 15, 2022
A Python script for finding a food-truck based on latitude and longitude coordinates that you can run in your shell

Food Truck Finder Project Description This repository contains a Python script for finding a food-truck based on latitude and longitude coordinates th

null 1 Jan 22, 2022
xonsh is a Python-powered, cross-platform, Unix-gazing shell

xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

xonsh 6.7k Dec 31, 2022
adds flavor of interactive filtering to the traditional pipe concept of UNIX shell

percol __ ____ ___ ______________ / / / __ \/ _ \/ ___/ ___/ __ \/ / / /_/ / __/ / / /__/ /_/ / / / .__

Masafumi Oyamada 3.2k Jan 7, 2023
Fetch is use to get information about anything on the shell using Wikipedia.

Fetch Search wikipedia article on command line [Why This?] [Support the Project] [Installation] [Configuration] Why this? Fetch helps you to quickly l

Yash Singh 340 Dec 18, 2022
A simple reverse shell in python

RevShell A simple reverse shell in python Getting started First, start the server python server.py Finally, start the client (victim) python client.py

Lojacopsen 4 Apr 6, 2022
a-shell: A terminal for iOS, with multiple windows

a-shell: A terminal for iOS, with multiple windows

Nicolas Holzschuch 1.7k Jan 2, 2023
A simple python implementation of a reverse shell

llehs A python implementation of a reverse shell. Note for contributors The project is open for contributions and is hacktoberfest registered! llehs u

Archisman Ghosh 2 Jul 5, 2022
Just a shell writed on Python

HIGHSHELL (also hSH or HS) Just a shell writed on Python Send bug report • How to use the shell • Broked features • Licenses How to use the shell Inst

0LungSkill0 2 Jan 4, 2022