Assuming the repo is cloned at /scratch/karnada/Sandbox/zulip-bots/zulip-karti-bot
create the following systemd service:
[Unit]
Description=Karti Zulip Bot
After=network.target
[Service]
Type=simple
User=karnada
WorkingDirectory=/scratch/karnada/Sandbox/zulip-bots
ExecStart=/bin/bash -c "source /scratch/karnada/Sandbox/zulip-bots/startkarti.sh"
Restart=on-failure
[Install]
WantedBy=multi-user.target
with contents of /scratch/karnada/Sandbox/zulip-bots/startkarti.sh
as:
#!/bin/bash
source /scratch/karnada/Sandbox/zulip-bots/zulip-env/bin/activate
sleep 10
zulip-run-bot karti --force --config-file /scratch/karnada/Sandbox/zulip-bots/kartizuliprc
To use this service, save the file as karti-zulip-bot.service
in the /etc/systemd/system
directory. Then, you can start the service using the following command:
sudo systemctl start karti-zulip-bot
To enable the service to start automatically at boot, use the following command:
sudo systemctl enable karti-zulip-bot```
Note: Make sure to replace `/scratch/karnada/Sandbox/zulip-bots/zulip-env/bin/activate` with the actual path to the script that activates your virtual environment, and `zulip-run-bot karti --config-file zuliprc` with the actual command you want to run.
This repository contains the source code for Zulip's PyPI packages:
zulip
: PyPI package for Zulip's API bindings.zulip_bots
: PyPI package for Zulip's bots and bots API.zulip_botserver
: PyPI package for Zulip's Flask Botserver.
The source code is written in Python 3.
This is part of the Zulip open source project; see the contributing guide and commit guidelines.
-
Fork and clone the Git repo, and set upstream to zulip/python-zulip-api:
git clone https://github.com/<your_username>/python-zulip-api.git cd python-zulip-api git remote add upstream https://github.com/zulip/python-zulip-api.git git fetch upstream
-
Make sure you have pip.
-
Run:
python3 ./tools/provision
This sets up a virtual Python environment in
zulip-api-py<your_python_version>-venv
, where<your_python_version>
is your default version of Python. If you would like to specify a different Python version, runpython3 ./tools/provision -p <path_to_your_python_version>
-
If that succeeds, it will end with printing the following command:
source /.../python-zulip-api/.../activate
You can run this command to enter the virtual environment. You'll want to run this in each new shell before running commands from
python-zulip-api
. -
Once you've entered the virtualenv, you should see something like this on the terminal:
(zulip-api-py3-venv) user@pc ~/python-zulip-api $
You should now be able to run any commands/tests/etc. in this virtual environment.
You can run all the tests with:
pytest
or test individual packages with pytest zulip
, pytest zulip_bots
,
or pytest zulip_botserver
(see the pytest
documentation
for more options).
To run the linter, type:
./tools/lint
To check the type annotations, run:
./tools/run-mypy