-
checkio-client & Web Extension
Short overview
CheckIO doesn't stand still and one of its priority development vectors is making the process of solving tasks more convenient and effective. For this purpose was created a new program - checkio-client.
One of its main goals is to become an alternative to CheckIO's web interface, and to the code editor in particular. So now you can use your favorite IDE to write the solution code, and then use checkio-client to test the written solutions. In addition to this function, it has a number of other equally useful features:
- the synchronization of all of your mission solutions;
- creation of a template repository for a new mission;
- testing of the created mission;
- sending a repository with a mission to GitHub.
Let's get to know it better.
The installation and description of new features
First of all, the checkio-client needs to be installed and configured. It's quite simple really - just type in the command line:
pip3 install checkio_client
After this, in order to enable the program to operate correctly, it's necessary to start the configuration process before the first start. You can do this with the command:
checkio config
If checkio command not found after installation the tool, try to use sudo:
sudo pip3 install checkio_client
Then you'll need to choose which server you'll use as the main one (py or js), and enter the corresponding personal key which you can find in your profile in the Api Access Code line. Note that the keys for Python and JavaScript are different.
After completing the setup procedure, you'll be able to use all functions mentioned above.
1. Running and testing your solution
As we've pointed out earlier, it's highly possible that you've gotten used to write code in some particular IDE and writing a solution using CheckIO's web interface may not be very convenient. In order for you to work in your usual development environment, checkio-client has two interchangeable options for testing your solutions (look at an example for a median mission):
checkio init median checkio_solutions/median.py checkio_solutions/median.py --check
(you can also use the second command without --check
- in that case your solution will run as normal Python or JS script, depending on what you've chosen)
After successfully passing the tests, you'll receive a link to the solutions of other users, as well as a link to share your own solution.
Pay attention that to the server will be sent just the solution code with no comments at the top (comments with the mission description and examples are added to the files with the solutions during the synchronization when they are being saved to your computer).
2. Synchronization of all of your solutions
Code of some of your solutions might come in handy not only while solving coding challenges, but also in other outside projects. But opening each task manually and reviewing your solution, evaluating its potential usefulness, is quite tiresome, isn't it?
Fortunately, checkio-client makes it easy to solve this problem with a single command:
$ checkio sync ~/checkio_solutions
After its execution, all of your solutions (even for those tasks you haven't started to solve yet) will be saved in the specified folder as the usual python or js scripts in the format mission-name.py (mission-name.js). As have already been mentioned, at the top of each solution there will also be a few commented lines with a description of the mission and examples.
After the primary saving of the missions to the local disk, the synchronization works as follows: sends all the solutions updates from the specified folder to the server (if you've made the latest changes locally) or vice versa, saves the solutions updates from the server (if the last changes were made on the site). Thus, if inspiration came down on you and you've solved several missions in a row, while saving the files with the solutions locally, synchronizing all of the changes with this command will be a piece of cake. Same goes for a situation when you've solved many tasks using only the web interface.
Also note that during the solution testing (wherever it occurs - in the browser or in the console), the last tested version of the code is being saved, and it will be used to synchronize and overwrite earlier versions.
The last folder you've specified during synchronization will be written to ~/.checkio/config.ini, so if you need to re-synchronize using the same folder, just type:
$ checkio sync
not specifying the folder.
In addition, it'll be possible to use simpler commands to run and test the solutions. They will look like this:
$ checkio check median $ checkio run median
Web extension
Nevertheless, the synchronization might be a cool thing to do, it’s not mandatory. Now, if you don’t feel like synchronizing your solutions from CheckIO with your local computer, it’s no biggie, because all of your solutions will be saved in the “py_checkio_solutions” (or “js_checkio_solution” for JS) folder, which is in your home directory, by default.
In order to install Chrome Extension in your browser, you’ll need to make two simple steps.
The first one is to configure the console tool (don't forget to sync your solutions in a local folder):
$ checkio install-plugin
After the successful configuration you’ll need to install Chrome Extension, which can be found here.
Now when you open CheckiO web editor, it’ll automatically use files from your local folder. If you’d like to use FireFox instead of Chrome you can add --ff option to the command
$ checkio install-plugin --ff
The extension for FF can be found here
You can also install the Chromium Extension using the following command:
$ checkio install-plugin --chromium
Windows users will have to make an extra step where you’ll be asked the path to your code editor. By default, the path to Sublime Text 3 is selected.
After installation and configuration of the plugin, you might need to restart your browser (chrome or ff)
The extension is in beta testing right now, so please let me know in comments if you have any issues while using it.
In order to uninstall the plugin do the following:
$ checkio uninstall-plugin
for Chrome Plugin and:
$ checkio uninstall-plugin --ff
for FireFox.
CheckiO serv as an alternative to using a browser plugin
In one of the recent updates, we added the serv command.
$ checkio serv -d
You can launch a local server instead of using a browser plugin.
And stop it any time.
$ checkio servd-stop
Creation and testing of missions
As you know, since the 9th level CheckIO users can create missions themselves and test them. Previously, the checkio-task-tester was used for this purpose. This tool was very useful, however, we've decided to add several extra functions to the testing. Furthermore, the checkio-client, unlike the task-tester, doesn't require the installation of Twisted, which means that Windows users won't have any additional difficulties with the startup.
1. Creating a Template RepositoryLike the checkio-task-tester, checkio-client allows you to create a ready-made project with one command, which you can use as a basis for your own missions.
You can do this with the command:
checkio initrepo ~/checkio_mission/new_mission
2. Testing the mission
A very important step that will allow you to check the mission for the absence of bugs, the correct display of illustrations and text, as well as verify the correctness of the tests and your own solution (if any). The testing is started by the following line:
checkio checkrepo ~/checkio_mission/new_mission
Then you need to open the corresponding tab in the browser - https://py.checkio.org/mission/tester/. Note that this method works for Python. If you want to test a mission for JavaScript, then the correct address will be https://js.checkio.org/mission/tester/, and the command will be added with an indication of js:
checkio --domain=js checkrepo ~/checkio_mission/new_mission
3. Sending the repository with a mission to GitHub
After you've finished checking the mission and made sure there were no errors, it's time to add the mission to GitHub. For this we use the following code:
$ checkio linkrepo ~/checkio_mission/new_mission git@github.com:oduvan/checkio-mission-new-mission.git
If you are using Python and JavaScript
In order to make better use of the checkio-client for both languages, after completing the configuration procedure, you'll need to enter the .checkio folder and make the appropriate changes to the config.ini file whose contents (if you chose 'py') will look like this:
[Main] default_domain = py [py_checkio] key = b30523506050473b8f33ca440101026a [js_checkio]
You just need to add the JS key and use --domain=js
when entering commands, for the checkio-client to work with the js domain.
In order to learn about additional features, you can read the official documentation from the developers.
Also you can read about the previous version of the program for creating and testing missions - checkio-task-tester, in the relevant publication and read the documentation.
If you have interesting ideas for new missions, we recommend you to go through the relevant article, which describes all the key stages - from discussing the idea with other users, to the official release after the testing period on the Polygon.
Conclusion
We're planning to extend its functionality in future, and there will be the opportunities for joint work between the checkio-client and Atom, Sublime Text, Visual Studio Code, and other code editors.
The possibility of integration with PyCharm Edu has just recently appeared and you can read all about it in this article.
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.
Join the Game